1
0
Fork 0
mirror of synced 2025-09-23 12:18:44 +00:00
ZoKrates/zokrates_cli/examples/merkleTree/pedersenPathProof3.zok
2020-07-13 09:20:27 +02:00

26 lines
1 KiB
Text

import "hashes/pedersen/512bit" as hash
import "ecc/edwardsCompress" as edwardsCompress
import "ecc/babyjubjubParams" as context
from "ecc/babyjubjubParams" import BabyJubJubParams
import "hashes/utils/256bitsDirectionHelper" as multiplex
// Merke-Tree inclusion proof for tree depth 3 using SNARK efficient pedersen hashes
// directionSelector=> 1/true if current digest is on the rhs of the hash
def main(bool[256] rootDigest, private bool[256] leafDigest, private bool[3] directionSelector, bool[256] PathDigest0, private bool[256] PathDigest1, private bool[256] PathDigest2) -> (bool):
BabyJubJubParams context = context()
//Setup
bool[256] currentDigest = leafDigest
//Loop up the tree
bool[512] preimage = multiplex(directionSelector[0], currentDigest, PathDigest0)
currentDigest = hash(preimage)
preimage = multiplex(directionSelector[1], currentDigest, PathDigest1)
currentDigest = hash(preimage)
preimage = multiplex(directionSelector[2], currentDigest, PathDigest2)
currentDigest = hash(preimage)
return rootDigest == currentDigest