aztec-nr - noir_aztec::context::call_interfaces

Struct PrivateCallInterface

pub struct PrivateCallInterface<let M: u32, T>
{ /* private fields */ }

Implementations

impl<let M: u32, T> PrivateCallInterface<M, T>

pub fn new( target_contract: AztecAddress, selector: FunctionSelector, name: str<M>, args: [Field], is_static: bool, ) -> Self
where T: Deserialize
pub fn call(self, context: &mut PrivateContext) -> T
where T: Deserialize

Makes the call to this private function.

Arguments

  • context - The PrivateContext -- made magically available to the body of every #[private] function as context, through the #[private] annotation's macro.

Returns

  • T - Whatever data the called function has returned.

This enables contracts to interact with each other while maintaining privacy. This "composability" of private contract functions is a key feature of the Aztec network.

If a user's transaction includes multiple private function calls, then by the design of Aztec, the following information will remain private[1]:

  • The function selectors and contract addresses of all private function calls will remain private, so an observer of the public mempool will not be able to look at a tx and deduce which private functions have been executed.
  • The arguments and return values of all private function calls will remain private.
  • The person who initiated the tx will remain private.
  • The notes and nullifiers and private logs that are emitted by all private function calls will (if designed well) not leak any user secrets, nor leak which functions have been executed.

[1] Caveats: Some of these privacy guarantees depend on how app developers design their smart contracts. Some actions can leak information, such as:

  • Calling an internal public function.
  • Calling a public function and not setting msg_sender to Option::none (see https://github.com/AztecProtocol/aztec-packages/pull/16433)
  • Calling any public function will always leak details about the nature of the transaction, so devs should be careful in their contract designs. If it can be done in a private function, then that will give the best privacy.
  • Not padding the side-effects of a tx to some standardised, uniform size. The kernel circuits can take hints to pad side-effects, so a wallet should be able to request for a particular amount of padding. Wallets should ideally agree on some standard.
    • Padding should include:
      • Padding the lengths of note & nullifier arrays
      • Padding private logs with random fields, up to some standardised size. See also: https://docs.aztec.network/developers/reference/considerations/privacy_considerations

Advanced

  • The call is added to the private call stack and executed by kernel circuits after this function completes
  • The called function can modify its own contract's private state
  • Side effects from the called function are included in this transaction
  • The call inherits the current transaction's context and gas limits

Arguments

  • context - The PrivateContext -- made magically available to the body of every #[private] function as context, through the #[private] annotation's macro.

Returns

  • T - Whatever data the called function has returned.
pub fn view(self, context: &mut PrivateContext) -> T
where T: Deserialize

Makes a read-only call to this private function.

This is similar to Solidity's staticcall. The called function cannot modify state, emit L2->L1 messages, nor emit events. Any nested calls are constrained to also be staticcalls.

See call for more general info on private function calls.

Arguments

  • context - The PrivateContext -- made magically available to the body of every #[private] function as context, through the #[private] annotation's macro.

Returns

  • T - Whatever data the called function has returned.

Trait implementations

impl<let M: u32, T> CallInterface<M> for PrivateCallInterface<M, T>

pub fn get_args(self) -> [Field] pub fn get_selector(self) -> FunctionSelector pub fn get_name(self) -> str<M> pub fn get_contract_address(self) -> AztecAddress pub fn get_is_static(self) -> bool