mirror of
https://github.com/arnaucube/hermez-node.git
synced 2026-02-07 11:26:44 +01:00
Add initial structure of BatchBuilder
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"math/big"
|
||||
|
||||
eth "github.com/ethereum/go-ethereum/common"
|
||||
"github.com/iden3/go-iden3-crypto/poseidon"
|
||||
cryptoUtils "github.com/iden3/go-iden3-crypto/utils"
|
||||
)
|
||||
|
||||
@@ -65,6 +66,16 @@ func (l *Leaf) BigInts() ([5]*big.Int, error) {
|
||||
return e, nil
|
||||
}
|
||||
|
||||
// Value returns the value of the Leaf, which is the Poseidon hash of its *big.Int representation
|
||||
func (l *Leaf) Value() (*big.Int, error) {
|
||||
toHash := [poseidon.T]*big.Int{}
|
||||
lBI := l.BigInts()
|
||||
copy(toHash[:], lBI[:])
|
||||
|
||||
v, err := poseidon.Hash(toHash)
|
||||
return v, err
|
||||
}
|
||||
|
||||
// LeafFromBigInts returns a Leaf from a [5]*big.Int
|
||||
func LeafFromBigInts(e [5]*big.Int) (*Leaf, error) {
|
||||
if !cryptoUtils.CheckBigIntArrayInField(e[:]) {
|
||||
|
||||
Reference in New Issue
Block a user