From ea1d944b6da036fe8fe70fdedf151d3ecdfba567 Mon Sep 17 00:00:00 2001 From: Joss Date: Thu, 13 Apr 2023 17:22:54 +0100 Subject: [PATCH] chore: switch to brillig oracles --- .../noir-aztec3/src/notes/value_note.nr | 17 ++++++-- .../noir-aztec3/src/state_vars/set.nr | 39 +++++++++++++++---- 2 files changed, 44 insertions(+), 12 deletions(-) diff --git a/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/notes/value_note.nr b/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/notes/value_note.nr index bb152a8d67f..9a9abfc62f7 100644 --- a/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/notes/value_note.nr +++ b/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/notes/value_note.nr @@ -2,11 +2,20 @@ use crate::types::point::Point; -#[builtin(rand)] -fn rand(_idx: Field) -> Field {} +#[oracle(rand)] +fn rand_oracle(_idx: Field) -> [Field; 2] {} + +unconstrained fn rand(idx: Field) -> Field { + rand_oracle(idx)[0] +} + +#[oracle(getSecretKey)] +fn get_secret_key_oracle(_owner: Point) -> [Field; 2] {} + +unconstrained fn get_secret_key(owner: Point) -> Field { + get_secret_key_oracle(owner)[0] +} -#[builtin(getSecretKey)] -fn get_secret_key(_owner: Point) -> Field {} struct Note { value: Field, diff --git a/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/state_vars/set.nr b/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/state_vars/set.nr index 051377651d6..1684e24cfde 100644 --- a/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/state_vars/set.nr +++ b/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/state_vars/set.nr @@ -7,26 +7,49 @@ use crate::state_vars::note_getter_data::NoteGetterData; use crate::state_vars::note_getter_data::make_note_getter_data; use crate::state_vars::note_getter_data::note_getter_data_len; -#[builtin(notifyCreatedNote)] -fn notify_created_note( +#[oracle(notifyCreatedNote)] +fn notify_created_note_oracle( _storage_slot: Field, _owner: Point, _note: Note, -) -> Field {} +) -> [Field; 2] {} -#[builtin(notifyNullifiedNote)] -fn notify_nullified_note( +unconstrained fn notify_created_note( + storage_slot: Field, + owner: Point, + note: Note, +) -> Field { + notify_created_note_oracle(storage_slot, owner, note)[0] +} + +#[oracle(notifyNullifiedNote)] +fn notify_nullified_note_oracle( _storage_slot: Field, _nullifier: Field, _note: Note, -) -> Field {} +) -> [Field; 2] {} -#[builtin(getNotes2)] -fn get_notes_2_internal( +unconstrained fn notify_nullified_note( + storage_slot: Field, + nullifier: Field, + note: Note, +) -> Field { + notify_nullified_note_oracle(storage_slot, nullifier, note)[0] +} + +#[oracle(getNotes2)] +fn get_notes_2_oracle( _contract_address: Field, _storage_slot: Field, ) -> [Field; 32] {} +unconstrained fn get_notes_2_internal( + contract_address: Field, + storage_slot: Field, +) -> [Field; 32] { + get_notes_2_oracle(contract_address, storage_slot) +} + fn get_2_notes(contract_address: Field, storage_slot: Field) -> (NoteGetterData, NoteGetterData) { let fields = get_notes_2_internal(contract_address, storage_slot); let data1 = make_note_getter_data(fields, 0);