Skip to content

Commit

Permalink
pass pointers instead of slices
Browse files Browse the repository at this point in the history
  • Loading branch information
pufferffish committed Oct 14, 2022
1 parent 1b8c3d0 commit ecb22e7
Show file tree
Hide file tree
Showing 18 changed files with 265 additions and 211 deletions.
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-- {
Expand All @@ -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
Expand All @@ -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]
Expand Down
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

0 comments on commit ecb22e7

Please sign in to comment.