Last active
December 6, 2018 07:20
Star
You must be signed in to star a gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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