Skip to content

Commit 27f77ad

Browse files
committed
feat: compute proof commitment in contract
1 parent c584c29 commit 27f77ad

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

contracts/scripts/anvil/state/alignedlayer-deployed-anvil-state.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

contracts/src/core/AlignedProofAggregationService.sol

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,27 @@ contract AlignedProofAggregationService is
9090
emit AggregatedProofVerified(merkleRoot, blobVersionedHash);
9191
}
9292

93-
function verifyProofInclusion(bytes32[] calldata merklePath, bytes32 proofCommitment) public view returns (bool) {
93+
/// @notice Verifies the inclusion of proof in an aggregated proof via Merkle tree proof.
94+
///
95+
/// @dev
96+
/// - The `programId` parameter represents the unique identifier for the vm program:
97+
/// - In RISC Zero, this corresponds to the `image_id`.
98+
/// - In SP1, this corresponds to the `vk` (verification key) hash.
99+
/// - The proof commitment is derived by hashing together the `programId` and the `publicInputs`.
100+
/// - The `merklePath` is then used to compute the Merkle root from this commitment.
101+
/// - The function returns `true` if this Merkle root is known to correspond to a valid aggregated proof.
102+
///
103+
/// @param merklePath The Merkle proof (sibling hashes) needed to reconstruct the Merkle root.
104+
/// @param programId The identifier for the ZK program (image_id in RISC0 or vk hash in SP1).
105+
/// @param publicInputs The public inputs bytes of the proof.
106+
///
107+
/// @return bool Returns true if the computed Merkle root is a recognized valid aggregated proof.
108+
function verifyProofInclusion(bytes32[] calldata merklePath, bytes32 programId, bytes calldata publicInputs)
109+
public
110+
view
111+
returns (bool)
112+
{
113+
bytes32 proofCommitment = keccak256(abi.encodePacked(programId, publicInputs));
94114
bytes32 merkleRoot = MerkleProof.processProofCalldata(merklePath, proofCommitment);
95115
return aggregatedProofs[merkleRoot];
96116
}

contracts/src/core/IAlignedProofAggregationService.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ interface IAlignedProofAggregationService {
2222
bytes calldata risc0JournalBytes
2323
) external;
2424

25-
function verifyProofInclusion(bytes32[] calldata merklePath, bytes32 proofCommitment)
25+
function verifyProofInclusion(bytes32[] calldata merklePath, bytes32 programId, bytes calldata publicInputs)
2626
external
2727
view
2828
returns (bool);

0 commit comments

Comments
 (0)