瀏覽代碼

Update zkas proofs merkle root opcode.

Luther Blissett 3 年之前
父節點
當前提交
deaed0bdc8
共有 6 個文件被更改,包括 19 次插入16 次删除
  1. 12 9
      Makefile
  2. 1 1
      bin/daod/proof/dao-propose-burn.zk
  3. 1 1
      bin/daod/proof/dao-propose-main.zk
  4. 1 1
      bin/daod/proof/dao-vote-burn.zk
  5. 1 1
      proof/burn.zk
  6. 3 3
      proof/voting.zk

+ 12 - 9
Makefile

@@ -21,7 +21,17 @@ BINDEPS = \
 	$(shell find script/sql -type f) \
 	$(shell find contrib/token -type f)
 
-all: $(BINS)
+# ZK proofs to compile with zkas
+PROOFS = \
+	$(shell find bin/daod/proof -type f -name '*.zk') \
+	$(shell find proof -type f -name '*.zk')
+
+PROOFS_BIN = $(PROOFS:=.bin)
+
+all: $(PROOFS_BIN) $(BINS)
+
+$(PROOFS_BIN): zkas $(PROOFS)
+	./zkas $(basename $@) -o $@
 
 token_lists:
 	$(MAKE) -C contrib/token all
@@ -43,14 +53,7 @@ rustdoc: token_lists
 	RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) doc --release --workspace --all-features \
 		--no-deps --document-private-items
 
-# zkas source files which we want to compile for tests
-VM_SRC = proof/arithmetic.zk proof/mint.zk proof/burn.zk example/simple.zk
-VM_BIN = $(VM_SRC:=.bin)
-
-$(VM_BIN): zkas $(VM_SRC)
-	./zkas $(basename $@) -o $@
-
-test: token_lists $(VM_BIN) test-tx
+test: token_lists $(PROOFS_BIN) test-tx
 	RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) test --release --all-features --all
 
 test-tx:

+ 1 - 1
bin/daod/proof/dao-propose-burn.zk

@@ -46,7 +46,7 @@ circuit "DaoProposeInput" {
 	C = poseidon_hash(pub_x, pub_y, value, token, serial, spend_hook, user_data, coin_blind);
 
 	# Merkle root
-	root = calculate_merkle_root(leaf_pos, path, C);
+	root = merkle_root(leaf_pos, path, C);
 	constrain_instance(root);
 
 	# Finally, we derive a public key for the signature and

+ 1 - 1
bin/daod/proof/dao-propose-main.zk

@@ -47,7 +47,7 @@ circuit "DaoProposeMain" {
         # @tmp-workaround
         dao_bulla_blind,
     );
-	dao_root = calculate_merkle_root(dao_leaf_pos, dao_path, dao_bulla);
+	dao_root = merkle_root(dao_leaf_pos, dao_path, dao_bulla);
 	constrain_instance(dao_root);
     # Proves this DAO is valid
 

+ 1 - 1
bin/daod/proof/dao-vote-burn.zk

@@ -46,7 +46,7 @@ circuit "DaoVoteInput" {
 	C = poseidon_hash(pub_x, pub_y, value, gov_token_id, serial, spend_hook, user_data, coin_blind);
 
 	# Merkle root
-	root = calculate_merkle_root(leaf_pos, path, C);
+	root = merkle_root(leaf_pos, path, C);
 	constrain_instance(root);
 
 	# Finally, we derive a public key for the signature and

+ 1 - 1
proof/burn.zk

@@ -51,7 +51,7 @@ circuit "Burn" {
 	C = poseidon_hash(pub_x, pub_y, value, token, serial, coin_blind);
 
 	# Merkle root
-	root = calculate_merkle_root(leaf_pos, path, C);
+	root = merkle_root(leaf_pos, path, C);
 	constrain_instance(root);
 
 	# Finally, we derive a public key for the signature and

+ 3 - 3
proof/voting.zk

@@ -1,7 +1,7 @@
 constant "Vote" {
-	EcFixedPoint VALUE_COMMIT_VALUE,
+	EcFixedPointShort VALUE_COMMIT_VALUE,
 	EcFixedPoint VALUE_COMMIT_RANDOM,
-	EcFixedPoint NULLIFIER_K,
+	EcFixedPointBase NULLIFIER_K,
 }
 
 contract "Vote" {
@@ -27,7 +27,7 @@ circuit "Vote" {
 	pk_hash = poseidon_hash(public_x, public_y);
 
 	# Merkle root
-	root = calculate_merkle_root(leaf_pos, path, pk_hash);
+	root = merkle_root(leaf_pos, path, pk_hash);
 	constrain_instance(root);
 
 	# Pedersen commitment for vote