arnau adf72a1f9c Merge pull request #2 from iden3/GraphViz
Correction to the GraphViz function when drawing empty nodes
2020-07-03 21:21:21 +02:00
2020-06-30 22:54:14 +02:00
2020-07-01 17:41:41 +02:00
2020-06-30 20:12:17 +02:00
2020-06-30 22:46:47 +02:00
2020-07-01 17:41:41 +02:00
2020-06-30 22:46:47 +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

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

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

	assert.True(t, VerifyProof(mt.Root(), proof, key, value))
}
Description
No description provided
Readme GPL-3.0 208 KiB
Languages
Go 100%