Files
arbo/ff_test.go
Lucas Menéndez 8e1cc943f4 feature: mimc bls12 377 (#31)
add mimc hash implementation over bls12_377 ecc from gnark
2024-11-20 12:26:23 +01:00

29 lines
712 B
Go

package arbo
import (
"math/big"
"testing"
)
func TestBigToFF(t *testing.T) {
baseField := BN254BaseField
iv := new(big.Int).Sub(baseField, big.NewInt(1))
// test with iv < baseField (the result should be iv)
z := BigToFF(baseField, iv)
if z.Cmp(iv) != 0 {
t.Fatalf("BigToFF failed: %v != %v", z, iv)
}
// test with iv > baseField (the result should be iv % baseField)
iv = new(big.Int).Add(baseField, big.NewInt(1))
z = BigToFF(baseField, iv)
if z.Cmp(big.NewInt(1)) != 0 {
t.Fatalf("BigToFF failed: %v != 0", z)
}
// test with iv == baseField (the result should be 0)
iv = baseField
z = BigToFF(baseField, iv)
if z.Cmp(big.NewInt(0)) != 0 {
t.Fatalf("BigToFF failed: %v != 0", z)
}
}