@@ -9,23 +9,23 @@ type MemoryPointer is uint256;
99/// @notice This contract provides a thin wrapper around the Halo2 verifier
1010/// outputted by `snark-verifier`, exposing a more user-friendly interface.
1111contract OpenVmHalo2Verifier is Halo2Verifier , IOpenVmHalo2Verifier {
12- /// @dev Invalid partial proof length
13- error InvalidPartialProofLength ();
12+ /// @dev Invalid proof data length
13+ error InvalidProofDataLength ();
1414
15- /// @dev Invalid guest PVs length
16- error InvalidGuestPvsLength ();
15+ /// @dev Invalid public values length
16+ error InvalidPublicValuesLength ();
1717
1818 /// @dev Proof verification failed
1919 error ProofVerificationFailed ();
2020
21- /// @dev The length of the partial proof, in bytes
22- uint256 private constant PARTIAL_PROOF_LENGTH = (12 + 43 ) * 32 ;
21+ /// @dev The length of the proof data , in bytes
22+ uint256 private constant PROOF_DATA_LENGTH = (12 + 43 ) * 32 ;
2323
24- /// @dev The length of the guest PVs , in bytes. This value is set by OpenVM.
25- uint256 private constant GUEST_PVS_LENGTH = 32 ;
24+ /// @dev The length of the public values , in bytes. This value is set by OpenVM.
25+ uint256 private constant PUBLIC_VALUES_LENGTH = 32 ;
2626
2727 /// @dev The length of the full proof, in bytes
28- uint256 private constant FULL_PROOF_LENGTH = (12 + 2 + GUEST_PVS_LENGTH + 43 ) * 32 ;
28+ uint256 private constant FULL_PROOF_LENGTH = (12 + 2 + PUBLIC_VALUES_LENGTH + 43 ) * 32 ;
2929
3030 /// @dev The leaf verifier commitment. This value is set by OpenVM.
3131 bytes32 public constant LEAF_EXE_COMMIT =
@@ -37,25 +37,25 @@ contract OpenVmHalo2Verifier is Halo2Verifier, IOpenVmHalo2Verifier {
3737 /// @notice A wrapper that constructs the proof into the right format for
3838 /// use with the `snark-verifier` verification.
3939 ///
40- /// @dev This function assumes that `guestPvs ` encodes one `bytes32`
40+ /// @dev This function assumes that `publicValues ` encodes one `bytes32`
4141 /// hash which is the hash of the public values.
4242 ///
4343 /// The verifier expected proof format is:
4444 /// proof[..12 * 32]: KZG accumulators
4545 /// proof[12 * 32..13 * 32]: app exe commit
4646 /// proof[13 * 32..14 * 32]: leaf exe commit
47- /// proof[14 * 32..(14 + GUEST_PVS_LENGTH ) * 32]: guestPvs [0..GUEST_PVS_LENGTH ]
48- /// proof[(14 + GUEST_PVS_LENGTH ) * 32..]: Guest PVs Suffix
47+ /// proof[14 * 32..(14 + PUBLIC_VALUES_LENGTH ) * 32]: publicValues [0..PUBLIC_VALUES_LENGTH ]
48+ /// proof[(14 + PUBLIC_VALUES_LENGTH ) * 32..]: Public Values Suffix
4949 ///
5050 /// @param publicValues The PVs revealed by the OpenVM guest program.
51- /// @param proofData All components of the proof except the Guest PVs ,
51+ /// @param proofData All components of the proof except the public values ,
5252 /// leaf and app exe commits. The expected format is:
5353 /// `abi.encodePacked(kzgAccumulators, proofSuffix)`
5454 /// @param appExeCommit The commitment to the OpenVM application executable whose execution
5555 /// is being verified.
5656 function verify (bytes calldata publicValues , bytes calldata proofData , bytes32 appExeCommit ) external view {
57- if (publicValues.length != GUEST_PVS_LENGTH ) revert InvalidGuestPvsLength ();
58- if (proofData.length != PARTIAL_PROOF_LENGTH ) revert InvalidPartialProofLength ();
57+ if (publicValues.length != PUBLIC_VALUES_LENGTH ) revert InvalidPublicValuesLength ();
58+ if (proofData.length != PROOF_DATA_LENGTH ) revert InvalidProofDataLength ();
5959
6060 // We will format the public values and construct the full proof payload
6161 // below.
@@ -79,14 +79,14 @@ contract OpenVmHalo2Verifier is Halo2Verifier, IOpenVmHalo2Verifier {
7979 //
8080 /// ```solidity
8181 /// bytes memory proof =
82- /// abi.encodePacked(partialProof [0:0x180], appExeCommit, leafExeCommit, guestPvsPayload, partialProof [0x180:]);
82+ /// abi.encodePacked(proofData [0:0x180], appExeCommit, leafExeCommit, publicValuesPayload, proofData [0x180:]);
8383 /// ```
8484 //
85- /// where `guestPvsPayload ` is a memory payload with each byte in
86- /// `guestPvs ` separated into its own `bytes32` word.
85+ /// where `publicValuesPayload ` is a memory payload with each byte in
86+ /// `publicValues ` separated into its own `bytes32` word.
8787 ///
8888 /// This function does not clean the memory it allocates. Since it is the
89- /// only memory allocation that occurs in the call frame, so we know that
89+ /// only memory allocation that occurs in the call frame, we know that
9090 /// the memory region was not written to before.
9191 ///
9292 /// @return proofPtr Memory pointer to the beginning of the constructed
@@ -104,8 +104,8 @@ contract OpenVmHalo2Verifier is Halo2Verifier, IOpenVmHalo2Verifier {
104104 // proof[..0x180]: KZG accumulators
105105 // proof[0x180..0x1a0]: app exe commit
106106 // proof[0x1a0..0x1c0]: leaf exe commit
107- // proof[0x1c0..(0x1c0 + GUEST_PVS_LENGTH * 32)]: guestPvs [0..GUEST_PVS_LENGTH ]
108- // proof[(0x1c0 + GUEST_PVS_LENGTH * 32)..]: Guest PVs Suffix
107+ // proof[0x1c0..(0x1c0 + PUBLIC_VALUES_LENGTH * 32)]: publicValues [0..PUBLIC_VALUES_LENGTH ]
108+ // proof[(0x1c0 + PUBLIC_VALUES_LENGTH * 32)..]: Public Values Suffix
109109
110110 /// @solidity memory-safe-assembly
111111 assembly {
@@ -121,20 +121,20 @@ contract OpenVmHalo2Verifier is Halo2Verifier, IOpenVmHalo2Verifier {
121121 mstore (add (proofPtr, 0x180 ), appExeCommit)
122122 mstore (add (proofPtr, 0x1a0 ), leafExeCommit)
123123
124- // Copy the Guest PVs Suffix (length 43 * 32 = 0x560) into the
125- // end of the memory buffer, leaving GUEST_PVS_LENGTH words in
126- // between for the guestPvsPayload .
124+ // Copy the Public Values Suffix (length 43 * 32 = 0x560) into the
125+ // end of the memory buffer, leaving PUBLIC_VALUES_LENGTH words in
126+ // between for the publicValuesPayload .
127127 //
128128 // Begin copying from the end of the KZG accumulators in the
129129 // calldata buffer (0x180)
130- let suffixProofOffset := add (0x1c0 , shl (5 , GUEST_PVS_LENGTH ))
130+ let suffixProofOffset := add (0x1c0 , shl (5 , PUBLIC_VALUES_LENGTH ))
131131 calldatacopy (add (proofPtr, suffixProofOffset), add (proofData.offset, 0x180 ), 0x560 )
132132
133- // Copy each byte of the guestPvs into the proof. It copies the
134- // most significant bytes of guestPvs first.
135- let guestPvsMemOffset := add (add (proofPtr, 0x1c0 ), 0x1f )
136- for { let i := 0 } iszero (eq (i, GUEST_PVS_LENGTH )) { i := add (i, 1 ) } {
137- calldatacopy (add (guestPvsMemOffset , shl (5 , i)), add (publicValues.offset, i), 0x01 )
133+ // Copy each byte of the public values into the proof. It copies the
134+ // most significant bytes of public values first.
135+ let publicValuesMemOffset := add (add (proofPtr, 0x1c0 ), 0x1f )
136+ for { let i := 0 } iszero (eq (i, PUBLIC_VALUES_LENGTH )) { i := add (i, 1 ) } {
137+ calldatacopy (add (publicValuesMemOffset , shl (5 , i)), add (publicValues.offset, i), 0x01 )
138138 }
139139 }
140140 }
0 commit comments