Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
223880 committed Sep 27, 2024
1 parent d21ce86 commit 2233edb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions zk_coinjoin_lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ pub mod utils; // Module for Coinjoin transaction logic
use crate::proof::{generate_proof, verify_proof, ZKProof};

// Public function to create a Coinjoin transaction with ZK proofs
pub fn create_coinjoin_transaction(/* parameters */) -> Result<(CoinjoinTransaction, ZKProof), String> {
pub fn create_coinjoin_transaction(/* parameters */) -> Result<(transaction::CoinjoinTransaction, ZKProof), String> {
// Create the Coinjoin transaction
let transaction = CoinjoinTransaction::new(/* parameters */);
let transaction = transaction::CoinjoinTransaction::new(/* parameters */);

// Generate the ZK proof
let proof = generate_proof(/* parameters */)
Expand Down
8 changes: 4 additions & 4 deletions zk_coinjoin_lib/src/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,20 @@ pub fn generate_proof<E: Engine>(
public_inputs,
})
}
pub fn verify_proof<E: Engine>(
pub fn verify_zk_proof<E: Engine>(
zk_proof: &ZKProof<E>,
vk: &PreparedVerifyingKey<E>
) -> Result<bool, Box<dyn Error>> {
// Convert public inputs from Vec<Vec<u8>> to the format expected by the `bellman::verify_proof`
// Convert public inputs from Vec<Vec<u8>> to the format expected by the `bellman::groth16::verify_proof`
let public_inputs: Vec<E::Fr> = zk_proof
.public_inputs
.iter()
.map(|input| {
// Convert Vec<u8> to Fr (the field element type)
E::Fr::from_repr(bellman::pairing::ff::PrimeFieldRepr::from(input.as_slice()))
E::Fr::from_repr(E::Fr::Repr::from(input.as_slice()))
})
.collect::<Result<Vec<_>, _>>()?;

// Verify the proof
Ok(verify_proof(vk, &zk_proof.proof, &public_inputs)?)
Ok(bellman::groth16::verify_proof(vk, &zk_proof.proof, &public_inputs)?)
}

0 comments on commit 2233edb

Please sign in to comment.