taikoxyz / raiko

Multi-proofs for Taiko. SNARKS, STARKS and Trusted Execution Enclave. Our previous ZK-EVM circuits are deprecated.
Apache License 2.0
124 stars 90 forks source link

Update Risc0 with the latest release of Stark2Snark #144

Open CeciliaZ030 opened 6 months ago

CeciliaZ030 commented 6 months ago

Describe the feature request

We are currently at risc0-zkvm = "0.21.0". The latest main branch contains updates after their open-source announcement which has a lot more nicer APIs. Example workflow:

    let env = ExecutorEnv::builder()
        .write(&MultiTestSpec::BusyLoop { cycles: 0 })
        .unwrap()
        .build()
        .unwrap();

    tracing::info!("execute");

    let mut exec = ExecutorImpl::from_elf(env, MULTI_TEST_ELF).unwrap();
    let session = exec.run().unwrap();

    tracing::info!("prove");
    let opts = ProverOpts::default();
    let ctx = VerifierContext::default();
    let prover = get_prover_server(&opts).unwrap();
    let receipt = prover.prove_session(&ctx, &session).unwrap().receipt;
    let claim = receipt.claim().unwrap();
    let composite_receipt = receipt.inner.composite().unwrap();
    let succinct_receipt = prover.compress(composite_receipt).unwrap();
    let journal = session.journal.unwrap().bytes;

    tracing::info!("identity_p254");
    let ident_receipt = identity_p254(&succinct_receipt).unwrap();
    let seal_bytes = ident_receipt.get_seal_bytes();

    tracing::info!("stark-to-snark");
    let seal = stark_to_snark(&seal_bytes).unwrap().to_vec();

    tracing::info!("Receipt");
    let receipt = Receipt::new(
        InnerReceipt::Compact(CompactReceipt { seal, claim }),
        journal,
    );

At some point we should try out risc0-zkvm = { git = "https://github.com/risc0/risc0.git", branch = "main" } and see whether we can save cost on bonsai.

Spam policy

mratsim commented 4 months ago

Since then Risc0 has updated to v1.0.x and on synthetic SHA256 CPU benchmarks (without circuits/precompiles) improvement is a dramatic x2.5.

We should pin a version though for reproducibility.