Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Classic McEliece #378

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
pass pointers instead of slices
  • Loading branch information
whyvl committed Oct 14, 2022
commit ecb22e79c145f2d730f24114f01be4f314d9bf0d
13 changes: 8 additions & 5 deletions kem/mceliece/mceliece348864/fft.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package mceliece348864

// The following code is translated from the C `vec` Additional Implementation
// from the NIST round 3 submission package.

import "github.com/cloudflare/circl/kem/mceliece/internal"

func fft(out [][gfBits]uint64, in []uint64) {
func fft(out *[exponent][gfBits]uint64, in *[gfBits]uint64) {
radixConversions(in)
butterflies(out, in)
}

func radixConversions(in []uint64) {
func radixConversions(in *[gfBits]uint64) {
for j := 0; j <= 4; j++ {
for i := 0; i < gfBits; i++ {
for k := 4; k >= j; k-- {
@@ -16,11 +19,11 @@ func radixConversions(in []uint64) {
}
}

vecMul(in, in, internal.RadixConversionsS4096[j][:]) // scaling
vecMul(in, in, &internal.RadixConversionsS4096[j]) // scaling
}
}

func butterflies(out [][gfBits]uint64, in []uint64) {
func butterflies(out *[exponent][gfBits]uint64, in *[gfBits]uint64) {
tmp := [gfBits]uint64{}
var constsPtr int
// broadcast
@@ -37,7 +40,7 @@ func butterflies(out [][gfBits]uint64, in []uint64) {

for j := 0; j < 64; j += 2 * s {
for k := j; k < j+s; k++ {
vecMul(tmp[:], out[k+s][:], internal.ButterfliesConsts4096[constsPtr+(k-j)][:])
vecMul(&tmp, &out[k+s], &internal.ButterfliesConsts4096[constsPtr+(k-j)])

for b := 0; b < gfBits; b++ {
out[k][b] ^= tmp[b]
33 changes: 18 additions & 15 deletions kem/mceliece/mceliece348864/pk_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 16 additions & 13 deletions kem/mceliece/mceliece348864/vec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 10 additions & 7 deletions kem/mceliece/mceliece460896/fft.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 18 additions & 15 deletions kem/mceliece/mceliece460896/pk_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading