You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, the mock prover correctly generates an empty SP1ProofWithPublicValues, as intended (reference here). In typical usage, the .bytes() method (see reference) is used to convert the proof into a byte format that the on-chain verifier can accept. This method works seamlessly with the network prover.
However, when using the mock prover, the mock verification fails if the output of the .bytes() method is directly fed into the mock SP1 verifier. This is because:
The MockSP1Verifier.sol expects proof bytes of length 0 (see here).
The .bytes() method appends the plonk_vkey_hash to the proof (see here). The mock value of plonk_vkey_hash is defined here.
This discrepancy requires users to handle mock proofs and standard SP1 proofs differently before submitting them to their respective verifiers. To improve the user experience, it would be beneficial if the proof generated by the .bytes() method could be accepted directly by the mock verifier.
Proposal:
I propose modifying the .bytes() method instead of altering MockSP1Verifier.sol. Below is the proposed modification:
/// For Plonk proofs, returns the proof in a byte encoding the onchain verifier accepts.
/// The bytes consist of the first four bytes of Plonk vkey hash followed by the encoded proof.
pub fn bytes(&self) -> Vec<u8> {
match &self.proof {
SP1Proof::Plonk(plonk_proof) => {
+ if plonk_proof.encoded_proof.is_empty() {+ return Vec::new();+ }+
let mut bytes = Vec::with_capacity(4 + plonk_proof.encoded_proof.len());
bytes.extend_from_slice(&plonk_proof.plonk_vkey_hash[..4]);
bytes.extend_from_slice(
&hex::decode(&plonk_proof.encoded_proof).expect("Invalid Plonk proof"),
);
bytes
}
_ => unimplemented!("only Plonk proofs are verifiable onchain"),
}
}
}
If there is agreement on this solution, I would be happy to open a pull request to implement this change.
The text was updated successfully, but these errors were encountered:
Description
Currently, the mock prover correctly generates an empty
SP1ProofWithPublicValues
, as intended (reference here). In typical usage, the.bytes()
method (see reference) is used to convert the proof into a byte format that the on-chain verifier can accept. This method works seamlessly with the network prover.However, when using the mock prover, the mock verification fails if the output of the
.bytes()
method is directly fed into the mock SP1 verifier. This is because:MockSP1Verifier.sol
expects proof bytes of length 0 (see here)..bytes()
method appends theplonk_vkey_hash
to the proof (see here). The mock value ofplonk_vkey_hash
is defined here.This discrepancy requires users to handle mock proofs and standard SP1 proofs differently before submitting them to their respective verifiers. To improve the user experience, it would be beneficial if the proof generated by the
.bytes()
method could be accepted directly by the mock verifier.Proposal:
I propose modifying the
.bytes()
method instead of alteringMockSP1Verifier.sol
. Below is the proposed modification:If there is agreement on this solution, I would be happy to open a pull request to implement this change.
The text was updated successfully, but these errors were encountered: