@@ -31,6 +31,7 @@ contract OpenVmHalo2Verifier is Halo2Verifier, IOpenVmHalo2Verifier {
3131 bytes32 public constant LEAF_EXE_COMMIT =
3232 bytes32 (0x0071628bff0dcb64201f77ff5c7d869c7073b842e3dadf9e618e8673ef671bfd );
3333
34+ /// @dev The version of OpenVM that generated the proof.
3435 string public constant OPENVM_VERSION = "v1.0.0 " ;
3536
3637 /// @notice A wrapper that constructs the proof into the right format for
@@ -73,22 +74,35 @@ contract OpenVmHalo2Verifier is Halo2Verifier, IOpenVmHalo2Verifier {
7374 }
7475 }
7576
77+ /// @dev The assembly code should perform the same function as the following
78+ /// solidity code:
79+ //
80+ /// ```solidity
81+ /// bytes memory proof =
82+ /// abi.encodePacked(partialProof[0:0x180], appExeCommit, leafExeCommit, guestPvsPayload, partialProof[0x180:]);
83+ /// ```
84+ //
85+ /// where `guestPvsPayload` is a memory payload with each byte in
86+ /// `guestPvs` separated into its own `bytes32` word.
87+ ///
88+ /// This function does not clean the memory it allocates. Since it is the
89+ /// only memory allocation that occurs in the call frame, we know that the
90+ /// memory was not written to before.
91+ ///
92+ /// @param guestPvs The PVs revealed by the OpenVM guest program.
93+ /// @param partialProof All components of the proof except the Guest PVs,
94+ /// leaf and app exe commits. The expected format is:
95+ /// `abi.encodePacked(kzgAccumulators, proofSuffix)`
96+ /// @param appExeCommit The commitment to the OpenVM application executable
97+ /// whose execution is being verified.
98+ ///
99+ /// @return proofPtr Memory pointer to the beginning of the constructed
100+ /// proof.
76101 function _constructProof (bytes calldata guestPvs , bytes calldata partialProof , bytes32 appExeCommit )
77102 internal
78103 pure
79104 returns (MemoryPointer proofPtr )
80105 {
81- // The assembly code should perform the same function as the following
82- // solidity code:
83- //
84- // ```solidity
85- // bytes memory proof =
86- // abi.encodePacked(partialProof[0:0x180], appExeCommit, leafExeCommit, guestPvsPayload, partialProof[0x180:]);
87- // ```
88- //
89- // where `guestPvsPayload` is a memory payload with each byte in
90- // `guestPvs` separated into its own `bytes32` word.
91-
92106 uint256 fullProofLength = FULL_PROOF_LENGTH;
93107 bytes32 leafExeCommit = LEAF_EXE_COMMIT;
94108
@@ -103,9 +117,7 @@ contract OpenVmHalo2Verifier is Halo2Verifier, IOpenVmHalo2Verifier {
103117 /// @solidity memory-safe-assembly
104118 assembly {
105119 proofPtr := mload (0x40 )
106- // Allocate the memory as a safety measure. We know that this is the
107- // only memory allocation that occurs in the call frame, so we don't
108- // need to clean the allocated memory.
120+ // Allocate the memory as a safety measure.
109121 mstore (0x40 , add (proofPtr, fullProofLength))
110122
111123 // Copy the KZG accumulators (length 0x180) into the beginning of
0 commit comments