Skip to content

Commit

Permalink
feat: Update to the new snarkjs verifier
Browse files Browse the repository at this point in the history
  • Loading branch information
Dimo99 committed Sep 4, 2024
1 parent 0c7d521 commit bc8257f
Show file tree
Hide file tree
Showing 4 changed files with 190 additions and 261 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ pragma solidity 0.8.9;

import './Verifier.sol';

contract LightClientUpdateVerifier is Verifier {
contract LightClientUpdateVerifier is Groth16Verifier {
error VerificationCallFailed();

function verifyUpdate(
uint256[2] memory a,
uint256[2][2] memory b,
Expand All @@ -14,7 +16,7 @@ contract LightClientUpdateVerifier is Verifier {
bytes32 finalizedHeaderRoot,
bytes32 executionStateRoot,
bytes32 domain
) internal view returns (bool) {
) internal returns (bool) {
bytes memory concatenated = abi.encodePacked(prevHeaderHash, nextHeaderHash, finalizedHeaderRoot, executionStateRoot, nextHeaderSlot, domain);
bytes32 commitment = sha256(concatenated);

Expand All @@ -23,6 +25,16 @@ contract LightClientUpdateVerifier is Verifier {
input[0] = (uint256(commitment) & (((1 << 253) - 1) << 3)) >> 3;
input[1] = (uint256(commitment) & ((1 << 3) - 1));

return verifyProof(a, b, c, input);
(bool success, bytes memory returnData) = address(this).call(
// Encode the call to the `verify` function with the public inputs
abi.encodeWithSelector(Groth16Verifier.verifyProof.selector, a, b, c, input)
);

// Check if the call was successful
if (!success) {
revert VerificationCallFailed();
}

return abi.decode(returnData, (bool));
}
}
Loading

0 comments on commit bc8257f

Please sign in to comment.