Add proof generation

This commit is contained in:
2021-03-31 20:04:30 +02:00
parent 43cb6041c9
commit 8c63b5d192
2 changed files with 97 additions and 19 deletions

View File

@@ -145,6 +145,24 @@ func TestAux(t *testing.T) {
assert.Nil(t, err)
}
func TestGenProof(t *testing.T) {
tree, err := NewTree(memory.NewMemoryStorage(), 100, HashFunctionPoseidon)
require.Nil(t, err)
defer tree.db.Close()
for i := 0; i < 10; i++ {
k := BigIntToBytes(big.NewInt(int64(i)))
v := BigIntToBytes(big.NewInt(int64(i * 2)))
if err := tree.Add(k, v); err != nil {
t.Fatal(err)
}
}
k := BigIntToBytes(big.NewInt(int64(7)))
_, err = tree.GenProof(k)
assert.Nil(t, err)
}
func BenchmarkAdd(b *testing.B) {
// prepare inputs
var ks, vs [][]byte