Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion circuits/prover/src/pool/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,10 @@ mod end_to_end {
"sig_s": sig_s,
"anchor_pk_x": fr_hex(&anchor.pk.x),
"anchor_pk_y": fr_hex(&anchor.pk.y),
// Explicit rather than relying on serde's default: this test exists to prove a phone's
// proof is accepted on-chain, and the contract supplies this value itself. Letting the
// default fill it would still pass while testing a different statement.
"min_kyc_level": credential::MIN_KYC_LEVEL,
"current_time": 1_700_000_000u64,
})
.to_string();
Expand Down Expand Up @@ -712,8 +716,10 @@ mod end_to_end {
fr_from_hex(result["enc1_rho"].as_str().unwrap()).unwrap(),
fr_from_hex(result["enc2_amount"].as_str().unwrap()).unwrap(),
fr_from_hex(result["enc2_rho"].as_str().unwrap()).unwrap(),
// Appended last, matching the circuit's allocation order and the contract's IC layout.
Fr::from(credential::MIN_KYC_LEVEL),
];
assert_eq!(public.len(), 15, "spend has 15 public inputs");
assert_eq!(public.len(), 16, "spend has 16 public inputs");

// The blob above is in Soroban's encoding, which the contract parses. Verifying here uses
// the arkworks form of the same statement, rebuilt from the identical witness.
Expand Down Expand Up @@ -771,6 +777,7 @@ mod end_to_end {
&cred,
point(&arg.anchor_pk_x, &arg.anchor_pk_y).unwrap(),
arg.current_time,
arg.min_kyc_level,
);
Groth16::<Bls12_381>::prove(spend_key(), circuit, &mut OsRng).unwrap()
}
Expand Down
3 changes: 2 additions & 1 deletion circuits/prover/src/pool/spend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,8 @@ impl ConstraintSynthesizer<Fr> for SpendCircuit {
// every proof fails verification with nothing to indicate why.
let min_kyc_level = FpVar::new_input(cs.clone(), || {
Ok(Fr::from(
self.min_kyc_level.ok_or(SynthesisError::AssignmentMissing)?,
self.min_kyc_level
.ok_or(SynthesisError::AssignmentMissing)?,
))
})?;

Expand Down
13 changes: 10 additions & 3 deletions circuits/prover/tests/pool_circuits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,16 @@ fn report_circuit_sizes() {
("shield", {
let cs = ConstraintSystem::<Fr>::new_ref();
let s = Scenario::new(71, 1000);
ShieldCircuit::new(s.cfg.clone(), 1000, s.owner_pk, s.rho, s.enc.pk, JubjubFr::from(7u64))
.generate_constraints(cs.clone())
.unwrap();
ShieldCircuit::new(
s.cfg.clone(),
1000,
s.owner_pk,
s.rho,
s.enc.pk,
JubjubFr::from(7u64),
)
.generate_constraints(cs.clone())
.unwrap();
cs
}),
] {
Expand Down
8 changes: 7 additions & 1 deletion contracts/pool/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,13 @@ fn initialize_is_one_shot() {
let z = BytesN::from_array(&f.env, &[0u8; 32]);
let err = f
.pool
.try_initialize(&f.admin, &f.pool.address, &z, &z, &crate::DEFAULT_MIN_KYC_LEVEL)
.try_initialize(
&f.admin,
&f.pool.address,
&z,
&z,
&crate::DEFAULT_MIN_KYC_LEVEL,
)
.expect_err("re-initialising would let the token or anchor be swapped");
assert_eq!(err, Ok(Error::AlreadyInitialized));
}
Expand Down
Loading