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

RFC-0002: Introducing Side-loading Verification Keys in o1js #3

Merged
merged 1 commit into from
Apr 17, 2024

Conversation

teddyjfpender
Copy link
Contributor

@teddyjfpender teddyjfpender commented Nov 27, 2023

🚀 Proposal Overview

We're excited to propose the introduction of side-loading verification keys in o1js smart contracts and provable-programs. This RFC (Request for Comments) aims to improve the developer experience by increasing flexibility and allow for the creation of new, innovative design patterns.

🎯 Why It Matters

Mina developers using o1js are limited to static verification keys compiled during their smart contract or provable-program creation, restricting dynamic interactions. By enabling side-loading of these keys, we open a world of possibilities, allowing for more complex, adaptable, and user-friendly applications within the Mina ecosystem.

🔍 Highlights of the RFC

  • Introduction of Side-loading Verification Keys: Allowing for greater flexibility and adaptability in smart contracts and programs.
  • Impact on Mina Ecosystem: This new feature in o1js has the potential to significantly improve application development within the Mina ecosystem, presenting broader applications and new design patterns.
  • Detailed Use Cases: We've outlined a few scenarios like KYC-transaction smart contracts and mutually recursive provable-programs to showcase the practical benefits and expanded capabilities this change would bring.

📣 Seeking Community Input

This proposal is a stepping stone and needs your contributions. Your input is vital to shaping a robust and effective implementation.

🔗 RFC Details

For a comprehensive understanding of the proposal, challenges, and anticipated impact, please refer to the full RFC document.

@teddyjfpender teddyjfpender requested a review from a team as a code owner November 27, 2023 12:46
@teddyjfpender teddyjfpender requested a review from a team December 4, 2023 16:18
@rpanic
Copy link

rpanic commented Dec 26, 2023

I started to implement side-loaded vks a few week ago and actually got quite far already.

I thought since this RFC exists, I will show you the API design that I came up with, in case anybody wants to share his/her thoughts.

So previously, we had one Proof class that provided the linkage between verification keys of compiled circuits to the usage of them in foreign circuits. After the introductions of sideloaded vks, this can now has to be distinguished between the old, static vks and the new SL-vks.
For this, I extended the old Proof class with its sideloaded pendant DynamicProof.

class DynamicProof<Input, Output> extends ProofBase<Input, Output> {
  verify(vk: VerificationKey);
  verifyIf(vk: VerificationKey, condition: Bool);
}

So as you can see, it implements the same methods as the default class does, but it requires a additional argument for the verfication key, that this proof should be verified with.

An example usage of this inside a ZkProgram could look like:

ZkProgram({
    name: "program2",
    publicInput: Field,
    methods: {
        foo: {
            privateInputs: [SampleSideloadedProof, VerificationKey],
            method(input: Field, proof: SampleSideloadedProof, vk: VerificationKey) {
                proof.verify(vk);

                proof.publicInput.assertEquals(input, "Public input not matching")
            }
        }
    }
});

Together with @mrmr1993 I am fixing some last issues, and after hearing everyone's thoughts, looking forward to merging this to o1js.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants