Skip to content

Commit e56e490

Browse files
authored
fix(kernel): bind tx_request_salt across the private kernels (#477)
* fix(kernel): bind tx_request_salt across the private kernels * update PR #477 * update PR #477 * chore: regenerate protocol + mock pinned-build for tx_request_salt * test: thread tx_request_salt into kernel Prover.toml fixtures
1 parent 84497a6 commit e56e490

13 files changed

Lines changed: 49 additions & 2 deletions

File tree

1.2 KB
Binary file not shown.

noir-projects/noir-protocol-circuits/crates/private-kernel-inner/Prover.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ claimed_first_nullifier = "0x18597ca0c71a7f7b36a69ff04d8096400a51c89f87e3c48da8f
186186
claimed_revertible_counter = "0x0000000000000000000000000000000000000000000000000000000000000004"
187187

188188
[previous_kernel_public_inputs.constants]
189+
tx_request_salt = "0x2deeb4d4a9cfc5a97e7403c4d21745f34e0c7971e29c38ac4a473bacbd10cac2"
189190
vk_tree_root = "0x1d81bf218cf88e95c51350b4b8de70a16798a155136d1eeb6e4f3ee05815a14d"
190191

191192
[previous_kernel_public_inputs.constants.anchor_block_header]

noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/private_call_data_validator.nr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ impl PrivateCallDataValidator {
171171
"anchor block header mismatch",
172172
);
173173
assert_eq(this_call.tx_context, constants.tx_context, "mismatch tx context");
174+
assert_eq(this_call.tx_request_salt, constants.tx_request_salt, "mismatch tx_request_salt");
174175
}
175176

176177
/// For Inner only.

noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/private_kernel_circuit_output_composer.nr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ impl PrivateKernelCircuitOutputComposer {
6666
) -> PrivateKernelCircuitPublicInputs {
6767
let constants = PrivateTxConstantData {
6868
tx_context: inputs.private_call.public_inputs.tx_context,
69+
tx_request_salt: inputs.private_call.public_inputs.tx_request_salt,
6970
vk_tree_root: inputs.vk_tree_root,
7071
protocol_contracts: inputs.protocol_contracts,
7172
anchor_block_header: inputs.private_call.public_inputs.anchor_block_header,

noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_kernel_inner/private_call_data/validate_against_previous_kernel_tests.nr

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,14 @@ fn mismatch_chain_id() {
1717

1818
builder.execute_and_fail();
1919
}
20+
21+
// A nested private call must see the same `tx_request_salt` that the Init circuit bound to the transaction request.
22+
// A malicious prover that picks a different app-visible salt for the nested call must be rejected.
23+
#[test(should_fail_with = "mismatch tx_request_salt")]
24+
fn mismatch_tx_request_salt() {
25+
let mut builder = TestBuilder::new();
26+
27+
builder.private_call.tx_request_salt += 1;
28+
29+
builder.execute_and_fail();
30+
}

noir-projects/noir-protocol-circuits/crates/private-kernel-reset-tail-to-public/Prover.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ claimed_first_nullifier = "0x02561e4f8664bc0d3a511f46ff6de210cfb9fabb320bdc418a8
188188
claimed_revertible_counter = "0x0000000000000000000000000000000000000000000000000000000000000004"
189189

190190
[previous_kernel_public_inputs.constants]
191+
tx_request_salt = "0x2deeb4d4a9cfc5a97e7403c4d21745f34e0c7971e29c38ac4a473bacbd10cac2"
191192
vk_tree_root = "0x1d81bf218cf88e95c51350b4b8de70a16798a155136d1eeb6e4f3ee05815a14d"
192193

193194
[previous_kernel_public_inputs.constants.anchor_block_header]

noir-projects/noir-protocol-circuits/crates/private-kernel-reset-tail/Prover.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ claimed_first_nullifier = "0x2cf7c5914b1b832c41d256a7bb0eeee95eb11bb95c73c4dfb76
188188
claimed_revertible_counter = "0x0000000000000000000000000000000000000000000000000000000000000004"
189189

190190
[previous_kernel_public_inputs.constants]
191+
tx_request_salt = "0x2deeb4d4a9cfc5a97e7403c4d21745f34e0c7971e29c38ac4a473bacbd10cac2"
191192
vk_tree_root = "0x1d81bf218cf88e95c51350b4b8de70a16798a155136d1eeb6e4f3ee05815a14d"
192193

193194
[previous_kernel_public_inputs.constants.anchor_block_header]

noir-projects/noir-protocol-circuits/crates/private-kernel-reset/Prover.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ claimed_first_nullifier = "0x2eb81a5a72d6816dd34b6330ce27e75a0faa44a3c8dcfb97b56
186186
claimed_revertible_counter = "0x0000000000000000000000000000000000000000000000000000000000000005"
187187

188188
[previous_kernel_public_inputs.constants]
189+
tx_request_salt = "0x2deeb4d4a9cfc5a97e7403c4d21745f34e0c7971e29c38ac4a473bacbd10cac2"
189190
vk_tree_root = "0x19e707b1c27292672391666e89b1deeeb36ab5bf508efef4f021df37bc224a21"
190191

191192
[previous_kernel_public_inputs.constants.anchor_block_header]

noir-projects/noir-protocol-circuits/crates/protocol-test-utils/src/fixture_builder.nr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ impl FixtureBuilder {
330330
PrivateTxConstantData {
331331
anchor_block_header: self.anchor_block_header,
332332
tx_context: self.tx_context,
333+
tx_request_salt: self.tx_request_salt,
333334
vk_tree_root: self.vk_tree_root,
334335
protocol_contracts: self.protocol_contracts,
335336
}

noir-projects/noir-protocol-circuits/crates/types/src/abis/private_tx_constant_data.nr

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ pub struct PrivateTxConstantData {
1919
// a situation we could be using header from a block before the upgrade took place but be using the updated
2020
// protocol to execute and prove the transaction.
2121
pub tx_context: TxContext,
22+
// The transaction request salt, kept constant so each app circuit's `tx_request_salt` can be checked against it.
23+
// Deliberately dropped by `to_tx_constant_data`, so it is never exposed beyond the private kernels.
24+
pub tx_request_salt: Field,
2225
// The root of the vk tree for the protocol circuits. Used for validating the protocol circuits being used.
2326
// This value must remain the same throughout the private execution and the rollups. It will be output from the root
2427
// rollup and checked on L1.
@@ -46,6 +49,7 @@ impl Empty for PrivateTxConstantData {
4649
PrivateTxConstantData {
4750
anchor_block_header: BlockHeader::empty(),
4851
tx_context: TxContext::empty(),
52+
tx_request_salt: 0,
4953
vk_tree_root: 0,
5054
protocol_contracts: ProtocolContracts::empty(),
5155
}

0 commit comments

Comments
 (0)