mirror of
https://github.com/waku-org/go-zerokit-rln.git
synced 2025-03-01 04:30:33 +00:00
22 lines
604 B
Go
22 lines
604 B
Go
package rln
|
|
|
|
import (
|
|
"bytes"
|
|
"math/big"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestBigInt(t *testing.T) {
|
|
base := big.NewInt(2)
|
|
value := base.Exp(base, big.NewInt(248), nil)
|
|
value = value.Sub(value, big.NewInt(1)) // 2^248 - 1
|
|
|
|
b32Value := BigIntToBytes32(value)
|
|
require.True(t, bytes.Equal(b32Value[:], []byte{255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0}))
|
|
|
|
newValue := Bytes32ToBigInt(b32Value)
|
|
require.True(t, bytes.Equal(newValue.Bytes(), value.Bytes()))
|
|
}
|