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

feat: inclusion and non-inclusion proofs experiment #3255

Merged
merged 71 commits into from
Nov 29, 2023
Merged
Changes from 1 commit
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
c37efa5
WIP
benesjan Nov 7, 2023
3da1c78
WIP
benesjan Nov 7, 2023
94f43be
WIP
benesjan Nov 7, 2023
32d2e39
minting
benesjan Nov 7, 2023
6343553
nullifying the note
benesjan Nov 7, 2023
ce3c4ab
fix after rebase
benesjan Nov 20, 2023
f159824
formatting
benesjan Nov 20, 2023
c98a5af
WIP
benesjan Nov 20, 2023
bbf4e66
fix: getPublicKeyAndPartialAddress in TypesOracle
benesjan Nov 20, 2023
e152b2c
WIP
benesjan Nov 20, 2023
af94bc9
WIP
benesjan Nov 20, 2023
e267f8d
WIP
benesjan Nov 20, 2023
7d2fab6
WIP
benesjan Nov 21, 2023
7cdd90e
WIP
benesjan Nov 21, 2023
3bf3036
fix
benesjan Nov 21, 2023
78eaadb
computing blocks hash
benesjan Nov 21, 2023
5528be5
WIP on verifying block hash
benesjan Nov 21, 2023
61a3682
fix
benesjan Nov 23, 2023
39b6011
feat: get_block_data.nr
benesjan Nov 23, 2023
227553f
finished get_block_data oracle
benesjan Nov 23, 2023
3635866
comment
benesjan Nov 24, 2023
71508b1
HistoricBlockData::block_hash()
benesjan Nov 24, 2023
eb5c260
renaming
benesjan Nov 24, 2023
508ab15
cleanup
benesjan Nov 24, 2023
cf14859
cleanup
benesjan Nov 24, 2023
b10f34c
running test in CI
benesjan Nov 24, 2023
38ba6b4
fix
benesjan Nov 24, 2023
ab2ba46
typo
benesjan Nov 24, 2023
1819c24
using blocks tree root from context
benesjan Nov 24, 2023
0016721
comment
benesjan Nov 24, 2023
61c6f85
fix
benesjan Nov 24, 2023
7360736
feat: note utils compute_siloed_nullifier
benesjan Nov 24, 2023
f407ce7
get_low_nullifier_membership_witness.nr
benesjan Nov 24, 2023
4b779af
updated get_low_nullifier_membership_witness.nr
benesjan Nov 24, 2023
1a5c4ab
WIP on proveNullifierNonInclusion
benesjan Nov 24, 2023
ec0d319
WIP
benesjan Nov 24, 2023
b9699d7
WIP
benesjan Nov 24, 2023
ff79a1f
naming fix
benesjan Nov 24, 2023
5533c1a
WIP
benesjan Nov 27, 2023
9e8890c
WIP
benesjan Nov 27, 2023
2329113
formatting
benesjan Nov 27, 2023
b298fc8
nullifier non-inclusion finished
benesjan Nov 27, 2023
4d4ecf1
updated comments
benesjan Nov 27, 2023
783b5ca
updated comments
benesjan Nov 27, 2023
5a1cbab
more consistent naming
benesjan Nov 27, 2023
9312223
overflow fix
benesjan Nov 27, 2023
c6881b0
WIP
benesjan Nov 27, 2023
976278c
fixes
benesjan Nov 27, 2023
4e29bb5
getPublicDataTreeSiblingPath
benesjan Nov 28, 2023
8dca2be
test fix
benesjan Nov 28, 2023
11bbc4d
refactor: constraining block data in a separate function
benesjan Nov 28, 2023
4b2f793
cleanup
benesjan Nov 28, 2023
17eb82d
docs fixes
benesjan Nov 28, 2023
5dd0a8b
Adding TODO
benesjan Nov 28, 2023
e10c3cb
clarified naming
benesjan Nov 28, 2023
fdca497
todo
benesjan Nov 28, 2023
acc1cb1
passing context instead of blocks tree root
benesjan Nov 28, 2023
e9769bb
forgotten TODO
benesjan Nov 28, 2023
a52985b
merkle tree id issue
benesjan Nov 28, 2023
cea9ae8
fixed TSDoc
benesjan Nov 28, 2023
c5a10e4
WIP on nullifier inclusion proof (currently broken)
benesjan Nov 28, 2023
3c89221
fix nullifier inclusion
benesjan Nov 28, 2023
df26f17
LowNullifierMembershipWitness > NullifierMembershipWitness
benesjan Nov 28, 2023
c90c3e2
test: nullifier non-inclusion proof failure case
benesjan Nov 29, 2023
1745153
feat: PrivateContext::get_block_data(...)
benesjan Nov 29, 2023
138c7ef
test: more failure cases
benesjan Nov 29, 2023
b8678ae
Merge branch 'master' into janb/liquidity-mining-experiment
benesjan Nov 29, 2023
b8a1e6c
TODOs
benesjan Nov 29, 2023
edf4628
clearer errors
benesjan Nov 29, 2023
da730d9
using Promise.all
benesjan Nov 29, 2023
52a9095
Merge branch 'master' into janb/liquidity-mining-experiment
benesjan Nov 29, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
WIP
benesjan committed Nov 28, 2023
commit af94bc96fbf61fb7f81f43a0e5e35c8a2582c942
1 change: 1 addition & 0 deletions yarn-project/aztec-nr/aztec/src/oracle.nr
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ mod call_private_function;
mod context;
mod debug_log;
mod get_l1_to_l2_message;
mod get_membership_witness;
mod get_public_key;
mod get_secret_key;
mod rand;
18 changes: 18 additions & 0 deletions yarn-project/aztec-nr/aztec/src/oracle/get_membership_witness.nr
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
use crate::constants_gen::NOTE_HASH_TREE_HEIGHT;
use crate::utils::arr_copy_slice;

