Przeglądaj źródła

proof: Fix examples for new halo2 API.

parazyd 4 lat temu
rodzic
commit
047ff319b6
2 zmienionych plików z 10 dodań i 9 usunięć
  1. 6 5
      proof/burn.rs
  2. 4 4
      proof/mint.rs

+ 6 - 5
proof/burn.rs

@@ -17,8 +17,8 @@ use halo2_gadgets::primitives::{
 use incrementalmerkletree::{bridgetree::BridgeTree, Frontier, Tree};
 use incrementalmerkletree::{bridgetree::BridgeTree, Frontier, Tree};
 use log::info;
 use log::info;
 use pasta_curves::{
 use pasta_curves::{
-    arithmetic::{CurveAffine, Field},
-    group::Curve,
+    arithmetic::CurveAffine,
+    group::{ff::Field, Curve},
     pallas,
     pallas,
 };
 };
 use rand::rngs::OsRng;
 use rand::rngs::OsRng;
@@ -56,7 +56,7 @@ fn main() -> Result<()> {
         let messages =
         let messages =
             [*coords.x(), *coords.y(), pallas::Base::from(value), token_id, serial, coin_blind];
             [*coords.x(), *coords.y(), pallas::Base::from(value), token_id, serial, coin_blind];
 
 
-        poseidon::Hash::init(P128Pow5T3, ConstantLength::<6>).hash(messages)
+        poseidon::Hash::<_, P128Pow5T3, ConstantLength<6>, 3, 2>::init().hash(messages)
     };
     };
 
 
     // Fill the merkle tree with some random coins that we want to witness,
     // Fill the merkle tree with some random coins that we want to witness,
@@ -93,7 +93,8 @@ fn main() -> Result<()> {
 
 
     // Create the public inputs
     // Create the public inputs
     let nullifier = [secret.0, serial];
     let nullifier = [secret.0, serial];
-    let nullifier = poseidon::Hash::init(P128Pow5T3, ConstantLength::<2>).hash(nullifier);
+    let nullifier =
+        poseidon::Hash::<_, P128Pow5T3, ConstantLength<2>, 3, 2>::init().hash(nullifier);
 
 
     let value_commit = pedersen_commitment_u64(value, value_blind);
     let value_commit = pedersen_commitment_u64(value, value_blind);
     let value_coords = value_commit.to_affine().coordinates().unwrap();
     let value_coords = value_commit.to_affine().coordinates().unwrap();
@@ -122,7 +123,7 @@ fn main() -> Result<()> {
 
 
     info!(target: "PROVER", "Building proving key and creating the zero-knowledge proof");
     info!(target: "PROVER", "Building proving key and creating the zero-knowledge proof");
     let proving_key = ProvingKey::build(11, &circuit);
     let proving_key = ProvingKey::build(11, &circuit);
-    let proof = Proof::create(&proving_key, &[circuit], &public_inputs)?;
+    let proof = Proof::create(&proving_key, &[circuit], &public_inputs, &mut OsRng)?;
 
 
     // ========
     // ========
     // Verifier
     // Verifier

+ 4 - 4
proof/mint.rs

@@ -15,8 +15,8 @@ use halo2_gadgets::primitives::{
 };
 };
 use log::info;
 use log::info;
 use pasta_curves::{
 use pasta_curves::{
-    arithmetic::{CurveAffine, Field},
-    group::Curve,
+    arithmetic::CurveAffine,
+    group::{ff::Field, Curve},
     pallas,
     pallas,
 };
 };
 use rand::rngs::OsRng;
 use rand::rngs::OsRng;
@@ -61,7 +61,7 @@ fn main() -> Result<()> {
 
 
     // Create the public inputs
     // Create the public inputs
     let msgs = [*coords.x(), *coords.y(), pallas::Base::from(value), token_id, serial, coin_blind];
     let msgs = [*coords.x(), *coords.y(), pallas::Base::from(value), token_id, serial, coin_blind];
-    let coin = poseidon::Hash::init(P128Pow5T3, ConstantLength::<6>).hash(msgs);
+    let coin = poseidon::Hash::<_, P128Pow5T3, ConstantLength<6>, 3, 2>::init().hash(msgs);
 
 
     let value_commit = pedersen_commitment_u64(value, value_blind);
     let value_commit = pedersen_commitment_u64(value, value_blind);
     let value_coords = value_commit.to_affine().coordinates().unwrap();
     let value_coords = value_commit.to_affine().coordinates().unwrap();
@@ -77,7 +77,7 @@ fn main() -> Result<()> {
 
 
     info!(target: "PROVER", "Building proving key and creating the zero-knowledge proof");
     info!(target: "PROVER", "Building proving key and creating the zero-knowledge proof");
     let proving_key = ProvingKey::build(11, &circuit);
     let proving_key = ProvingKey::build(11, &circuit);
-    let proof = Proof::create(&proving_key, &[circuit], &public_inputs)?;
+    let proof = Proof::create(&proving_key, &[circuit], &public_inputs, &mut OsRng)?;
 
 
     // ========
     // ========
     // Verifier
     // Verifier