Files
icicle/wrappers/golang/curves/bls12381/tests/main_test.go
nonam3e f8d15e2613 update imports in golang bindings (#498)
## Describe the changes

This PR updates imports in golang bindings to the v2 version
2024-04-25 03:46:14 +07:00

49 lines
1.2 KiB
Go

package tests
import (
"os"
"testing"
"github.com/ingonyama-zk/icicle/v2/wrappers/golang/core"
bls12_381 "github.com/ingonyama-zk/icicle/v2/wrappers/golang/curves/bls12381"
ntt "github.com/ingonyama-zk/icicle/v2/wrappers/golang/curves/bls12381/ntt"
poly "github.com/ingonyama-zk/icicle/v2/wrappers/golang/curves/bls12381/polynomial"
"github.com/consensys/gnark-crypto/ecc/bls12-381/fr/fft"
)
const (
largestTestSize = 20
)
func initDomain[T any](largestTestSize int, cfg core.NTTConfig[T]) core.IcicleError {
rouMont, _ := fft.Generator(uint64(1 << largestTestSize))
rou := rouMont.Bits()
rouIcicle := bls12_381.ScalarField{}
limbs := core.ConvertUint64ArrToUint32Arr(rou[:])
rouIcicle.FromLimbs(limbs)
e := ntt.InitDomain(rouIcicle, cfg.Ctx, false)
return e
}
func TestMain(m *testing.M) {
poly.InitPolyBackend()
// setup domain
cfg := ntt.GetDefaultNttConfig()
e := initDomain(largestTestSize, cfg)
if e.IcicleErrorCode != core.IcicleErrorCode(0) {
panic("initDomain failed")
}
// execute tests
os.Exit(m.Run())
// release domain
e = ntt.ReleaseDomain(cfg.Ctx)
if e.IcicleErrorCode != core.IcicleErrorCode(0) {
panic("ReleaseDomain failed")
}
}