Skip to content

Commit

Permalink
shielded-pool: λ collect field elements
Browse files Browse the repository at this point in the history
  • Loading branch information
cratelyn committed Feb 15, 2024
1 parent 456d343 commit d829638
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions crates/core/component/shielded-pool/src/spend/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,25 +341,25 @@ impl SpendProof {
.vartime_decompress()
.map_err(VerificationError::DecompressRk)?;

let mut public_inputs = Vec::new();
public_inputs.extend([Fq::from(anchor)]);
public_inputs.extend(
balance_commitment
.to_field_elements()
.ok_or(VerificationError::BalanceCommitment)?,
);
public_inputs.extend(
nullifier
.to_field_elements()
.ok_or(VerificationError::Nullifier)?,
);
public_inputs.extend(
element_rk
.to_field_elements()
.ok_or(VerificationError::Rk)?,
);

tracing::trace!(?public_inputs);
/// Shorthand helper, convert expressions into field elements.
macro_rules! to_field_elements {
($fe:expr, $err:expr) => {
$fe.to_field_elements().ok_or($err)?
};
}

use VerificationError::*;
let public_inputs = [
to_field_elements!(Fq::from(anchor), Anchor),
to_field_elements!(balance_commitment, BalanceCommitment),
to_field_elements!(nullifier, Nullifier),
to_field_elements!(element_rk, Rk),
]
.into_iter()
.flatten()
.collect::<Vec<_>>()
.tap(|public_inputs| tracing::trace!(?public_inputs));

let start = std::time::Instant::now();
Groth16::<Bls12_377, LibsnarkReduction>::verify_with_processed_vk(
vk,
Expand Down

0 comments on commit d829638

Please sign in to comment.