Ver Fonte

hide the coin... we don't reveal that

narodnik há 5 anos atrás
pai
commit
1776f87d59
2 ficheiros alterados com 12 adições e 9 exclusões
  1. 3 2
      proofs/spend.pism
  2. 9 7
      src/spend.rs

+ 3 - 2
proofs/spend.pism

@@ -98,8 +98,9 @@ start
     # TOTAL: 832 bits for preimage
     # TOTAL: 832 bits for preimage
     static_assert_binary_size preimage 832
     static_assert_binary_size preimage 832
     blake2s coin preimage CRH_IVK
     blake2s coin preimage CRH_IVK
-    binary_clone coin2 coin
-    emit_binary coin2
+    # Debug stuff. Normally we don't reveal the coin in the spend proof.
+    #binary_clone coin2 coin
+    #emit_binary coin2
 
 
     # coin_commit = PedersenHash(coin)
     # coin_commit = PedersenHash(coin)
     pedersen_hash cm coin NOTE_COMMIT
     pedersen_hash cm coin NOTE_COMMIT

+ 9 - 7
src/spend.rs

@@ -45,7 +45,8 @@ pub fn merkle_hash(depth: usize, lhs: &bls12_381::Scalar, rhs: &bls12_381::Scala
 struct SpendRevealedValues {
 struct SpendRevealedValues {
     value_commit: jubjub::SubgroupPoint,
     value_commit: jubjub::SubgroupPoint,
     nullifier: [u8; 32],
     nullifier: [u8; 32],
-    coin: [u8; 32],
+    // This should not be here, we just have it for debugging
+    //coin: [u8; 32],
     merkle_root: bls12_381::Scalar,
     merkle_root: bls12_381::Scalar,
 }
 }
 
 
@@ -106,11 +107,11 @@ impl SpendRevealedValues {
             }
             }
         }
         }
 
 
-        SpendRevealedValues { value_commit, nullifier, coin, merkle_root }
+        SpendRevealedValues { value_commit, nullifier, merkle_root }
     }
     }
 
 
-    fn make_outputs(&self) -> [bls12_381::Scalar; 7] {
-        let mut public_input = [bls12_381::Scalar::zero(); 7];
+    fn make_outputs(&self) -> [bls12_381::Scalar; 5] {
+        let mut public_input = [bls12_381::Scalar::zero(); 5];
 
 
         // CV
         // CV
         {
         {
@@ -136,8 +137,9 @@ impl SpendRevealedValues {
             public_input[3] = hash[1];
             public_input[3] = hash[1];
         }
         }
 
 
+        // Not revealed. We leave this code here for debug
         // Coin
         // Coin
-        {
+        /*{
             // Pack the hash as inputs for proof verification.
             // Pack the hash as inputs for proof verification.
             let hash = multipack::bytes_to_bits_le(&self.coin);
             let hash = multipack::bytes_to_bits_le(&self.coin);
             let hash = multipack::compute_multipacking(&hash);
             let hash = multipack::compute_multipacking(&hash);
@@ -147,9 +149,9 @@ impl SpendRevealedValues {
 
 
             public_input[4] = hash[0];
             public_input[4] = hash[0];
             public_input[5] = hash[1];
             public_input[5] = hash[1];
-        }
+        }*/
 
 
-        public_input[6] = self.merkle_root;
+        public_input[4] = self.merkle_root;
 
 
         public_input
         public_input
     }
     }