Skip to content

Commit

Permalink
tree/smt Processor now uses poseidon.MultiHash
Browse files Browse the repository at this point in the history
  • Loading branch information
altergui committed Dec 10, 2024
1 parent 421cc1e commit 220afbf
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions tree/smt/hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,25 @@ package smt
import (
"github.com/consensys/gnark/frontend"

"github.com/mdehoog/poseidon/circuits/poseidon"
"github.com/vocdoni/gnark-crypto-primitives/hash/bn254/poseidon"
)

// based on https://github.com/iden3/circomlib/blob/master/circuits/smt/smthash_poseidon.circom

func Hash1(api frontend.API, key, value frontend.Variable) frontend.Variable {
inputs := []frontend.Variable{key, value, 1}
return poseidon.Hash(api, inputs)
hash, err := poseidon.MultiHash(api, inputs...)
if err != nil {
panic(err)
}
return hash
}

func Hash2(api frontend.API, l, r frontend.Variable) frontend.Variable {
inputs := []frontend.Variable{l, r}
return poseidon.Hash(api, inputs)
hash, err := poseidon.MultiHash(api, inputs...)
if err != nil {
panic(err)
}
return hash
}

0 comments on commit 220afbf

Please sign in to comment.