github.com/consensys/gnark-crypto@v0.14.0/internal/generator/sis/generate.go (about) 1 package sis 2 3 import ( 4 "math/bits" 5 "path/filepath" 6 7 "github.com/consensys/bavard" 8 "github.com/consensys/gnark-crypto/internal/generator/config" 9 ) 10 11 func Generate(conf config.Curve, baseDir string, bgen *bavard.BatchGenerator) error { 12 13 conf.Package = "sis" 14 entries := []bavard.Entry{ 15 {File: filepath.Join(baseDir, "sis_fft.go"), Templates: []string{"fft.go.tmpl"}}, 16 } 17 18 funcs := make(map[string]interface{}) 19 funcs["bitReverse"] = func(n, i int64) uint64 { 20 nn := uint64(64 - bits.TrailingZeros64(uint64(n))) 21 r := make([]uint64, n) 22 for i := 0; i < len(r); i++ { 23 r[i] = uint64(i) 24 } 25 for i := 0; i < len(r); i++ { 26 irev := bits.Reverse64(r[i]) >> nn 27 if irev > uint64(i) { 28 r[i], r[irev] = r[irev], r[i] 29 } 30 } 31 return r[i] 32 } 33 34 bavardOpts := []func(*bavard.Bavard) error{bavard.Funcs(funcs)} 35 36 return bgen.GenerateWithOptions(conf, conf.Package, "./sis/template/", bavardOpts, entries...) 37 }