-
Notifications
You must be signed in to change notification settings - Fork 596
Expand file tree
/
Copy pathnote_interface.nr
More file actions
62 lines (55 loc) · 2.6 KB
/
note_interface.nr
File metadata and controls
62 lines (55 loc) · 2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
use crate::context::PrivateContext;
use crate::protocol::{address::AztecAddress, traits::Empty};
// Autogenerated by the #[note] macro
pub trait NoteType {
/// Returns the unique identifier for the note type. This is typically used when processing note logs.
fn get_id() -> Field;
}
pub trait NoteHash {
/// Returns the non-siloed note hash, i.e. the inner hash computed by the contract during private execution. Note
/// hashes are later siloed by contract address and hashed with note nonce by the kernels before being committed to
/// the state tree.
///
/// This should be a commitment to the packed note, including the storage slot (for indexing) and some random value
/// (to prevent brute force trial-hashing attacks).
fn compute_note_hash(self, owner: AztecAddress, storage_slot: Field, randomness: Field) -> Field;
/// Returns the non-siloed nullifier (also called inner-nullifier), which will be later siloed by contract address
/// by the kernels before being committed to the state tree.
///
/// This function MUST be called with the correct note hash for consumption! It will otherwise silently fail and
/// compute an incorrect value. The reason why we receive this as an argument instead of computing it ourselves
/// directly is because the caller will typically already have computed this note hash, and we can reuse that value
/// to reduce the total gate count of the circuit.
///
/// This function receives the context since nullifier computation typically involves proving nullifying keys, and
/// we require the kernel's assistance to do this in order to prevent having to reveal private keys to application
/// circuits.
fn compute_nullifier(
self,
context: &mut PrivateContext,
owner: AztecAddress,
note_hash_for_nullification: Field,
) -> Field;
/// Like `compute_nullifier`, except this variant is unconstrained: there are no guarantees on the returned value
/// being correct. Because of that it doesn't need to take a context (since it won't perform any kernel key
/// validation requests).
///
/// Returns `None` if the nullifier cannot be computed (when the relevant keys needed for nullifier computation are
/// not available).
unconstrained fn compute_nullifier_unconstrained(
self,
owner: AztecAddress,
note_hash_for_nullification: Field,
) -> Option<Field>;
}
pub trait NoteProperties<T> {
fn properties() -> T;
}
pub trait PartialNote<S, F>
where
S: Empty,
F: Empty,
{
fn setup_payload() -> S;
fn finalization_payload() -> F;
}