Skip to content

Commit 9c2eae3

Browse files
authored
chore: refactor private kernel init and inner (#19025)
Refactor some code and add more comments.
2 parents 26b6d5a + bac3351 commit 9c2eae3

File tree

207 files changed

+6497
-5494
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

207 files changed

+6497
-5494
lines changed

noir-projects/noir-protocol-circuits/Nargo.template.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ members = [
44
"crates/types",
55
"crates/blob",
66
"crates/parity-base",
7-
"crates/parity-lib",
87
"crates/parity-root",
98
"crates/private-kernel-lib",
109
"crates/private-kernel-init",

noir-projects/noir-protocol-circuits/bootstrap.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ function build {
157157
echo_stderr "Checking libraries for warnings..."
158158
parallel -v --line-buffer --tag $NARGO --program-dir {} check ::: \
159159
./crates/blob \
160-
./crates/parity-lib \
161160
./crates/private-kernel-lib \
162161
./crates/rollup-lib \
163162
./crates/types \
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
use dep::rollup_lib::tx_base::{PublicChonkVerifierPrivateInputs, PublicChonkVerifierPublicInputs};
1+
use dep::rollup_lib::tx_base::{
2+
public_chonk_verifier, PublicChonkVerifierPrivateInputs, PublicChonkVerifierPublicInputs,
3+
};
24

35
// CHONK_VERIFIER: Recursively verifies Chonk (Client Honk) proofs in circuits
46
fn main(inputs: PublicChonkVerifierPrivateInputs) -> pub PublicChonkVerifierPublicInputs {
5-
inputs.execute()
7+
public_chonk_verifier::execute(inputs)
68
}

noir-projects/noir-protocol-circuits/crates/hiding-kernel-to-public/Nargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ type = "bin"
44
authors = [""]
55

66
[dependencies]
7+
private_kernel_lib = { path = "../private-kernel-lib" }
78
types = { path = "../types" }
Lines changed: 8 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,16 @@
1-
use types::{
1+
use dep::private_kernel_lib::{hiding_kernel_to_public, HidingKernelToPublicPrivateInputs};
2+
use dep::types::{
23
abis::kernel_circuit_public_inputs::PrivateToPublicKernelCircuitPublicInputs,
3-
constants::{MEGA_VK_LENGTH_IN_FIELDS, PRIVATE_KERNEL_TAIL_TO_PUBLIC_INDEX, PROOF_TYPE_HN_FINAL},
4-
proof::vk_data::VkData,
4+
constants::MEGA_VK_LENGTH_IN_FIELDS, proof::vk_data::VkData,
55
};
66

7-
pub struct HidingKernelToPublicPrivateInputs {
8-
previous_kernel_public_inputs: PrivateToPublicKernelCircuitPublicInputs,
9-
previous_kernel_vk_data: VkData<MEGA_VK_LENGTH_IN_FIELDS>,
10-
}
11-
12-
impl HidingKernelToPublicPrivateInputs {
13-
pub fn execute(self) {
14-
// Verify previous kernel, which contains a folding proof and a decider proof.
15-
// The associated public inputs and proofs are linked through the verification queue in the backend.
16-
// The proof type `PROOF_TYPE_HN_FINAL` designates the final proof in the client IVC sequence.
17-
if !std::runtime::is_unconstrained() {
18-
std::verify_proof_with_type(
19-
self.previous_kernel_vk_data.vk.key,
20-
[],
21-
[],
22-
self.previous_kernel_vk_data.vk.hash,
23-
PROOF_TYPE_HN_FINAL,
24-
);
25-
}
26-
27-
// Validate that the vk index corresponds to the `private_kernel_tail_to_public` circuit.
28-
assert_eq(self.previous_kernel_vk_data.leaf_index, PRIVATE_KERNEL_TAIL_TO_PUBLIC_INDEX);
29-
30-
// Validates that the vk hash exists in the vk tree at the expected index.
31-
// Note: The hash of the verification key is checked in `verify_proof_with_type` against the given vk hash.
32-
self.previous_kernel_vk_data.validate_in_vk_tree(
33-
self.previous_kernel_public_inputs.constants.vk_tree_root,
34-
);
35-
}
36-
}
37-
387
fn main(
398
previous_kernel_public_inputs: call_data(0) PrivateToPublicKernelCircuitPublicInputs,
409
previous_kernel_vk_data: VkData<MEGA_VK_LENGTH_IN_FIELDS>,
4110
) -> pub PrivateToPublicKernelCircuitPublicInputs {
42-
HidingKernelToPublicPrivateInputs { previous_kernel_public_inputs, previous_kernel_vk_data }
43-
.execute();
44-
45-
previous_kernel_public_inputs
11+
let inputs = HidingKernelToPublicPrivateInputs {
12+
previous_kernel_public_inputs,
13+
previous_kernel_vk_data,
14+
};
15+
hiding_kernel_to_public::execute(inputs)
4616
}

noir-projects/noir-protocol-circuits/crates/hiding-kernel-to-rollup/Nargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ type = "bin"
44
authors = [""]
55

66
[dependencies]
7+
private_kernel_lib = { path = "../private-kernel-lib" }
78
types = { path = "../types" }
Lines changed: 8 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,16 @@
1-
use types::{
1+
use dep::private_kernel_lib::{hiding_kernel_to_rollup, HidingKernelToRollupPrivateInputs};
2+
use dep::types::{
23
abis::kernel_circuit_public_inputs::PrivateToRollupKernelCircuitPublicInputs,
3-
constants::{MEGA_VK_LENGTH_IN_FIELDS, PRIVATE_KERNEL_TAIL_INDEX, PROOF_TYPE_HN_FINAL},
4-
proof::vk_data::VkData,
4+
constants::MEGA_VK_LENGTH_IN_FIELDS, proof::vk_data::VkData,
55
};
66

7-
pub struct HidingKernelToRollupPrivateInputs {
8-
previous_kernel_public_inputs: PrivateToRollupKernelCircuitPublicInputs,
9-
previous_kernel_vk_data: VkData<MEGA_VK_LENGTH_IN_FIELDS>,
10-
}
11-
12-
impl HidingKernelToRollupPrivateInputs {
13-
pub fn execute(self) {
14-
// Verify previous kernel, which contains a folding proof and a decider proof.
15-
// The associated public inputs and proofs are linked through the verification queue in the backend.
16-
// The proof type `PROOF_TYPE_HN_FINAL` designates the final proof in the chonk sequence.
17-
if !std::runtime::is_unconstrained() {
18-
std::verify_proof_with_type(
19-
self.previous_kernel_vk_data.vk.key,
20-
[],
21-
[],
22-
self.previous_kernel_vk_data.vk.hash,
23-
PROOF_TYPE_HN_FINAL,
24-
);
25-
}
26-
27-
// Validate that the vk index corresponds to the `private_kernel_tail` circuit.
28-
assert_eq(self.previous_kernel_vk_data.leaf_index, PRIVATE_KERNEL_TAIL_INDEX);
29-
30-
// Validates that the vk hash exists in the vk tree at the expected index.
31-
// Note: The hash of the verification key is checked in `verify_proof_with_type` against the given vk hash.
32-
self.previous_kernel_vk_data.validate_in_vk_tree(
33-
self.previous_kernel_public_inputs.constants.vk_tree_root,
34-
);
35-
}
36-
}
37-
387
fn main(
398
previous_kernel_public_inputs: call_data(0) PrivateToRollupKernelCircuitPublicInputs,
409
previous_kernel_vk_data: VkData<MEGA_VK_LENGTH_IN_FIELDS>,
4110
) -> pub PrivateToRollupKernelCircuitPublicInputs {
42-
HidingKernelToRollupPrivateInputs { previous_kernel_public_inputs, previous_kernel_vk_data }
43-
.execute();
44-
45-
previous_kernel_public_inputs
11+
let inputs = HidingKernelToRollupPrivateInputs {
12+
previous_kernel_public_inputs,
13+
previous_kernel_vk_data,
14+
};
15+
hiding_kernel_to_rollup::execute(inputs)
4616
}

noir-projects/noir-protocol-circuits/crates/parity-base/Nargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ authors = [""]
55
compiler_version = ">=0.18.0"
66

77
[dependencies]
8-
parity_lib = { path = "../parity-lib" }
8+
rollup_lib = { path = "../rollup-lib" }
99
types = { path = "../types" }
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use dep::parity_lib::{ParityBasePrivateInputs, ParityPublicInputs};
1+
use dep::rollup_lib::parity::{parity_base, ParityBasePrivateInputs, ParityPublicInputs};
22

33
fn main(inputs: ParityBasePrivateInputs) -> pub ParityPublicInputs {
4-
inputs.execute()
4+
parity_base::execute(inputs)
55
}

noir-projects/noir-protocol-circuits/crates/parity-lib/Nargo.toml

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)