1
0
mirror of https://github.com/fluencelabs/lazy-snark synced 2025-06-29 14:41:51 +00:00

add zkp for "sum four numbers is equal"

This commit is contained in:
Drygin Alexander
2019-06-22 17:28:43 +03:00
parent 401dbe8681
commit 4180410d96
8 changed files with 224411 additions and 0 deletions

18
backend_zk/root.code Normal file

@ -0,0 +1,18 @@
import "hashes/sha256/512bitPacked.code" as sha256packed
def main(private field[4] n_old, private field[4] n_new, field[2] hash_old, field[2] hash_new) -> (field):
//check sum
n_old[0] + n_old[1] + n_old[2] + n_old[3] == n_new[0] + n_new[1] + n_new[2] + n_new[3]
// check old hash
h_old = sha256packed([n_old[0], n_old[1], n_old[2], n_old[3]])
h_old[0] == hash_old[0]
h_old[1] == hash_old[1]
// check new hash
h_new = sha256packed([n_new[0], n_new[1], n_new[2], n_new[3]])
h_new[0] == hash_new[0]
h_new[1] == hash_new[1]
return 1