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

32 lines
1.3 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
<<<<<<< HEAD
def main(u32[8] rootDigest, private u32[8] leafDigest, private bool[3] directionSelector, u32[8] PathDigest0, private u32[8] PathDigest1, private u32[8] PathDigest2) -> (field):
=======
def main(bool[256] rootDigest, private bool[256] leafDigest, private bool[3] directionSelector, bool[256] PathDigest0, private bool[256] PathDigest1, private bool[256] PathDigest2) -> ():
>>>>>>> 26f4d72ee6e0c802823cf145fbd11a372586eb28
BabyJubJubParams context = context()
//Setup
u32[8] currentDigest = leafDigest
//Loop up the tree
u32[16] 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)
assert(rootDigest == currentDigest)
return