Skip to content

Commit

Permalink
chore: switch to brillig oracles
Browse files Browse the repository at this point in the history
  • Loading branch information
joss-aztec committed Apr 13, 2023
1 parent 566650e commit ea1d944
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit ea1d944

Please sign in to comment.