bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 75쪽 중 47쪽
authwit. The account contract requests the witness from Alice via an oracle, validates it, and returns the result.
<!-- -->
Static calls for security
The authwit verification uses a static call to the account contract. This prevents the account from re-entering the flow and modifying state during verification.
### Public authwit flow[](#public-authwit-flow "Direct link to Public authwit flow")
In public execution, oracles aren't available since the sequencer runs the code. Instead, authorizations are stored in a shared registry before use.
<!-- -->
The registry approach has a gas optimization: if authorization is set and consumed in the same transaction, the state changes cancel out, saving gas.
Why use Auth Registry for signatures in public?
ECDSA signature verification is not directly available in public functions due to AVM limitations. The public authwit flow above is the recommended pattern: verify signatures in private, store approvals in the Auth Registry, and consume them in public. See [AVM Cryptographic Compatibility](/developers/testnet/docs/foundational-topics/advanced/circuits/avm_compatibility.md) for more details.
### Replay prevention[](#replay-prevention "Direct link to Replay prevention")
Each authwit can only be used once. The consuming contract emits a nullifier for the action, preventing reuse. This is similar to how notes work.
To allow the same action multiple times (e.g., repeated transfers of the same amount), include a nonce in the arguments:
```
inner_hash = H(defi, transfer_selector, H(alice_account, defi, 1000, nonce));
```
The account contract cannot emit the nullifier (it's called via static call), so the consuming contract handles this. The authwit library manages this automatically.
### Cancelling authwits[](#cancelling-authwits "Direct link to Cancelling authwits")
You can cancel an authwit before it's used by emitting its nullifier directly. This invalidates the authwit without executing the authorized action:
```
fn cancel_authwit(inner_hash: Field) {
let on_behalf_of = self.msg_sender();
let nullifier = compute_authwit_nullifier(on_behalf_of, inner_hash);
self.context.push_nullifier_unsafe(nullifier);
}
```
## Differences from ERC20 approvals[](#differences-from-erc20-approvals "Direct link to Differences from ERC20 approvals")
| Aspect | ERC20 Approve | Authwit |
| -------------- | ------------------------------- | -------------------------- |
| Scope | Blanket allowance | Specific action |
| User awareness | Often unclear amounts | Exact action visible |
| Revocation | Requires transaction | Can cancel with nullifier |
| Private state | Cannot work (need note secrets) | Works via account contract |
Private authwits and note secrets
While authwits authorize a contract to perform an action, spending private notes still requires knowledge of the note secrets. For private tokens, the note owner must be involved in the transaction—they cannot simply give another user an authwit and have that user spend the notes independently.
## Use cases[](#use-cases "Direct link to Use cases")
Authwits work for any function requiring third-party authorization:
* Token transfers and burns
* DeFi deposits and withdrawals
* Governance voting
* Bridge operations (public to private transfers)
* Any contract interaction requiring user approval
## Implementation[](#implementation "Direct link to Implementation")
Use the `#[authorize_once]` macro to add authwit verification to your contract functions:
```
#[authorize_once("from", "authwit_nonce")]
#[external("private")]
fn transfer_in_private(
from: AztecAddress,
to: AztecAddress,
amount: u128,
authwit_nonce: Field,
) {
// Transfer logic here
}
```
The macro handles authwit verification and nullifier emission automatically.
For complete implementation details, see the [developer documentation](/developers/testnet/docs/aztec-nr/framework-description/authentication_witnesses.md).
---
# Circuits
Central to Aztec's operations are 'circuits' derived both from the core protocol and the developer-written Aztec.nr contracts.
The core circuits enhance privacy by adding additional security checks and preserving transaction details - a characteristic Ethereum lacks.
On this page, you’ll learn a bit more about these circuits and their integral role in promoting secure and efficient transactions within Aztec's privacy-centric framework.
## Motivation[](#motivation "Direct link to Motivation")
In Aztec, circuits come from two sources:
1. Core protocol circuits
2. User-written circuits (written as Aztec.nr Contracts and deployed to the network)
This page focuses on the core protocol circuits. These circuits check that the rules of the protocol are being adhered to.
When a function in an Ethereum smart contract is executed, the EVM performs checks to ensure that Ethereum's transaction rules are being adhered-to correctly. Stuff like:
* "Does this tx have a valid signature?"
* "Does this contract address contain deployed code?"
* "Does this function exist in the requested contract?"
* "Is this function allowed to call this function?"
* "How much gas has been paid, and how much is left?"
* "Is this contract allowed to read/update this state variable?"
* "Perform the state read / state write"
* "Execute these opcodes"
All of these checks have a computational cost, for which users are charged gas.
Many existing L2s move this logic offchain, as a way of saving their users gas costs, and as a way of increasing tx throughput.
zk-Rollups, in particular, move these checks offchain by encoding them in zk-S(N/T)ARK circuits. Rather than paying a committee of Ethereum validators to perform the above kinds of checks, L2 users instead pay a sequencer to execute these checks via the circuit(s) which encode them. The sequencer can then generate a zero-knowledge proof of having executed the circuit(s) correctly, which they can send to a rollup contract on Ethereum. The Ethereum validators then verify this zk-S(N/T)ARK. It often turns out to be much cheaper for users to pay the sequencer to do this, than to execute a smart contract on Ethereum directly.
But there's a problem.
Ethereum (and the EVM) doesn't have a notion of privacy.
* There is no notion of a private state variable in the EVM.
* There is no notion of a private function in the EVM.
So users cannot keep private state variables' values private from Ethereum validators, nor from existing (non-private) L2 sequencers. Nor can users keep the details of which function they've executed private from validators or sequencers.
How does Aztec add privacy?
Well, we just encode *extra* checks in our zk-Rollup's zk-SNARK circuits! These extra checks introduce the notions of private state and private functions, and enforce privacy-preserving constraints on every transaction being sent to the network.
In other words, since neither the EVM nor other rollups have rules for how to preserve privacy, we've written a new rollup which introduces such rules, and we've written circuits to enforce those rules!
What kind of extra rules / checks does a rollup need, to enforce notions of private states and private functions? Stuff like:
* "Perform state reads and writes using new tree structures which prevent tx linkability" (see [indexed merkle tree](/developers/testnet/docs/foundational-topics/advanced/storage/indexed_merkle_tree.md).
* "Hide which function was just executed, by wrapping it in a zk-snark"
* "Hide all functions which were executed as part of this tx's stack trace, by wrapping the whole tx in a zk-snark"
## Aztec core protocol circuits[](#aztec-core-protocol-circuits "Direct link to Aztec core protocol circuits")
So what kinds of core protocol circuits does Aztec have?
### Kernel, Rollup, and Squisher Circuits[](#kernel-rollup-and-squisher-circuits "Direct link to Kernel, Rollup, and Squisher Circuits")
The specs of these have recently been updated. Eg for squisher circuits since Honk and Goblin Plonk schemes are still being improved! But we'll need some extra circuit(s) to squish a Honk proof (as produced by the Root Rollup Circuit) into a Standard Plonk or Fflonk proof, for cheap verification on Ethereum.
---
# AVM Cryptographic Compatibility
Private and public functions in Aztec use different execution models. Private functions compile to ACIR circuits and have access to the full Noir standard library. Public functions compile to AVM bytecode via the transpiler, which supports only a specific set of cryptographic operations.
## Compatibility Table[](#compatibility-table "Direct link to Compatibility Table")
The table below lists the low-level blackbox operations and whether they are available in the AVM. Higher-level Noir standard library functions (like `sha256::sha256_var`, `keccak256::keccak256`, `poseidon2::hash`, and `std::hash::pedersen_hash`) are built on these primitives and work in public functions when the underlying operations are supported.
| Noir Primitive | Private (ACIR) | Public (AVM) | Notes |
| --------------------------- | -------------- | ----------------- | ------------------------------------------- |
| Poseidon2 Permutation | Supported | Supported | `POSEIDON2PERM` opcode |
| Pedersen Hash / Commitment | Supported | Supported | Lowered to `ECADD` and `MSM` operations |
| SHA-256 Compression | Supported | Supported | `SHA256COMPRESSION` opcode |
| Keccak f1600 | Supported | Supported | `KECCAKF1600` opcode |
| Embedded Curve Add | Supported | Supported | `ECADD` opcode (Grumpkin curve) |
| Multi-Scalar Multiplication | Supported | Supported | Lowered to `TORADIXBE` + `ECADD` operations |
| ToRadix | Supported | Supported | `TORADIXBE` opcode |
| ECDSA secp256k1 | Supported | **Not supported** | Transpiler panics |
| ECDSA secp256r1 | Supported | **Not supported** | Transpiler panics |
| AES-128 Encrypt | Supported | **Not supported** | Transpiler panics |
| Blake2s | Supported | **Not supported** | Transpiler panics |
| Blake3 | Supported | **Not supported** | Transpiler panics |
## Why the Difference[](#why-the-difference "Direct link to Why the Difference")
Private functions are compiled to ACIR (Abstract Circuit Intermediate Representation), which supports the full set of Noir standard library blackbox functions. These are evaluated as part of the zk-SNARK proof generation on the user's device.
Public functions are compiled to AVM bytecode via the transpiler. The AVM has a fixed instruction set, and each supported cryptographic operation must either have a dedicated opcode or be reducible to a sequence of supported opcodes. For example, multi-scalar multiplication has no dedicated opcode but is lowered to `TORADIXBE` and `ECADD` instructions. Operations that cannot be mapped to supported opcodes cannot be transpiled.
## What Error Will I See?[](#what-error-will-i-see "Direct link to What Error Will I See?")
If you use an unsupported blackbox function in a `#[external("public")]` function, the transpiler will panic at compile time with a message like:
```
Transpiler doesn't know how to process EcdsaSecp256k1
```
where the final token is the name of the unsupported `BlackBoxOp` variant (e.g. `AES128Encrypt`, `Blake2s`, `Blake3`).
## Signature Verification in Public: Workarounds[](#signature-verification-in-public-workarounds "Direct link to Signature Verification in Public: Workarounds")
Since ECDSA signature verification is not available in public functions, use the **Authentication Registry** pattern:
1. Verify signatures in a **private** function (where all Noir primitives are available)
2. Store approval hashes in the **Auth Registry** (a shared public contract)
3. Consume the approvals in **public** functions
This is exactly how public authwits work. See [Authentication Witnesses](/developers/testnet/docs/foundational-topics/advanced/authwit.md) for the full pattern.
Schnorr signatures
The [`noir-lang/schnorr`](https://github.com/noir-lang/schnorr) library implements Schnorr verification in pure Noir using embedded curve operations (ECADD, MSM), which are supported in the AVM. This means Schnorr verification may work in public functions. However, the standard Aztec account contracts only use Schnorr in private functions, and the recommended pattern remains verifying signatures in private via the Auth Registry.
## ISA Reference[](#isa-reference "Direct link to ISA Reference")
For the complete list of AVM opcodes, see the [AVM ISA Quick Reference](https://github.com/aztec-labs-eng/aztec-node/blob/v6.0.0-rc.1/yarn-project/simulator/docs/avm/avm-isa-quick-reference.md).
## Related Pages[](#related-pages "Direct link to Related Pages")
* [Public Execution (AVM)](/developers/testnet/docs/foundational-topics/advanced/circuits/public_execution.md) – How the AVM executes public functions
* [Authentication Witnesses](/developers/testnet/docs/foundational-topics/advanced/authwit.md) – The Auth Registry pattern for public authorization
* [Call Types](/developers/testnet/docs/foundational-topics/call_types.md) – How private and public functions interact
* [Private Kernel](/developers/testnet/docs/foundational-topics/advanced/circuits/private_kernel.md) – How private functions are processed
---
# Private Kernel Circuit
The private kernel circuit is executed by the user on their own device. This ensures private inputs remain private.
note
This is the only core protocol circuit that truly requires the "zero-knowledge" property. Other circuits use SNARKs for succinct verification, but don't need to hide witness data. The private kernel must hide: the contract function executed, the user's address, and the function's inputs and outputs.
## Overview[](#overview "Direct link to Overview")
The private kernel processes all private function calls in a transaction, accumulating their side effects (note hashes, nullifiers, logs, messages) and validation requests. It runs recursively—once per private function call—building up a proof that all private execution was correct.
The kernel validates:
* Proof of private function execution
* Correct call context (caller, address, arguments)
* Proper scoping of side effects to their originating contract
* Uniqueness and ordering of side effect counters
## Kernel Phases[](#kernel-phases "Direct link to Kernel Phases")
The private kernel consists of five circuit types:
### Init[](#init "Direct link to Init")
The entry point for private kernel execution. It processes the first private function call in a transaction and validates:
* The call matches the transaction request (origin, function, arguments)
* The function is marked as private
* No msg\_sender exists (first call has no caller)
### Inner[](#inner "Direct link to Inner")
Processes subsequent private function calls after init. Can chain multiple times as the call stack grows. It:
* Verifies the previous kernel proof
* Pops the next call from the private call stack
* Validates the call matches its request
* Appends new side effects to accumulated data
### Reset[](#reset "Direct link to Reset")
Can be called one or more times at any point after init and before tail/tail-to-public. Optimizes the accumulated data by:
* Squashing transient note hash/nullifier pairs (where a note is created and nullified within the same transaction) along with their associated logs
* Validating note hash and nullifier read requests against the state
* Validating key validation requests
This circuit reduces the data size before finalization.
### Tail[](#tail "Direct link to Tail")
The final circuit for **private-only** transactions (no public function calls). It:
* Sorts remaining side effects
* Converts accumulated data to rollup format
* Produces output ready for rollup aggregation
### Tail to Public[](#tail-to-public "Direct link to Tail to Public")
The bridge circuit for transactions with both private and public execution. It:
* Splits side effects into non-revertible and revertible arrays
* Prepares data for public execution
* Handles the transition from private to public phases
## Data Flow[](#data-flow "Direct link to Data Flow")
As the kernel processes each private call, it accumulates:
| Data Type | Description |
| -------------------- | --------------------------------------------------- |
| Note hashes | Commitments to new private notes |
| Nullifiers | Markers that invalidate notes or provide uniqueness |
| L2 to L1 messages | Cross-chain messages to Ethereum |
| Private logs | Encrypted event data |
| Public call requests | Queued public function calls |
Each item is scoped with the contract address that emitted it, ensuring proper attribution.
## Performance Impact[](#performance-impact "Direct link to Performance Impact")
The kernel circuits add significant overhead to every transaction. Understanding this overhead is important when designing contracts and profiling performance.
### Gate counts per phase[](#gate-counts-per-phase "Direct link to Gate counts per phase")
Consider a typical transaction where a user calls a single contract function. This actually involves **two** private function calls — the account entrypoint (e.g. `SchnorrAccount:entrypoint`) and your contract function — so the kernel processes both:
```
Account entrypoint: 22,000 gates (1st private call → processed by init)
Your function: 14,000 gates (2nd private call → processed by inner)
private_kernel_init: ~46,000 gates
private_kernel_inner: ~101,000 gates
private_kernel_reset: ~200,000 gates
private_kernel_tail: ~44,000 gates
─────────────────────────────────────
Total transaction: ~427,000 gates
```
The init circuit handles the first private function call (the account entrypoint), and inner handles each subsequent one. The exact kernel gate counts vary depending on the transaction's complexity (number of note hashes, nullifiers, read requests, etc.), but the key takeaway is: **kernel overhead is substantial and scales with the number of private function calls**.
Each additional private function call in a transaction adds at least one more kernel inner circuit (\~101k gates). This means that architectural decisions — like whether to inline logic into one function vs. splitting across multiple function calls — can have a significant impact on total proving time.
Design tip
When profiling shows high gate counts, consider whether you can reduce the number of distinct private function calls in your transaction. For example, inlining a verification step into the calling function saves an entire kernel fold (\~101k gates), even if it slightly increases the calling function's own gate count.
Large circuits do not prevent transaction inclusion
A contract with a high gate count is **not** uncallable. The only effect of a large circuit is that it takes longer to prove on the client. Your transaction will still be included in a block as long as it is valid by the time the proof is submitted.
In practice, there are only two edge cases where slow proving could cause issues:
1. **Transaction expiry**: If proving takes so long (e.g. over an hour) that the transaction becomes invalid by the time you're done. This is unlikely for most use cases.
2. **Fee volatility**: If network fees increase rapidly while you're proving, your transaction may be underpriced by the time it's broadcast. This is similar to signing an Ethereum transaction and waiting before submitting it. You can mitigate this by overpaying for fees if rapid inclusion is a priority.
One of the major benefits of Aztec is that private computation is proven client-side: you can do as much computation as you want in private functions — the network cost is the same regardless.
For tools to measure these costs, see the [profiling guide](/developers/testnet/docs/aztec-nr/framework-description/advanced/how_to_profile_transactions.md).
## Related Pages[](#related-pages "Direct link to Related Pages")
* [Transactions](/developers/testnet/docs/foundational-t프로젝트로 돌아가기