Skip to content

Commit f7e27ed

Browse files
committed
chore: address comments
1 parent c2a795f commit f7e27ed

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

src/OpenVmHalo2Verifier.sol

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
pragma solidity 0.8.19;
33

44
import { Halo2Verifier } from "./Halo2Verifier.sol";
5+
import { IOpenVmHalo2Verifier } from "./interfaces/IOpenVmHalo2Verifier.sol";
56

67
type MemoryPointer is uint256;
78

89
/// @notice This contract provides a thin wrapper around the Halo2 verifier
910
/// outputted by `snark-verifier`, exposing a more user-friendly interface.
10-
contract OpenVmHalo2Verifier is Halo2Verifier {
11+
contract OpenVmHalo2Verifier is Halo2Verifier, IOpenVmHalo2Verifier {
1112
/// @dev Invalid partial proof length
1213
error InvalidPartialProofLength();
1314

@@ -35,7 +36,7 @@ contract OpenVmHalo2Verifier is Halo2Verifier {
3536
/// @notice A wrapper that constructs the proof into the right format for
3637
/// use with the `snark-verifier` verification.
3738
///
38-
/// @dev This function assumes that `publicValues` encodes one `bytes32`
39+
/// @dev This function assumes that `guestPvs` encodes one `bytes32`
3940
/// hash which is the hash of the public values.
4041
///
4142
/// The verifier expected proof format is:
@@ -45,19 +46,13 @@ contract OpenVmHalo2Verifier is Halo2Verifier {
4546
/// proof[14 * 32..(14 + GUEST_PVS_LENGTH) * 32]: guestPvs[0..GUEST_PVS_LENGTH]
4647
/// proof[(14 + GUEST_PVS_LENGTH) * 32..]: Guest PVs Suffix
4748
///
48-
/// Or with hex offsets
49-
///
50-
/// proof[..0x180]: KZG accumulators
51-
/// proof[0x180..0x1a0]: app exe commit
52-
/// proof[0x1a0..0x1c0]: leaf exe commit
53-
/// proof[0x1c0..(0x1c0 + GUEST_PVS_LENGTH * 32)]: guestPvs[0..GUEST_PVS_LENGTH]
54-
/// proof[(0x1c0 + GUEST_PVS_LENGTH * 32)..]: Guest PVs Suffix
49+
5550
///
5651
/// @param partialProof All components of the proof except the Guest PVs,
5752
/// leaf and app exe commits. The expected format is:
58-
/// `abi.encodePacked(KZG accumulators, Guest PVs Suffix)`
53+
/// `abi.encodePacked(kzgAccumulators, proofSuffix)`
5954
/// @param guestPvs The PVs revealed by the OpenVM guest program.
60-
/// @param appExeCommit The commitment to the RISC-V executable whose execution
55+
/// @param appExeCommit The commitment to the OpenVM application executable whose execution
6156
/// is being verified.
6257
function verify(bytes calldata guestPvs, bytes calldata partialProof, bytes32 appExeCommit) external view {
6358
if (guestPvs.length != GUEST_PVS_LENGTH) revert InvalidGuestPvsLength();
@@ -94,11 +89,19 @@ contract OpenVmHalo2Verifier is Halo2Verifier {
9489
// ```
9590
//
9691
// where `guestPvsPayload` is a memory payload with each byte in
97-
// `guestPvs` separated into its own word.
92+
// `guestPvs` separated into its own `bytes32` word.
9893

9994
uint256 fullProofLength = FULL_PROOF_LENGTH;
10095
bytes32 leafExeCommit = LEAF_EXE_COMMIT;
10196

97+
// The expected proof format using hex offsets:
98+
//
99+
// proof[..0x180]: KZG accumulators
100+
// proof[0x180..0x1a0]: app exe commit
101+
// proof[0x1a0..0x1c0]: leaf exe commit
102+
// proof[0x1c0..(0x1c0 + GUEST_PVS_LENGTH * 32)]: guestPvs[0..GUEST_PVS_LENGTH]
103+
// proof[(0x1c0 + GUEST_PVS_LENGTH * 32)..]: Guest PVs Suffix
104+
102105
/// @solidity memory-safe-assembly
103106
assembly {
104107
proofPtr := mload(0x40)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.19;
3+
4+
interface IOpenVmHalo2Verifier {
5+
function verify(bytes calldata guestPvs, bytes calldata partialProof, bytes32 appExeCommit) external view;
6+
}

0 commit comments

Comments
 (0)