Skip to content

Commit

Permalink
Merge pull request #26 from vocdoni/feature/addbatch-bigtrees-indisk
Browse files Browse the repository at this point in the history
Feature/addbatch bigtrees indisk
  • Loading branch information
arnaucube authored Dec 17, 2021
2 parents 17bf867 + e809403 commit 96ccfdb
Show file tree
Hide file tree
Showing 11 changed files with 941 additions and 172 deletions.
371 changes: 287 additions & 84 deletions addbatch_test.go

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions circomproofs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ import (
"testing"

qt "github.com/frankban/quicktest"
"go.vocdoni.io/dvote/db"
"go.vocdoni.io/dvote/db/badgerdb"
)

func TestCircomVerifierProof(t *testing.T) {
c := qt.New(t)
database, err := badgerdb.New(badgerdb.Options{Path: c.TempDir()})
database, err := badgerdb.New(db.Options{Path: c.TempDir()})
c.Assert(err, qt.IsNil)
tree, err := NewTree(database, 4, HashFunctionPoseidon)
tree, err := NewTree(Config{Database: database, MaxLevels: 4,
HashFunction: HashFunctionPoseidon})
c.Assert(err, qt.IsNil)
defer tree.db.Close() //nolint:errcheck

Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ go 1.16
require (
github.com/frankban/quicktest v1.13.0
github.com/iden3/go-iden3-crypto v0.0.6-0.20210308142348-8f85683b2cef
go.vocdoni.io/dvote v1.0.4-0.20210806163627-9494efbc5382
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97
go.vocdoni.io/dvote v1.0.4-0.20211025120558-83c64f440044
golang.org/x/crypto v0.0.0-20210920023735-84f357641f63
)
293 changes: 288 additions & 5 deletions go.sum

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ func (f HashPoseidon) Len() int {
return 32 //nolint:gomnd
}

// Hash implements the hash method for the HashFunction HashPoseidon
// Hash implements the hash method for the HashFunction HashPoseidon. It
// expects the byte arrays to be little-endian representations of big.Int
// values.
func (f HashPoseidon) Hash(b ...[]byte) ([]byte, error) {
var toHash []*big.Int
for i := 0; i < len(b); i++ {
Expand Down
11 changes: 7 additions & 4 deletions helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"time"

qt "github.com/frankban/quicktest"
"go.vocdoni.io/dvote/db"
"go.vocdoni.io/dvote/db/badgerdb"
)

Expand Down Expand Up @@ -87,14 +88,16 @@ func TestReadTreeDBG(t *testing.T) {

c := qt.New(t)

database1, err := badgerdb.New(badgerdb.Options{Path: c.TempDir()})
database1, err := badgerdb.New(db.Options{Path: c.TempDir()})
c.Assert(err, qt.IsNil)
tree1, err := NewTree(database1, 100, HashFunctionBlake2b)
tree1, err := NewTree(Config{Database: database1, MaxLevels: 100,
HashFunction: HashFunctionBlake2b})
c.Assert(err, qt.IsNil)

database2, err := badgerdb.New(badgerdb.Options{Path: c.TempDir()})
database2, err := badgerdb.New(db.Options{Path: c.TempDir()})
c.Assert(err, qt.IsNil)
tree2, err := NewTree(database2, 100, HashFunctionBlake2b)
tree2, err := NewTree(Config{Database: database2, MaxLevels: 100,
HashFunction: HashFunctionBlake2b})
c.Assert(err, qt.IsNil)

// tree1 is generated by a loop of .Add
Expand Down
6 changes: 4 additions & 2 deletions testvectors/circom/go-data-generator/generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@ import (

qt "github.com/frankban/quicktest"
"github.com/vocdoni/arbo"
"go.vocdoni.io/dvote/db"
"go.vocdoni.io/dvote/db/badgerdb"
)

func TestGenerator(t *testing.T) {
c := qt.New(t)
database, err := badgerdb.New(badgerdb.Options{Path: c.TempDir()})
database, err := badgerdb.New(db.Options{Path: c.TempDir()})
c.Assert(err, qt.IsNil)
tree, err := arbo.NewTree(database, 4, arbo.HashFunctionPoseidon)
tree, err := arbo.NewTree(arbo.Config{Database: database, MaxLevels: 4,
HashFunction: arbo.HashFunctionPoseidon})
c.Assert(err, qt.IsNil)

testVector := [][]int64{
Expand Down
Loading

0 comments on commit 96ccfdb

Please sign in to comment.