Browse Source

Add test that breaks poseidion due to padding

fix/issue-9
Eduard S 5 years ago
parent
commit
7c6170453e
1 changed files with 9 additions and 1 deletions
  1. +9
    -1
      poseidon/poseidon_test.go

+ 9
- 1
poseidon/poseidon_test.go

@ -66,7 +66,7 @@ func TestPoseidon(t *testing.T) {
assert.Equal(t, "10747013384255785702102976082726575658403084163954725275481577373644732938016", hmsg2.String())
}
func TestPoseidonBroken(t *testing.T) {
func TestPoseidonBrokenChunks(t *testing.T) {
h1, err := Hash([]*big.Int{big.NewInt(0), big.NewInt(1), big.NewInt(2), big.NewInt(3), big.NewInt(4),
big.NewInt(5), big.NewInt(6), big.NewInt(7), big.NewInt(8), big.NewInt(9)})
assert.Nil(t, err)
@ -76,6 +76,14 @@ func TestPoseidonBroken(t *testing.T) {
assert.NotEqual(t, h1, h2)
}
func TestPoseidonBrokenPadding(t *testing.T) {
h1, err := Hash([]*big.Int{big.NewInt(1)})
assert.Nil(t, err)
h2, err := Hash([]*big.Int{big.NewInt(1), big.NewInt(0)})
assert.Nil(t, err)
assert.NotEqual(t, h1, h2)
}
func BenchmarkPoseidon(b *testing.B) {
b12 := big.NewInt(int64(12))
b45 := big.NewInt(int64(45))

Loading…
Cancel
Save