You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
824 B

5 years ago
  1. package poseidon
  2. import (
  3. "encoding/hex"
  4. "math/big"
  5. "testing"
  6. "github.com/stretchr/testify/assert"
  7. "golang.org/x/crypto/blake2b"
  8. )
  9. func TestBlake2bVersion(t *testing.T) {
  10. h := blake2b.Sum256([]byte("poseidon_constants"))
  11. assert.Equal(t, "e57ba154fb2c47811dc1a2369b27e25a44915b4e4ece4eb8ec74850cb78e01b1", hex.EncodeToString(h[:]))
  12. }
  13. func TestPoseidon(t *testing.T) {
  14. b1 := big.NewInt(int64(1))
  15. b2 := big.NewInt(int64(2))
  16. h, err := Hash([]*big.Int{b1, b2})
  17. assert.Nil(t, err)
  18. assert.Equal(t, "12242166908188651009877250812424843524687801523336557272219921456462821518061", h.String())
  19. b3 := big.NewInt(int64(3))
  20. b4 := big.NewInt(int64(4))
  21. h, err = Hash([]*big.Int{b3, b4})
  22. assert.Nil(t, err)
  23. assert.Equal(t, "17185195740979599334254027721507328033796809509313949281114643312710535000993", h.String())
  24. }