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=6
Browse files Browse the repository at this point in the history
  • Loading branch information
tgkudelski authored Jan 16, 2024
1 parent 8380db8 commit 18058dd
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions crystals-kyber/poly.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,11 +256,17 @@ func (p *Poly) compress(d int) []byte {

case 6:
var t [4]uint16
var d0 uint32 /* accumulation value for fixing KyberSlash2 */
id := 0
for i := 0; i < n/4; i++ {
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)
for j := 0; j < 4; j++ {
/* t[j] = uint16(((uint32(p[4*i+j])<<6)+uint32(q)/2)/
uint32(q)) & ((1 << 6) - 1) */
d0 = uint32(p[8*i+j]) << 6
d0 += 1664
d0 *= 20159
d0 >>= 26
t[j] = uint16(d0 & 0x3f)
}
c[id] = byte(t[0]) | byte(t[1]<<6)
c[id+1] = byte(t[1]>>2) | byte(t[2]<<4)
Expand Down

0 comments on commit 18058dd

Please sign in to comment.