Add test that breaks poseidion due to padding

This commit is contained in:
Eduard S
2019-12-16 17:24:22 +01:00
parent 27ec5b26df
commit 7c6170453e

View File

@@ -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))