From e1728c257d8596893c71fe11be94bed082e60c59 Mon Sep 17 00:00:00 2001 From: arnaucube Date: Mon, 8 Apr 2024 15:42:52 +0200 Subject: [PATCH] add checks modifying z_0 & z_i to nova_cyclefold_solidity_verifier test --- .../src/verifiers/nova_cyclefold.rs | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/solidity-verifiers/src/verifiers/nova_cyclefold.rs b/solidity-verifiers/src/verifiers/nova_cyclefold.rs index daf8bef4..36033d02 100644 --- a/solidity-verifiers/src/verifiers/nova_cyclefold.rs +++ b/solidity-verifiers/src/verifiers/nova_cyclefold.rs @@ -314,7 +314,7 @@ mod tests { let function_selector = get_function_selector_for_nova_cyclefold_verifier(nova.z_0.len() * 2 + 1); - let mut calldata: Vec = prepare_calldata( + let calldata: Vec = prepare_calldata( function_selector, nova.i, nova.z_0, @@ -335,15 +335,23 @@ mod tests { let (_, output) = evm.call(verifier_address, calldata.clone()); assert_eq!(*output.last().unwrap(), 1); - // change i to make calldata invalid - // first 4 bytes are the function signature + 32 bytes for i --> change byte at index 35 - let prev_call_data_i = calldata[35]; - calldata[35] = 0; - let (_, output) = evm.call(verifier_address, calldata.clone()); + // change i to make calldata invalid, placed between bytes 4 - 35 + let mut invalid_calldata = calldata.clone(); + invalid_calldata[35] += 1; + let (_, output) = evm.call(verifier_address, invalid_calldata.clone()); + assert_eq!(*output.last().unwrap(), 0); + + // change z_0 to make the EVM check fail, placed between bytes 35 - 67 + let mut invalid_calldata = calldata.clone(); + invalid_calldata[67] += 1; + let (_, output) = evm.call(verifier_address, invalid_calldata.clone()); assert_eq!(*output.last().unwrap(), 0); - calldata[35] = prev_call_data_i; - // TODO: change z_0 to make the EVM check fail + // change z_i to make the EVM check fail, placed between bytes 68 - 100 + let mut invalid_calldata = calldata.clone(); + invalid_calldata[99] += 1; + let (_, output) = evm.call(verifier_address, invalid_calldata.clone()); + assert_eq!(*output.last().unwrap(), 0); } #[test]