Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Commit

Permalink
Update poly.go
Browse files Browse the repository at this point in the history
  • Loading branch information
tgkudelski authored Jan 16, 2024
1 parent 56534a7 commit d2370c3
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions crystals-kyber/poly.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func (p *Poly) compress(d int) []byte {
var t [8]uint16
id := 0
for i := 0; i < n/8; i++ {
for j := 0; j < 8; j++ {
for j := 0; j < 8; j++ { //TODO: fix KyberSlash2 here
t[j] = uint16(((uint32(p[8*i+j])<<3)+uint32(q)/2)/
uint32(q)) & ((1 << 3) - 1)
}
Expand All @@ -207,11 +207,18 @@ func (p *Poly) compress(d int) []byte {

case 4:
var t [8]uint16
var d0 uint32 /* accumulation value for fixing KyberSlash2 */
id := 0
for i := 0; i < n/8; i++ {
for j := 0; j < 8; j++ {
t[j] = uint16(((uint32(p[8*i+j])<<4)+uint32(q)/2)/
uint32(q)) & ((1 << 4) - 1)
/* t[j] = uint16(((uint32(p[8*i+j])<<4)+uint32(q)/2)/
uint32(q)) & ((1 << 4) - 1)*/
t[j] = uint16(p[8*i+j])
d0 = uint32(t << 4)

Check failure on line 217 in crystals-kyber/poly.go

View workflow job for this annotation

GitHub Actions / 1.16 ubuntu-latest

invalid operation: t << 4 (shift of type [8]uint16)
d0 += 1665
d0 *= 80635
d0 >>= 28
t[j] = d0 & 0xf;

Check failure on line 221 in crystals-kyber/poly.go

View workflow job for this annotation

GitHub Actions / 1.16 ubuntu-latest

cannot use d0 & 15 (type uint32) as type uint16 in assignment
}
c[id] = byte(t[0]) | byte(t[1]<<4)
c[id+1] = byte(t[2]) | byte(t[3]<<4)
Expand Down Expand Up @@ -240,7 +247,7 @@ func (p *Poly) compress(d int) []byte {
var t [4]uint16
id := 0
for i := 0; i < n/4; i++ {
for j := 0; j < 4; j++ {
for j := 0; j < 4; j++ {//TODO: fix KyberSlash2 here
t[j] = uint16(((uint32(p[4*i+j])<<6)+uint32(q)/2)/
uint32(q)) & ((1 << 6) - 1)
}
Expand Down

0 comments on commit d2370c3

Please sign in to comment.