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

WEB3-262: Add [Groth16] Seal utilities #365

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Conversation

capossele
Copy link
Contributor

Groth16 seal utility functions to easily convert an onchain seal into a risc0 Receipt

@capossele capossele requested a review from a team as a code owner December 12, 2024 16:39
@github-actions github-actions bot changed the title Add [Groth16] Seal utilities WEB3-262: Add [Groth16] Seal utilities Dec 12, 2024
let seal_bytes = seal.to_vec();
let (selector, stripped_seal) = seal_bytes.split_at(4);
// Fake receipt seal is 32 bytes
let receipt = if stripped_seal.len() == 32 {
Copy link
Contributor

Choose a reason for hiding this comment

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

A set inclusion seal with one path element will also be 32 bytes.

Comment on lines +74 to +85
let receipt = if stripped_seal.len() == 32 {
if selector != [0u8; 4] {
return Err(anyhow::anyhow!(
"Invalid selector {} for fake receipt",
hex::encode(selector)
));
};
Receipt::new(
InnerReceipt::Fake(FakeReceipt::new(claim)),
journal.as_ref().to_vec(),
)
} else {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this function should handle fake receipts. It's currently an odd compromise, where it handles Groth16 and Fake receipts, but not set inclusion receipts and it would not handle e.g. Plonk receipts if we add them later. We probably needs two types of decoding. One would be a method that decodes to a specific type (e.g. Groth16, Fake, or SetInclusion), and another that decodes any seal in a list of known types. For the later, we will need a table included in the library mapping selectors to verifier parameter (digests). At the very least, that table should include Groth16, SetInclusion and Fake verifier parameters for the current version. We could additionally include previous versions in the this table as well. We've discussed this elsewhere, and it seems likely to be useful.

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.

2 participants