Skip to content

Commit

Permalink
forge test runs but real verification failed
Browse files Browse the repository at this point in the history
  • Loading branch information
CeciliaZ030 committed Jul 14, 2024
1 parent 6764e7a commit 039c1df
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
4 changes: 2 additions & 2 deletions provers/sp1/contracts/src/Raiko.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ contract Raiko {
view
returns (bytes32)
{
ISP1Verifier(verifier).verifyProof(RaikoProgramVkey, publicValues, proof);
bytes32 pi_hash = abi.decode(publicValues, bytes32);
ISP1Verifier(verifier).verifyProof(raikoProgramVkey, publicValues, proof);
bytes32 pi_hash = abi.decode(publicValues, (bytes32));
return pi_hash;
}
}
2 changes: 1 addition & 1 deletion provers/sp1/contracts/src/fixtures/fixture.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"pi_hash": "0x i don't know",
"vkey": "0x000c413c257554c0d44f840ea4e6e3cf6acf1ec722af839547814ce9632fd6bf",
"pi_hash": "0x000c413c257554c0d44f840ea4e6e3cf6acf1ec722af839547814ce9632fd6bf",
"publicValues": "0x00000000000000000000000000000000000000000000000000000000000001f400000000000000000000000000000000000000000000000000000000000004f40000000000000000000000000000000000000000000000000000000000000786",
"proof": "0x1b24bf0ece10786a2307e121b48c2c90c4b07641f81b773502cb132296a837c61c37e1fb4402606cacf385295f7b4832d2222f9ecd9803d022c09fb159e8af8f0fd2cb1fceb65e32058b0f7e04734682cca35b917098b6e0a95aeb02f69272c4168899e7867a5ddfa8246ec4fe35a0e2d2ac85355a26b2490ed78aea20a2869a115b66835ee849fa9fbd3462138bccb3092b4f4cb8cdd5af495ae5ab06f0e1a00c043787dcda55e88dca9a6b845806f626b29c0d191aaf48ae93d00e02ffda7a2680eaf720b34b00aa4477b6b9b4512e0cc94b2df5a865a6c0cb491bdc834f5800c80881e1ce55a364dcce58fb1daaaf9f5986845036b1831024e03072a3ac56051d6c07a287a27414da42ba86bf42cc9d0ef7f17ebb1226f6b263086c2d77b910466c8d8b6675c0d0fce875f6b594722ad5bdaeeca7d4b673467adf065cf00d2f2ecdf78010fe75f1212dd9c6540c96a6e1eb11530290e966699018c1e41d7b07e3a1a08cb13adcf536851e5f58e33f464321118b67f8c80db338733c3bda72039aa214dfe5015f117b6f876b018199424510024b2946bb5f8027245225ff8b240237bdef147c509f04f33a09da19549a27411430c059cd1376f2706549b6671694bb18973c35c9fe8cc4d40f08c60aca4c277ddf09eb2e095556f3c3156ba51550b6a94fd21d4540764d093fb39e4e6c4517bd4ccc87c21f08fdd4588ff27b032cbbfb8c6a8cd431524521677d40aed6700eac960e2ca5f66c6f19cbcbe1af16f962c9e5eae242aab756079cee9a1419474da4e3f5d531f70738e6dac99dd40858cee714f519e6af127d3c57553c1e3ace3206dc24866f6dce3b6a9fa99ced10ef7440dc5227ab24c05201207fdfeb341fbe716f2a969c9663d6b2188c25271abff2b7c68177be370f2d804306693461a5f749de729433ad45e6eff0b692e216c9216e5596d7a39e5971c5bcfed0cebb520014059ec9ade2c7a1196d967f4121aa5603cda863fbda14a380853fdac1e09de824fc8bb65c29ef2fd78d32aa8e24bef20ab27682cd82dcaee11a478bc5f9da361d87262686b1b2d91f135a10d3120954d3a8f3f5c14c069730d0c9bfc2bb86f7cd6a106e294f1ecddd3543b7110bc67355e1fc211b968f314ebcf9ea8352a01d0b9a1bbaac88457409b49388ac189007a6b62c2839220edd1f012ff5331baec07c4077522fce86fd3b8931e8a4"
}
27 changes: 14 additions & 13 deletions provers/sp1/contracts/test/Raiko.t.sol
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;

import {Test} from "forge-std/Test.sol";
import {Test, console} from "forge-std/Test.sol";
import {stdJson} from "forge-std/StdJson.sol";
import {Raiko} from "../src/Raiko.sol";
import {SP1Verifier} from "../src/SP1Verifier.sol";
import "forge-std/console.sol";
import {SP1VerifierGateway} from "@sp1-contracts/SP1VerifierGateway.sol";

struct RaikoProofFixture {
bytes32 pi_hash;
bytes proof;
bytes publicValues;
bytes32 vkey;
}

struct SP1ProofFixtureJson {
uint32 a;
uint32 b;
uint32 n;
bytes proof;
bytes publicValues;
bytes32 vkey;
}


contract RaikoTest is Test {
using stdJson for string;

Expand All @@ -36,7 +45,7 @@ contract RaikoTest is Test {
}

function test_ValidRaikoProof() public {
SP1ProofFixtureJson memory fixture = loadFixture();
RaikoProofFixture memory fixture = loadFixture();

vm.mockCall(verifier, abi.encodeWithSelector(SP1VerifierGateway.verifyProof.selector), abi.encode(true));

Expand All @@ -46,18 +55,10 @@ contract RaikoTest is Test {

function testFail_InvalidRaikoProof() public view {
RaikoProofFixture memory fixture = loadFixture();
raiko.verifyRaikoProof(
fixture.publicValues,
fixture.publicValues
);
}

function testFail_InvalidRaikoProof() public view {
RaikoProofFixtureJson memory fixture = loadFixture();

// Create a fake proof.
bytes memory fakeProof = new bytes(fixture.proof.length);

fibonacci.verifyFibonacciProof(fakeProof, fixture.publicValues);
raiko.verifyRaikoProof(fakeProof, fixture.publicValues);
}
}

0 comments on commit 039c1df

Please sign in to comment.