mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-08 10:41:19 +00:00
eb70fc73cd
Former-commit-id: 25dc367490dd16ef4fa1d462118aa438df1b319a [formerly 6fab78aeb8b9f54fddbad1406f97392b753a830a] Former-commit-id: 0de0bb3ef9af1735ac8ecd1aefe2d57c0f76c62d
30 lines
731 B
Go
30 lines
731 B
Go
package bn256
|
|
|
|
import (
|
|
"crypto/rand"
|
|
|
|
"testing"
|
|
)
|
|
|
|
func TestLatticeReduceCurve(t *testing.T) {
|
|
k, _ := rand.Int(rand.Reader, Order)
|
|
ks := curveLattice.decompose(k)
|
|
|
|
if ks[0].BitLen() > 130 || ks[1].BitLen() > 130 {
|
|
t.Fatal("reduction too large")
|
|
} else if ks[0].Sign() < 0 || ks[1].Sign() < 0 {
|
|
t.Fatal("reduction must be positive")
|
|
}
|
|
}
|
|
|
|
func TestLatticeReduceTarget(t *testing.T) {
|
|
k, _ := rand.Int(rand.Reader, Order)
|
|
ks := targetLattice.decompose(k)
|
|
|
|
if ks[0].BitLen() > 66 || ks[1].BitLen() > 66 || ks[2].BitLen() > 66 || ks[3].BitLen() > 66 {
|
|
t.Fatal("reduction too large")
|
|
} else if ks[0].Sign() < 0 || ks[1].Sign() < 0 || ks[2].Sign() < 0 || ks[3].Sign() < 0 {
|
|
t.Fatal("reduction must be positive")
|
|
}
|
|
}
|