struct MembershipWitness<N> {
index: Field,
path: [Field; N],
}

#[oracle(getMembershipWitness)]
fn get_membership_witness_oracle<T>(_block_number: Field, _tree_id: Field, _leaf: Field) -> [Field; T] {}

unconstrained pub fn get_membership_witness<N, T>(block_number: Field, tree_id: Field, leaf: Field) -> MembershipWitness<N> {
let fields: [Field; T] = get_membership_witness_oracle(block_number, tree_id, leaf);
MembershipWitness {
index: fields[0],
path: arr_copy_slice(fields, [0; N], 1)
}
}
Original file line number Diff line number Diff line change
@@ -16,7 +16,10 @@ contract LiquidityMining {
utils as note_utils,
},
constants_gen::NOTE_HASH_TREE_HEIGHT,
oracle::get_sibling_path::get_sibling_path,
oracle::get_membership_witness::{
get_membership_witness,
MembershipWitness,
},
// oracle::debug_log::debug_log_format,
};

@@ -27,7 +30,7 @@ contract LiquidityMining {
}

impl Storage {
fn init(context: Context) -> pub Self {
fn init(context: Context) -> Self {
Storage {
balances: Map::new(
context,
@@ -68,7 +71,7 @@ contract LiquidityMining {
// e) Prove that the block hash is in the HAT.
// f) Get the note/preimage from PXE.
// g) Compute the commitment from the note.
// h) Pop the note commitment sibling path in the note hash tree from the stack.
// h) Get the membership witness of a note in the note hash tree.
// i) Verify that the commitment is in the note hash tree.
// 2) Prove that the note has not yet been nullified by emitting a nullifier.
// 3) Use the timestamp from 1.b), current timestamp and the note amount from 1.f) to compute the reward.
@@ -90,14 +93,15 @@ contract LiquidityMining {
// 1.h)
let ignored_block_number = 0; // Oracle ignores this now and only gets the sibling path at the latest block
let note_hash_tree_id = 2;
let note_sibling_path: [Field; NOTE_HASH_TREE_HEIGHT + 1] = get_sibling_path(ignored_block_number, note_hash_tree_id, note_commitment);
let witness: MembershipWitness<NOTE_HASH_TREE_HEIGHT> =
get_membership_witness(ignored_block_number, note_hash_tree_id, note_commitment);

// 1.i)
// This should be tree root at the latest block and should correspond to the sibling path we obtain from oracle
// In our test case this should be tree root at the latest block and should correspond to the sibling path we obtain from oracle
let note_hash_tree_root = context.block_data.note_hash_tree_root;
assert(
note_hash_tree_root == compute_merkle_root(note_commitment, p.index, note_sibling_path),
"Before root don't match"
note_hash_tree_root == compute_merkle_root(note_commitment, witness.index, witness.path),
"Proving membership of a note failed"
);

// Remove/nullify the note