Skip to content

Commit 4c39d18

Browse files
committed
added num_constraints method to sdk
1 parent db791fc commit 4c39d18

File tree

1 file changed

+17
-0
lines changed
  • wasm/src/programs/verifying_key

1 file changed

+17
-0
lines changed

wasm/src/programs/verifying_key/mod.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,14 @@ impl VerifyingKey {
8383
pub fn to_string(&self) -> String {
8484
self.0.to_string()
8585
}
86+
87+
/// Get the number of constraints associated with the circuit
88+
///
89+
/// @returns {number} The number of constraints
90+
#[wasm_bindgen(js_name = "numConstraints")]
91+
pub fn num_constraints(&self) -> usize {
92+
self.0.circuit_info.num_constraints
93+
}
8694
}
8795

8896
impl Deref for VerifyingKey {
@@ -238,4 +246,13 @@ mod tests {
238246

239247
assert_eq!(transfer_public_verifying_key_checksum, checksum);
240248
}
249+
250+
#[wasm_bindgen_test]
251+
async fn test_num_constraints() {
252+
let transfer_public_verifier_bytes =
253+
crate::types::native::parameters::TransferPublicVerifier::load_bytes().unwrap();
254+
let transfer_public_verifier = VerifyingKey::from_bytes(&transfer_public_verifier_bytes).unwrap();
255+
let num_constraints = transfer_public_verifier.num_constraints();
256+
assert_eq!(num_constraints, 12326);
257+
}
241258
}

0 commit comments

Comments
 (0)