-
Notifications
You must be signed in to change notification settings - Fork 236
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Migrate the init kernel CPP tests to noir (#3091)
Please provide a paragraph or two giving a summary of the change, including relevant motivation and context. # Checklist: Remove the checklist to signal you've completed it. Enable auto-merge if the PR is ready to merge. - [ ] If the pull request requires a cryptography review (e.g. cryptographic algorithm implementations) I have added the 'crypto' tag. - [ ] I have reviewed my diff in github, line by line and removed unexpected formatting changes, testing logs, or commented-out code. - [ ] Every change is related to the PR description. - [ ] I have [linked](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue) this pull request to relevant issues (if any exist).
- Loading branch information
1 parent
ebda5fc
commit 906429f
Showing
13 changed files
with
9,810 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4,399 changes: 4,399 additions & 0 deletions
4,399
yarn-project/noir-private-kernel/src/__snapshots__/noir_test_gen.test.ts.snap
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
510 changes: 510 additions & 0 deletions
510
yarn-project/noir-private-kernel/src/crates/private-kernel-lib/src/private_kernel_init.nr
Large diffs are not rendered by default.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
yarn-project/noir-private-kernel/src/crates/private-kernel-lib/src/tests.nr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
mod testing_harness; | ||
mod apps; | ||
mod read_requests; |
2 changes: 2 additions & 0 deletions
2
yarn-project/noir-private-kernel/src/crates/private-kernel-lib/src/tests/apps.nr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
mod deposit; | ||
mod constructor; |
12 changes: 12 additions & 0 deletions
12
yarn-project/noir-private-kernel/src/crates/private-kernel-lib/src/tests/apps/constructor.nr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
use crate::{ | ||
abis::private_circuit_public_inputs::PrivateCircuitPublicInputs, | ||
tests::testing_harness::{PrivateCircuitPublicInputsBuilder, PrivateAppInputs}, | ||
utils::uint128::U128, | ||
hash::NUM_FIELDS_PER_SHA256, | ||
}; | ||
|
||
struct ConstructorParams {} | ||
|
||
pub fn constructor_app(inputs: PrivateAppInputs, params: ConstructorParams) -> PrivateCircuitPublicInputs { | ||
PrivateCircuitPublicInputsBuilder::new(inputs).finish() | ||
} |
39 changes: 39 additions & 0 deletions
39
yarn-project/noir-private-kernel/src/crates/private-kernel-lib/src/tests/apps/deposit.nr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
use crate::{ | ||
abis::private_circuit_public_inputs::PrivateCircuitPublicInputs, | ||
tests::testing_harness::{PrivateCircuitPublicInputsBuilder, PrivateAppInputs}, | ||
utils::uint128::U128, | ||
hash::NUM_FIELDS_PER_SHA256, | ||
}; | ||
|
||
global BALANCES_SLOT = 1; | ||
|
||
struct DepositParams { | ||
amount: Field, | ||
asset_id: Field, | ||
memo: Field, | ||
encrypted_logs_hash : [U128; NUM_FIELDS_PER_SHA256], | ||
unencrypted_logs_hash : [U128; NUM_FIELDS_PER_SHA256], | ||
encrypted_log_preimages_length : Field, | ||
unencrypted_log_preimages_length : Field, | ||
} | ||
|
||
pub fn deposit_app(inputs: PrivateAppInputs, params: DepositParams) -> PrivateCircuitPublicInputs { | ||
let msg_sender = inputs.call_context.msg_sender; | ||
|
||
let mut context = PrivateCircuitPublicInputsBuilder::new(inputs); | ||
|
||
|
||
let user_balance_slot = dep::std::hash::pedersen_hash([BALANCES_SLOT, params.asset_id, msg_sender.to_field()]); | ||
|
||
let commitment = dep::std::hash::pedersen_hash([user_balance_slot, params.amount, msg_sender.to_field(), params.memo]); | ||
|
||
context.new_commitments.push(commitment); | ||
|
||
context.encrypted_logs_hash = params.encrypted_logs_hash.map(|uint: U128| uint.to_field()); | ||
context.unencrypted_logs_hash = params.unencrypted_logs_hash.map(|uint: U128| uint.to_field()); | ||
|
||
context.encrypted_log_preimages_length = params.encrypted_log_preimages_length; | ||
context.unencrypted_log_preimages_length = params.unencrypted_log_preimages_length; | ||
|
||
context.finish() | ||
} |
4,356 changes: 4,356 additions & 0 deletions
4,356
yarn-project/noir-private-kernel/src/crates/private-kernel-lib/src/tests/read_requests.nr
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.