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 5, 2024
1 parent 4b9de06 commit e7d78ff
Show file tree
Hide file tree
Showing 5 changed files with 191 additions and 262 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@
url = https://github.com/ethereum/consensus-spec-tests.git
[submodule "vendor/snarkjs"]
path = vendor/snarkjs
url = [email protected]:iden3/snarkjs.git
url = [email protected]:metacraft-labs/snarkjs.git
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 e7d78ff

Please sign in to comment.