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

Create an 'Initial' Private Kernel Circuit #506

Closed
dbanks12 opened this issue May 9, 2023 · 3 comments
Closed

Create an 'Initial' Private Kernel Circuit #506

dbanks12 opened this issue May 9, 2023 · 3 comments
Assignees
Labels
C-protocol-circuits Component: Protocol circuits (kernel & rollup)

Comments

@dbanks12
Copy link
Collaborator

dbanks12 commented May 9, 2023

Migrated from archived circuits repo: AztecProtocol/aztec3-circuits#200

"""
Currently, there's only 1 private kernel circuit.

That means for the very first iteration, we need to generate dummy 'previous kernel data'. The way we generate this data is inefficient, and the way we generate this data is inefficient (because we're currently generating actual VKs over a mock circuit).

Todo:

  • Separate c_bind for calling the initial native previous kernel circuit
  • A new struct for InitialPrivateKernelInputs and InitialPrivateKernelPublicInputs
  • Remove code which generates a dummy previous kernel (unless needed for testing, but I don't think we'll need that)
  • Write an initial native previous kernel circuit, which skips 'previous kernel proof verification' and any 'recursive case' logic
    • Make sure to re-use common codepaths between this circuit and the existing 'recursive' private kernel circuit (refactor to put functions in common files, if needed).
    • Make sure this circuit can only be called in the 'base case' (by including appropriate assertions inside the circuit)
  • Update the existing 'recursive' private kernel circuit:
    • remove:
      • The signature verification
      • TxRequest validation (we might even be able to remove the SignedTxRequest input altogether)
      • The 'base case' logic
      • Contract deployment logic (for now)
    • keep:
      • Verification of the 'previous kernel data'
      • recursive case logic
      • etc.
    • new:
      • A check on the previous kernel data's verification key -- that it matches the hard-coded one of the initial kernel circuit, when executing private_call_count = 2. (I.e. we're enforcing that private_call_count = 1 used the 'initial' circuit).
        • Note: for subsequent iterations of the kernel circuit, we can't check the verification key within the kernel circuit, because that's cyclic! We defer such verification key checks to the base rollup circuit. (A separate issue will be opened for this).
  • Typescript:
    • Work with someone to make corresponding changes to all the typescript code (mainly in the kernel-prover package), including structs.

"""

Story subtasks:

  1. Split private_kernel__sim cbind into ...sim and ...initial_sim #502
  2. Create native_private_kernel_initial function #503
  3. Move logic between initial and inner private kernels #504
  4. Update private_kernel__initial_sim cbind to use underlying initial function #505
@dbanks12
Copy link
Collaborator Author

We'll want to mimic some of what has been done for the public kernel. We can move some logic into a common.hpp. Constructor logic only needs to be in the initial kernel. We may want to consider renaming some public kernel functions and structs if we decide on more intuitive names for their private kernel workalikes.

@dbanks12
Copy link
Collaborator Author

Note after starting work in #549:

  1. We'll want to add the CombinedHistoricTreeRoots to the PrivateKernelInputsInitial to initialize public_inputs.constants.
  2. We can initialize public_inputs.constants.tx_context from the tx_request.
  3. Since we discovered that there were checks missing comparing tx request against private call, we should add test cases that would catch this
  4. We shouldn't hesitate to refactor the public kernel to match ours as we move forward with the private kernel split

@dbanks12 dbanks12 removed their assignment May 12, 2023
@dbanks12 dbanks12 moved this from Todo to In Progress in A3 May 15, 2023
@dbanks12 dbanks12 moved this from In Progress to In Review in A3 Jun 1, 2023
@dbanks12 dbanks12 moved this from In Review to Done in A3 Jun 1, 2023
@iAmMichaelConnor
Copy link
Contributor

Closing, as status moved to 'Done' (it's a GitHub bug)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-protocol-circuits Component: Protocol circuits (kernel & rollup)
Projects
None yet
Development

No branches or pull requests

3 participants