feat: Private Kernel Recursion#6278
Conversation
…tecProtocol/aztec-packages into pw/enable-private-kernel-proving-test
Changes to circuit sizes
🧾 Summary (100% most significant diffs)
Full diff report 👇
|
LeilaWang
left a comment
There was a problem hiding this comment.
Some suggestions. Looks great to me overall! 🚀
| global PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH: u64 = CALL_CONTEXT_LENGTH + 2 + (READ_REQUEST_LENGTH * MAX_NULLIFIER_READ_REQUESTS_PER_CALL) + (READ_REQUEST_LENGTH * MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_CALL) + (CONTRACT_STORAGE_UPDATE_REQUEST_LENGTH * MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL) + (CONTRACT_STORAGE_READ_LENGTH * MAX_PUBLIC_DATA_READS_PER_CALL) + MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL + (NOTE_HASH_LENGTH * MAX_NEW_NOTE_HASHES_PER_CALL) + (NULLIFIER_LENGTH * MAX_NEW_NULLIFIERS_PER_CALL) + (L2_TO_L1_MESSAGE_LENGTH * MAX_NEW_L2_TO_L1_MSGS_PER_CALL) + 2 + (SIDE_EFFECT_LENGTH * MAX_UNENCRYPTED_LOGS_PER_CALL) + 1 + HEADER_LENGTH + GLOBAL_VARIABLES_LENGTH + AZTEC_ADDRESS_LENGTH + /* revert_code */ 1 + 2 * GAS_LENGTH + /* transaction_fee */ 1; | ||
| global PRIVATE_CALL_STACK_ITEM_LENGTH: u64 = AZTEC_ADDRESS_LENGTH + FUNCTION_DATA_LENGTH + PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH; | ||
|
|
||
| global READ_REQUEST_CONTEXT_SERIALIZED_LEN = 3; |
There was a problem hiding this comment.
Looks like this is copied from read_request.nr. Should we replace the constant in read_request.nr with this? I renamed the one in that file to SCOPED_READ_REQUEST_SERIALIZED_LEN. But maybe we should call it SCOPED_READ_REQUEST_LENGTH so that it's more consistent with other SCOPED_XXX_LENGTH.
| global CALL_REQUEST_LENGTH = 1 + AZTEC_ADDRESS_LENGTH + CALLER_CONTEXT_LENGTH + 2; | ||
| global PRIVATE_ACCUMULATED_DATA_LENGTH = (SCOPED_NOTE_HASH_LENGTH * MAX_NEW_NOTE_HASHES_PER_TX) + (SCOPED_NULLIFIER_LENGTH * MAX_NEW_NULLIFIERS_PER_TX) + (MAX_NEW_L2_TO_L1_MSGS_PER_TX * SCOPED_L2_TO_L1_MESSAGE_LENGTH) + (SIDE_EFFECT_LENGTH * MAX_ENCRYPTED_LOGS_PER_TX) + (SIDE_EFFECT_LENGTH * MAX_UNENCRYPTED_LOGS_PER_TX) + 2 + (CALL_REQUEST_LENGTH * MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX) + (CALL_REQUEST_LENGTH * MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX); | ||
| global PRIVATE_KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH = 1 + VALIDATION_REQUESTS_LENGTH + PRIVATE_ACCUMULATED_DATA_LENGTH + COMBINED_CONSTANT_DATA_LENGTH + CALL_REQUEST_LENGTH; | ||
|
|
There was a problem hiding this comment.
Although these constants are not used outside of noir. But can still run yarn remake-constants in circuits.js to update other constant files so that they won't appear in another irrelevant pr.
There was a problem hiding this comment.
Wasn't aware of that. Have pushed the updated files.
| await fs.writeFile(proofFileName, proof.buffer); | ||
| await fs.writeFile(verificationKeyPath, verificationKey); | ||
|
|
||
| const result = await verifyProof(this.bbBinaryPath, proofFileName, verificationKeyPath!, logFunction); |
There was a problem hiding this comment.
Shall we catch the error and always delete the directory?
This PR introduces recursive verification to the private kernel circuits. Both app circuit and previous kernel circuit proofs are verified. This closes #5978
The changes can be largely categorised as:
PrivateCircuitPublicInputsandPrivateKernelCircuitPublicInputsstructs to fields.verify_proofapi.Additional task create here to prevent the specification of
pubon arguments to private functions.