Skip to content

Instantly share code, notes, and snippets.

@3esmit 3esmit/phase1.zokrates
Last active Dec 6, 2018

Embed
What would you like to do?
import "LIBSNARK/sha256packed"
def hash(field[16] deck) -> (field[2]):
field res = 0
for field i in 0..16 do
res = res + deck[i] * (2**(4*i))
endfor
h0, h1 = sha256packed(0, 0, 0, res)
return [h0, h1]
def isInDeck(field i, field[16] deck) -> (field):
field res = 1
for field card in 0..16 do
res = res * (deck[card] - i)
endfor
return res
def isPermutation(field[16] deck) -> (field):
for field card in 0..16 do
0 == isInDeck(card, deck)
endfor
return 1
def main(private field[16] deck, field salt) -> (field[2]):
1 == isPermutation(deck)
return hash(deck, salt)
import "LIBSNARK/sha256packed"
def hash(field[16] deck) -> (field[2]):
field res = 0
for field i in 0..16 do
res = res + deck[i] * (2**(4*i))
endfor
h0, h1 = sha256packed(0, 0, 0, res)
return [h0, h1]
def main(private field[16] deck, field nullifier) -> (field[2]):
return hash(deck), nullifier
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.