Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable composition of rv32im programs and generalized recursion programs #1841

Merged
merged 74 commits into from
May 22, 2024

Conversation

nategraf
Copy link
Contributor

@nategraf nategraf commented May 16, 2024

As a major step towards composition with recursion programs and circuits implementing accelerators, this PR adds a control_root value to the receipt claim encoding of assumptions, and enables proving and of recursion programs that are not in the main set of rv32im transforms.

In the course of this PR, there are also a number of changes to make it possible to pass alternate parameters to proving and verification. In particular, ProverOpts now holds the set of allowed control roots and can be configured to use an alternate set, and VerifierContext holds the verifier parameters for each receipt type.

SuccinctReceipt has been made more generic, allowing it to represent proof of any recursion program that follows the convention of placing a control root in the first output slot, and a SHA-256 claim digest in the second output slot. This claim digest can be over a generic claim, which allows for claims representing the execution of e.g. accelerators which are not ReceiptClaim and do not represent zkVM execution.

Verification routines on Receipt and CompositeReceipt are simplified, partially taking advantage of recent changes to the rv32im circuit to zero-out the post-state digest, and partially by dropping ExitCode::Paused(0) as a default accepted exit code.

Copy link

vercel bot commented May 16, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Ignored Deployments
Name Status Preview Updated (UTC)
docs-website ⬜️ Ignored (Inspect) Visit Preview May 22, 2024 11:30pm
reports-and-benchmarks ⬜️ Ignored (Inspect) Visit Preview May 22, 2024 11:30pm

Copy link
Contributor Author

@nategraf nategraf May 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file was moved from risc0/zkvm/src/host/recursion/merkle.rs in or to make it possible to add MerkleProof as a (pub(crate)) field of SuccinctReceipt.

Comment on lines +92 to +101
pub fn hash_suite_from_name(name: impl AsRef<str>) -> Option<HashSuite<BabyBear>> {
match name.as_ref() {
"sha-256" => Some(sha::Sha256HashSuite::new_suite()),
"poseidon2" => Some(poseidon2::Poseidon2HashSuite::new_suite()),
"blake2b" => Some(blake2b::Blake2bCpuHashSuite::new_suite()),
#[cfg(feature = "prove")]
"poseidon_254" => Some(poseidon_254::Poseidon254HashSuite::new_suite()),
_ => None,
}
}
Copy link
Member

@flaub flaub May 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. I was also thinking of making the hashfn a non_exhaustive enum, rather than a string

@nategraf nategraf marked this pull request as ready for review May 22, 2024 05:31
@nategraf
Copy link
Contributor Author

Some failures in risc0-ethereum tests. These are expected due to breaking API changes, and I think it is fine to ignore these for the purpose of merging this PR, the follow up with a PR to that repo. Once we hit 1.0 (very soon now!), that test should be more reliable.
https://github.com/risc0/risc0/actions/runs/9186038065/job/25261017020?pr=1841

@SchmErik
Copy link
Contributor

Some failures in risc0-ethereum tests. These are expected due to breaking API changes, and I think it is fine to ignore these for the purpose of merging this PR, the follow up with a PR to that repo. Once we hit 1.0 (very soon now!), that test should be more reliable. https://github.com/risc0/risc0/actions/runs/9186038065/job/25261017020?pr=1841

Agreed! risc0-ethereum should pass after making the fix and should be more stable after 1.0

Copy link
Contributor

@jbruestle jbruestle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did a fairly careful review of the cryptographically relevant bits. Will wait for Frank's OK on the rest.

Comment on lines +565 to +568
// NOTE: InnerReceipt and InnerAssumptionReceipt are the same type in protobuf.
// In Rust, they are distinct types becaue Rust needs to size everything on the
// stack and e.g. SuccinctReceipt<ReceiptClaim> and SuccinctReceipt<Unknown>
// have different sizes. Protobuf handles this without issue.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this will bite us in the end when we want to start making changes to one or the other. What's nice about having separate types in protobuf is that they can vary independently in a backwards-compatible way.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Part of my assumption here is that you can "fork" the types later as needed without introducing a backwards incompatibility at the protobuf layer. I think this is true, but I'm not 100% sure.

I'd be happy to split this out now

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, if we can fork later in a compatible way, then this seems fine to me.

nategraf and others added 3 commits May 22, 2024 13:42
Co-authored-by: Frank Laub <flaub@risc0.com>
Co-authored-by: Frank Laub <flaub@risc0.com>
Copy link
Member

@flaub flaub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fantastic!

@nategraf nategraf enabled auto-merge (squash) May 22, 2024 23:22
@nategraf nategraf merged commit 701b3d9 into main May 22, 2024
36 of 40 checks passed
@nategraf nategraf deleted the victor/generalized-composition-assumptions branch May 22, 2024 23:55
capossele pushed a commit to risc0/risc0-ethereum that referenced this pull request May 29, 2024
… to match zkVM 1.0 (#124)

In risc0/risc0#1841 where changes to the control
root (due to an updated `resolve` program) as well as a changes to how
the `Gorth16ReceiptVerifierParamters` are hashed. This PR addresses
those.
nategraf added a commit that referenced this pull request May 29, 2024
A mistake in #1841, the newline `\n`
in the format string doesn't turn into a newline when using `r#"` string
literals.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants