Skip to content

Commit

Permalink
risczero test case
Browse files Browse the repository at this point in the history
  • Loading branch information
preston4896 committed Sep 11, 2024
1 parent 5fe583c commit c694040
Showing 1 changed file with 30 additions and 12 deletions.
42 changes: 30 additions & 12 deletions forge-test/AutomataDcapAttestationTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
pragma solidity ^0.8.13;

import "./utils/PCCSSetupBase.sol";
import "./utils/RiscZeroSetup.sol";

import {AutomataDcapAttestation} from "../contracts/AutomataDcapAttestation.sol";
import {V3QuoteVerifier} from "../contracts/verifiers/V3QuoteVerifier.sol";
import {V4QuoteVerifier} from "../contracts/verifiers/V4QuoteVerifier.sol";

import {IRiscZeroVerifier} from "risc0/IRiscZeroVerifier.sol";
// import {RiscZeroCheats} from "risc0/test/RiscZeroCheats.sol";

contract AutomataDcapAttestationTest is PCCSSetupBase {
contract AutomataDcapAttestationTest is PCCSSetupBase, RiscZeroSetup {
AutomataDcapAttestation attestation;
PCCSRouter pccsRouter;

Expand All @@ -24,16 +22,10 @@ contract AutomataDcapAttestationTest is PCCSSetupBase {
pccsRouter = setupPccsRouter();
pcsDaoUpserts();

// RiscZero Setup
// @dev you must disable DEV MODE, to get proof directly from Bonsai
// vm.setEnv("RISC0_DEV_MODE", "true");

// IRiscZeroVerifier riscZeroVerifier;
// riscZeroVerifier = deployRiscZeroVerifier();
setUpRiscZero();

// DCAP Contract Deployment
// attestation = new AutomataDcapAttestation(address(riscZeroVerifier), imageId);
attestation = new AutomataDcapAttestation(address(0), imageId);
attestation = new AutomataDcapAttestation(address(riscZeroVerifier), imageId);

vm.stopPrank();
}
Expand Down Expand Up @@ -100,4 +92,30 @@ contract AutomataDcapAttestationTest is PCCSSetupBase {
}
assertTrue(success);
}

function testZKProofAttestationViaFork() public {
// pinned August 1st, 2024, Midnight GMT
vm.warp(1722470400);

vm.startPrank(admin);
bytes memory pckCrlUpdate = hex"30820a6330820a08020101300a06082a8648ce3d04030230703122302006035504030c19496e74656c205347582050434b20506c6174666f726d204341311a3018060355040a0c11496e74656c20436f72706f726174696f6e3114301206035504070c0b53616e746120436c617261310b300906035504080c024341310b3009060355040613025553170d3234303731373037303934325a170d3234303831363037303934325a30820934303302146fc34e5023e728923435d61aa4b83c618166ad35170d3234303731373037303934325a300c300a0603551d1504030a01013034021500efae6e9715fca13b87e333e8261ed6d990a926ad170d3234303731373037303934325a300c300a0603551d1504030a01013034021500fd608648629cba73078b4d492f4b3ea741ad08cd170d3234303731373037303934325a300c300a0603551d1504030a010130340215008af924184e1d5afddd73c3d63a12f5e8b5737e56170d3234303731373037303934325a300c300a0603551d1504030a01013034021500b1257978cfa9ccdd0759abf8c5ca72fae3a78a9b170d3234303731373037303934325a300c300a0603551d1504030a01013033021474fea614a972be0e2843f2059835811ed872f9b3170d3234303731373037303934325a300c300a0603551d1504030a01013034021500f9c4ef56b3ab48d577e108baedf4bf88014214b9170d3234303731373037303934325a300c300a0603551d1504030a010130330214071de0778f9e5fc4f2878f30d6b07c9a30e6b30b170d3234303731373037303934325a300c300a0603551d1504030a01013034021500cde2424f972cea94ff239937f4d80c25029dd60b170d3234303731373037303934325a300c300a0603551d1504030a0101303302146c3319e5109b64507d3cf1132ce00349ef527319170d3234303731373037303934325a300c300a0603551d1504030a01013034021500df08d756b66a7497f43b5bb58ada04d3f4f7a937170d3234303731373037303934325a300c300a0603551d1504030a01013033021428af485b6cf67e409a39d5cb5aee4598f7a8fa7b170d3234303731373037303934325a300c300a0603551d1504030a01013034021500fb8b2daec092cada8aa9bc4ff2f1c20d0346668c170d3234303731373037303934325a300c300a0603551d1504030a01013034021500cd4850ac52bdcc69a6a6f058c8bc57bbd0b5f864170d3234303731373037303934325a300c300a0603551d1504030a01013034021500994dd3666f5275fb805f95dd02bd50cb2679d8ad170d3234303731373037303934325a300c300a0603551d1504030a0101303302140702136900252274d9035eedf5457462fad0ef4c170d3234303731373037303934325a300c300a0603551d1504030a01013033021461f2bf73e39b4e04aa27d801bd73d24319b5bf80170d3234303731373037303934325a300c300a0603551d1504030a0101303302143992be851b96902eff38959e6c2eff1b0651a4b5170d3234303731373037303934325a300c300a0603551d1504030a010130330214639f139a5040fdcff191e8a4fb1bf086ed603971170d3234303731373037303934325a300c300a0603551d1504030a01013034021500959d533f9249dc1e513544cdc830bf19b7f1f301170d3234303731373037303934325a300c300a0603551d1504030a0101303302140fda43a00b68ea79b7c2deaeac0b498bdfb2af90170d3234303731373037303934325a300c300a0603551d1504030a010130340215009d67753b81e47090aea763fbec4c4549bcdb9933170d3234303731373037303934325a300c300a0603551d1504030a01013033021434bfbb7a1d9c568147e118b614f7b76ed3ef68df170d3234303731373037303934325a300c300a0603551d1504030a0101303402150085d3c9381b77a7e04d119c9e5ad6749ff3ffab87170d3234303731373037303934325a300c300a0603551d1504030a0101303402150093887ca4411e7a923bd1fed2819b2949f201b5b4170d3234303731373037303934325a300c300a0603551d1504030a0101303302142498dc6283930996fd8bf23a37acbe26a3bed457170d3234303731373037303934325a300c300a0603551d1504030a010130340215008a66f1a749488667689cc3903ac54c662b712e73170d3234303731373037303934325a300c300a0603551d1504030a01013034021500afc13610bdd36cb7985d106481a880d3a01fda07170d3234303731373037303934325a300c300a0603551d1504030a01013034021500efe04b2c33d036aac96ca673bf1e9a47b64d5cbb170d3234303731373037303934325a300c300a0603551d1504030a0101303402150083d9ac8d8bb509d1c6c809ad712e8430559ed7f3170d3234303731373037303934325a300c300a0603551d1504030a0101303302147931fd50b5071c1bbfc5b7b6ded8b45b9d8b8529170d3234303731373037303934325a300c300a0603551d1504030a0101303302141fa20e2970bde5d57f7b8ddf8339484e1f1d0823170d3234303731373037303934325a300c300a0603551d1504030a0101303302141e87b2c3b32d8d23e411cef34197b95af0c8adf5170d3234303731373037303934325a300c300a0603551d1504030a010130340215009afd2ee90a473550a167d996911437c7502d1f09170d3234303731373037303934325a300c300a0603551d1504030a0101303302144481b0f11728a13b696d3ea9c770a0b15ec58dda170d3234303731373037303934325a300c300a0603551d1504030a01013034021500a7859f57982ef0e67d37bc8ef2ef5ac835ff1aa9170d3234303731373037303934325a300c300a0603551d1504030a0101303302147ae37748a9f912f4c63ba7ab07c593ce1d1d1181170d3234303731373037303934325a300c300a0603551d1504030a01013033021413884b33269938c195aa170fca75da177538df0b170d3234303731373037303934325a300c300a0603551d1504030a0101303302142c3cc6fe9279db1516d5ce39f2a898cda5a175e1170d3234303731373037303934325a300c300a0603551d1504030a010130330214717948687509234be979e4b7dce6f31bef64b68c170d3234303731373037303934325a300c300a0603551d1504030a010130340215009d76ef2c39c136e8658b6e7396b1d7445a27631f170d3234303731373037303934325a300c300a0603551d1504030a01013034021500c3e025fca995f36f59b48467939e3e34e6361a6f170d3234303731373037303934325a300c300a0603551d1504030a010130340215008c5f6b3257da05b17429e2e61ba965d67330606a170d3234303731373037303934325a300c300a0603551d1504030a01013034021500a17c51722ec1e0c3278fe8bdf052059cbec4e648170d3234303731373037303934325a300c300a0603551d1504030a0101a02f302d300a0603551d140403020101301f0603551d23041830168014956f5dcdbd1be1e94049c9d4f433ce01570bde54300a06082a8648ce3d04030203490030460221008ef10a3081e047107b5882989aa86888f7722c9c3c178d3b8075e6058972903c022100956b4891144c4b2bb9192215c5060abd82a5d7e90f05f8f4364e5c74c119b99c";
pcsDao.upsertPckCrl(CA.PLATFORM, pckCrlUpdate);
V4QuoteVerifier quoteVerifier = new V4QuoteVerifier(address(pccsRouter));
attestation.setQuoteVerifier(address(quoteVerifier));
assertEq(address(attestation.quoteVerifiers(4)), address(quoteVerifier));
vm.stopPrank();

bytes memory journal = hex"55020004000000810000806f05000004010700000000000000000000000000ffc97a88587660fb04e1f7c851300c96ae0b5a463ac46d035d16c2d9f36d0ed1d23775bcbd27deb219e3a3cc2802389500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000e700060000000000935be7742dd89c6a4df6dba8353d89041ae0f052beef993b1e7f4524d3bc57650df20e5582158352e1240b3f1fed55d800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000051fe06600000000263d136c1a2a09982f4fefe376b9ba54fa79ac23cbb24e0b0afe11bbe887ea836ff7242a4e842c8da74ac54490c4a0185b39f1e7e3a2834d1d306bdb089f080e0fa74a3f32c80b978c8ad671395dabf24283eef9091bc3919fd39b9915a87f1adf3061c165c0191e2658256a2855cac9267f179aafb1990c9e918d6452816adf9953f245d005b9d7d8e36a842a60b51e5cf85b2c2072ae397c178535c9985b7738f66e00977fffefe8c29eedb0bd5f9be77a9588d216eb8d711a33783dbac54d";
bytes memory seal = hex"310fe59829804dc23822fb1f81bd008128867b16042eef12dc3677773dba3c8daf0a24871ca16bb503d9f9d1cc418bbcbb200629cfb02ff250e466fd493b905002cf23a3267a2ab4d4bb470154fc4dfff7f40a8a072312f6849af1cb46465a53d573f5ef22b6052bbf0b7bdf4502cfecc8a47a08c8374f64b7863c760c3f4f61b333d144105c93790e5e5cf1dfd8fd5e0890d09714af1db6253f1c4ea9fc4b94b691b6b20d984b5ea58a8233bb6813da5265f6e13c76617754ea327e843390d5a50013020a934151f46f8ac6e70ec39db759457dee18c36678d4f9d9d28c9eefb0acd1db21c3a23adbb4a289479cf63dcc104342ff3da4ba5d17e39abacc4abd9f3395eb";

(bool success, bytes memory output)= attestation.verifyAndAttestWithZKProof(
journal,
seal
);

if (!success) {
console.log(string(output));
}
assertTrue(success);
}
}

0 comments on commit c694040

Please sign in to comment.