PrivateContext
When finished, one can call .finish() to convert back to the abi
Fields
Field | Type |
---|---|
inputs | PrivateContextInputs |
side_effect_counter | u32 |
min_revertible_side_effect_counter | u32 |
is_fee_payer | bool |
args_hash | Field |
return_hash | Field |
max_block_number | MaxBlockNumber |
note_hash_read_requests | BoundedVec<ReadRequest, MAX_NOTE_HASH_READ_REQUESTS_PER_CALL> |
nullifier_read_requests | BoundedVec<ReadRequest, MAX_NULLIFIER_READ_REQUESTS_PER_CALL> |
key_validation_requests_and_generators | BoundedVec<KeyValidationRequestAndGenerator, MAX_KEY_VALIDATION_REQUESTS_PER_CALL> |
new_note_hashes | BoundedVec<NoteHash, MAX_NEW_NOTE_HASHES_PER_CALL> |
new_nullifiers | BoundedVec<Nullifier, MAX_NEW_NULLIFIERS_PER_CALL> |
private_call_requests | BoundedVec<PrivateCallRequest, MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL> |
public_call_stack_hashes | BoundedVec<Field, MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL> |
public_teardown_function_hash | Field |
new_l2_to_l1_msgs | BoundedVec<L2ToL1Message, MAX_NEW_L2_TO_L1_MSGS_PER_CALL> |
historical_header | Header |
note_encrypted_logs_hashes | BoundedVec<NoteLogHash, MAX_NOTE_ENCRYPTED_LOGS_PER_CALL> |
encrypted_logs_hashes | BoundedVec<EncryptedLogHash, MAX_ENCRYPTED_LOGS_PER_CALL> |
unencrypted_logs_hashes | BoundedVec<LogHash, MAX_UNENCRYPTED_LOGS_PER_CALL> |
last_key_validation_requests | Option<KeyValidationRequest>; NUM_KEY_TYPES] |
Methods
new
PrivateContext::new(inputs, args_hash);
Parameters
Name | Type |
---|---|
inputs | PrivateContextInputs |
args_hash | Field |
msg_sender
PrivateContext::msg_sender(self);
Parameters
Name | Type |
---|---|
self |
this_address
PrivateContext::this_address(self);
Parameters
Name | Type |
---|---|
self |
chain_id
PrivateContext::chain_id(self);
Parameters
Name | Type |
---|---|
self |
version
PrivateContext::version(self);
Parameters
Name | Type |
---|---|
self |
selector
PrivateContext::selector(self);
Parameters
Name | Type |
---|---|
self |
get_args_hash
PrivateContext::get_args_hash(self);
Parameters
Name | Type |
---|---|
self |
push_new_note_hash
PrivateContext::push_new_note_hash(&mut self, note_hash);
Parameters
Name | Type |
---|---|
&mut self | |
note_hash | Field |
push_new_nullifier
TODO(#7112): This function is called with non-zero note hash only in 1 of 25 cases in aztec-packages repo - consider creating a separate function with 1 arg for the zero note hash case.
PrivateContext::push_new_nullifier(&mut self, nullifier, nullified_note_hash);
Parameters
Name | Type |
---|---|
&mut self | |
nullifier | Field |
nullified_note_hash | Field |
get_header
Returns the header of a block whose state is used during private execution (not the block the transaction is included in).
PrivateContext::get_header(self);
Parameters
Name | Type |
---|---|
self |
get_header_at
Returns the header of an arbitrary block whose block number is less than or equal to the block number of historical header.
PrivateContext::get_header_at(self, block_number);
Parameters
Name | Type |
---|---|
self | |
block_number | u32 |
set_return_hash
PrivateContext::set_return_hash(&mut self, returns_hasher);
Parameters
Name | Type |
---|---|
&mut self | |
returns_hasher | ArgsHasher |
finish
PrivateContext::finish(self);
Parameters
Name | Type |
---|---|
self |
set_as_fee_payer
PrivateContext::set_as_fee_payer(&mut self);
Parameters
Name | Type |
---|---|
&mut self |
end_setup
PrivateContext::end_setup(&mut self);
Parameters
Name | Type |
---|---|
&mut self |
set_tx_max_block_number
PrivateContext::set_tx_max_block_number(&mut self, max_block_number);
Parameters
Name | Type |
---|---|
&mut self | |
max_block_number | u32 |
push_note_hash_read_request
PrivateContext::push_note_hash_read_request(&mut self, note_hash);
Parameters
Name | Type |
---|---|
&mut self | |
note_hash | Field |
push_nullifier_read_request
PrivateContext::push_nullifier_read_request(&mut self, nullifier);
Parameters
Name | Type |
---|---|
&mut self | |
nullifier | Field |
request_nsk_app
PrivateContext::request_nsk_app(&mut self, npk_m_hash);
Parameters
Name | Type |
---|---|
&mut self | |
npk_m_hash | Field |
request_ovsk_app
PrivateContext::request_ovsk_app(&mut self, ovpk_m_hash);
Parameters
Name | Type |
---|---|
&mut self | |
ovpk_m_hash | Field |
request_sk_app
PrivateContext::request_sk_app(&mut self, pk_m_hash, key_index);
Parameters
Name | Type |
---|---|
&mut self | |
pk_m_hash | Field |
key_index | Field |
message_portal
PrivateContext::message_portal(&mut self, recipient, content);
Parameters
Name | Type |
---|---|
&mut self | |
recipient | EthAddress |
content | Field |
consume_l1_to_l2_message
PrivateContext::consume_l1_to_l2_message(&mut self, content, secret, sender);
Parameters
Name | Type |
---|---|
&mut self | |
content | Field |
secret | Field |
sender | EthAddress |
emit_unencrypted_log
TODO: We might want to remove this since emitting unencrypted logs from private functions is violating privacy. --> might be a better approach to force devs to make a public function call that emits the log if needed then it would be less easy to accidentally leak information. If we decide to keep this function around would make sense to wait for traits and then merge it with emit_unencrypted_log.
PrivateContext::emit_unencrypted_log(&mut self, log);
Parameters
Name | Type |
---|---|
&mut self | |
log | T |
emit_contract_class_unencrypted_log
This fn exists separately from emit_unencrypted_log because sha hashing the preimage is too large to compile (16,200 fields, 518,400 bytes) => the oracle hashes it It is ONLY used with contract_class_registerer_contract since we already assert correctness: - Contract class -> we will commit to the packed bytecode (currently a TODO) - Private function -> we provide a membership proof - Unconstrained function -> we provide a membership proof Ordinary logs are not protected by the above so this fn shouldn't be called by anything else
PrivateContext::emit_contract_class_unencrypted_log(&mut self, log);
Parameters
Name | Type |
---|---|
&mut self | |
log | [Field; N] |
emit_raw_event_log_with_masked_address
NB: A randomness value of 0 signals that the kernels should not mask the contract address used in siloing later on e.g. 'handshaking' contract w/ known address.
PrivateContext::emit_raw_event_log_with_masked_address(&mut self, randomness, encrypted_log);
Parameters
Name | Type |
---|---|
&mut self | |
randomness | Field |
encrypted_log | [u8; M] |
emit_raw_note_log
PrivateContext::emit_raw_note_log(&mut self, note_hash_counter, encrypted_log);
Parameters
Name | Type |
---|---|
&mut self | |
note_hash_counter | u32 |
encrypted_log | [u8; M] |
call_private_function
PrivateContext::call_private_function(&mut self, contract_address, function_selector, args);
Parameters
Name | Type |
---|---|
&mut self | |
contract_address | AztecAddress |
function_selector | FunctionSelector |
args | [Field; ARGS_COUNT] |
static_call_private_function
PrivateContext::static_call_private_function(&mut self, contract_address, function_selector, args);
Parameters
Name | Type |
---|---|
&mut self | |
contract_address | AztecAddress |
function_selector | FunctionSelector |
args | [Field; ARGS_COUNT] |
delegate_call_private_function
PrivateContext::delegate_call_private_function(&mut self, contract_address, function_selector, args);
Parameters
Name | Type |
---|---|
&mut self | |
contract_address | AztecAddress |
function_selector | FunctionSelector |
args | [Field; ARGS_COUNT] |
call_private_function_no_args
PrivateContext::call_private_function_no_args(&mut self, contract_address, function_selector);
Parameters
Name | Type |
---|---|
&mut self | |
contract_address | AztecAddress |
function_selector | FunctionSelector |
static_call_private_function_no_args
PrivateContext::static_call_private_function_no_args(&mut self, contract_address, function_selector);
Parameters
Name | Type |
---|---|
&mut self | |
contract_address | AztecAddress |
function_selector | FunctionSelector |
delegate_call_private_function_no_args
PrivateContext::delegate_call_private_function_no_args(&mut self, contract_address, function_selector);
Parameters
Name | Type |
---|---|
&mut self | |
contract_address | AztecAddress |
function_selector | FunctionSelector |
call_private_function_with_packed_args
PrivateContext::call_private_function_with_packed_args(&mut self, contract_address, function_selector, args_hash, is_static_call, is_delegate_call);
Parameters
Name | Type |
---|---|
&mut self | |
contract_address | AztecAddress |
function_selector | FunctionSelector |
args_hash | Field |
is_static_call | bool |
is_delegate_call | bool |
call_public_function
PrivateContext::call_public_function(&mut self, contract_address, function_selector, args);
Parameters
Name | Type |
---|---|
&mut self | |
contract_address | AztecAddress |
function_selector | FunctionSelector |
args | [Field; ARGS_COUNT] |
static_call_public_function
PrivateContext::static_call_public_function(&mut self, contract_address, function_selector, args);
Parameters
Name | Type |
---|---|
&mut self | |
contract_address | AztecAddress |
function_selector | FunctionSelector |
args | [Field; ARGS_COUNT] |
delegate_call_public_function
PrivateContext::delegate_call_public_function(&mut self, contract_address, function_selector, args);
Parameters
Name | Type |
---|---|
&mut self | |
contract_address | AztecAddress |
function_selector | FunctionSelector |
args | [Field; ARGS_COUNT] |
call_public_function_no_args
PrivateContext::call_public_function_no_args(&mut self, contract_address, function_selector);
Parameters
Name | Type |
---|---|
&mut self | |
contract_address | AztecAddress |
function_selector | FunctionSelector |
static_call_public_function_no_args
PrivateContext::static_call_public_function_no_args(&mut self, contract_address, function_selector);
Parameters
Name | Type |
---|---|
&mut self | |
contract_address | AztecAddress |
function_selector | FunctionSelector |
delegate_call_public_function_no_args
PrivateContext::delegate_call_public_function_no_args(&mut self, contract_address, function_selector);
Parameters
Name | Type |
---|---|
&mut self | |
contract_address | AztecAddress |
function_selector | FunctionSelector |
call_public_function_with_packed_args
PrivateContext::call_public_function_with_packed_args(&mut self, contract_address, function_selector, args_hash, is_static_call, is_delegate_call);
Parameters
Name | Type |
---|---|
&mut self | |
contract_address | AztecAddress |
function_selector | FunctionSelector |
args_hash | Field |
is_static_call | bool |
is_delegate_call | bool |
set_public_teardown_function
PrivateContext::set_public_teardown_function(&mut self, contract_address, function_selector, args);
Parameters
Name | Type |
---|---|
&mut self | |
contract_address | AztecAddress |
function_selector | FunctionSelector |
args | [Field; ARGS_COUNT] |
set_public_teardown_function_with_packed_args
PrivateContext::set_public_teardown_function_with_packed_args(&mut self, contract_address, function_selector, args_hash, is_static_call, is_delegate_call);
Parameters
Name | Type |
---|---|
&mut self | |
contract_address | AztecAddress |
function_selector | FunctionSelector |
args_hash | Field |
is_static_call | bool |
is_delegate_call | bool |
validate_call_stack_item_from_oracle
PrivateContext::validate_call_stack_item_from_oracle(self, item, contract_address, function_selector, args_hash, is_static_call, is_delegate_call);
Parameters
Name | Type |
---|---|
self | |
item | PublicCallStackItem |
contract_address | AztecAddress |
function_selector | FunctionSelector |
args_hash | Field |
is_static_call | bool |
is_delegate_call | bool |
next_counter
PrivateContext::next_counter(&mut self);
Parameters
Name | Type |
---|---|
&mut self |
Standalone Functions
empty
empty();
Takes no parameters.