mirror of
https://github.com/arnaucube/go-iden3-crypto.git
synced 2026-02-07 11:36:41 +01:00
add Poseidon
This commit is contained in:
29
poseidon/poseidon_test.go
Normal file
29
poseidon/poseidon_test.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package poseidon
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"math/big"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"golang.org/x/crypto/blake2b"
|
||||
)
|
||||
|
||||
func TestBlake2bVersion(t *testing.T) {
|
||||
h := blake2b.Sum256([]byte("poseidon_constants"))
|
||||
assert.Equal(t, "e57ba154fb2c47811dc1a2369b27e25a44915b4e4ece4eb8ec74850cb78e01b1", hex.EncodeToString(h[:]))
|
||||
}
|
||||
|
||||
func TestPoseidon(t *testing.T) {
|
||||
b1 := big.NewInt(int64(1))
|
||||
b2 := big.NewInt(int64(2))
|
||||
h, err := Hash([]*big.Int{b1, b2})
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, "12242166908188651009877250812424843524687801523336557272219921456462821518061", h.String())
|
||||
|
||||
b3 := big.NewInt(int64(3))
|
||||
b4 := big.NewInt(int64(4))
|
||||
h, err = Hash([]*big.Int{b3, b4})
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, "17185195740979599334254027721507328033796809509313949281114643312710535000993", h.String())
|
||||
}
|
||||
Reference in New Issue
Block a user