Skip to content

Commit 41c44c4

Browse files
committed
chore: address comments
1 parent c2a795f commit 41c44c4

File tree

2 files changed

+20
-13
lines changed

2 files changed

+20
-13
lines changed

src/OpenVmHalo2Verifier.sol

Lines changed: 14 additions & 13 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,11 @@ 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
55-
///
5649
/// @param partialProof All components of the proof except the Guest PVs,
5750
/// leaf and app exe commits. The expected format is:
58-
/// `abi.encodePacked(KZG accumulators, Guest PVs Suffix)`
51+
/// `abi.encodePacked(kzgAccumulators, proofSuffix)`
5952
/// @param guestPvs The PVs revealed by the OpenVM guest program.
60-
/// @param appExeCommit The commitment to the RISC-V executable whose execution
53+
/// @param appExeCommit The commitment to the OpenVM application executable whose execution
6154
/// is being verified.
6255
function verify(bytes calldata guestPvs, bytes calldata partialProof, bytes32 appExeCommit) external view {
6356
if (guestPvs.length != GUEST_PVS_LENGTH) revert InvalidGuestPvsLength();
@@ -94,11 +87,19 @@ contract OpenVmHalo2Verifier is Halo2Verifier {
9487
// ```
9588
//
9689
// where `guestPvsPayload` is a memory payload with each byte in
97-
// `guestPvs` separated into its own word.
90+
// `guestPvs` separated into its own `bytes32` word.
9891

9992
uint256 fullProofLength = FULL_PROOF_LENGTH;
10093
bytes32 leafExeCommit = LEAF_EXE_COMMIT;
10194

95+
// The expected proof format using hex offsets:
96+
//
97+
// proof[..0x180]: KZG accumulators
98+
// proof[0x180..0x1a0]: app exe commit
99+
// proof[0x1a0..0x1c0]: leaf exe commit
100+
// proof[0x1c0..(0x1c0 + GUEST_PVS_LENGTH * 32)]: guestPvs[0..GUEST_PVS_LENGTH]
101+
// proof[(0x1c0 + GUEST_PVS_LENGTH * 32)..]: Guest PVs Suffix
102+
102103
/// @solidity memory-safe-assembly
103104
assembly {
104105
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)