arnaucube 3d074f3195 Upgrade Pebble version & go mod tidy
To include the last changes of Pebble that fixes the cgo issues, from:
c2b05f12d7
2021-01-05 10:57:43 +01:00
2020-12-18 11:56:07 +01:00
2020-12-18 11:56:07 +01:00
2021-01-05 10:57:43 +01:00
2021-01-05 10:57:43 +01:00
2020-08-29 18:11:52 +02:00
2020-07-23 22:27:38 +02:00

go-merkletree GoDoc Go Report Card Test

MerkleTree compatible with version from circomlib.

Adaptation of the merkletree from https://github.com/iden3/go-iden3-core/tree/v0.0.8 with several changes and more functionalities.

Usage

More detailed examples can be found at the tests, and in the documentation.

import (
	"fmt"
	"math/big"
	"testing"

	"github.com/iden3/go-iden3-core/db"
	"github.com/stretchr/testify/assert"
)

[...]

func TestExampleMerkleTree(t *testing.T) {
	mt, err := NewMerkleTree(db.NewMemoryStorage(), 10)
	assert.Nil(t, err)

	key := big.NewInt(1)
	value := big.NewInt(2)
	err = mt.Add(key, value)
	assert.Nil(t, err)
	fmt.Println(mt.Root().String())

	v, err := mt.Get(key)
	asseert.Equal(t, value, v)

	value = big.NewInt(3)
	err = mt.Update(key, value)

	proof, err := mt.GenerateProof(key, nil)
	assert.Nil(t, err)

	assert.True(t, VerifyProof(mt.Root(), proof, key, value))

	err := mt.Delete(big.NewInt(1)) // delete the leaf of key=1
	assert.Nil(t, err)
}
Description
No description provided
Readme GPL-3.0 207 KiB
Languages
Go 100%