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

Commit

Permalink
bugfix:KyberSlash2 case d=11
Browse files Browse the repository at this point in the history
  • Loading branch information
tgkudelski authored Jan 16, 2024
1 parent 1ac2808 commit d457a8c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions crystals-kyber/poly.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,11 +297,17 @@ func (p *Poly) compress(d int) []byte {
}
case 11:
var t [8]uint16
var d0 uint64 /* 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])<<11)+uint32(q)/2)/
uint32(q)) & ((1 << 11) - 1)
/* t[j] = uint16(((uint32(p[8*i+j])<<11)+uint32(q)/2)/
uint32(q)) & ((1 << 11) - 1) */
d0 = uint64(p[4*i+j]) << 11
d0 += 1664
d0 *= 645084
d0 >>= 31
t[j] = uint16(d0 & 0x7ff)
}
c[id] = byte(t[0])
c[id+1] = byte(t[0]>>8) | byte(t[1]<<3)
Expand Down

0 comments on commit d457a8c

Please sign in to comment.