Skip to content

Commit cf97fb4

Browse files
authored
chore: Accumulated backports to v4-next (#22060)
BEGIN_COMMIT_OVERRIDE chore: rename pxe-side oracle implementations (#22044) chore: rename pxe-side oracle implementations (#22044) (#22051) docs: document AVM cryptographic compatibility for public vs private (#21814) END_COMMIT_OVERRIDE
2 parents 8be945d + 48f9044 commit cf97fb4

File tree

92 files changed

+1364
-383
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+1364
-383
lines changed

barretenberg/cpp/src/barretenberg/api/file_io.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ inline void write_file(const std::string& filename, std::vector<uint8_t> const&
6969
size_t total_written = 0;
7070
size_t data_size = data.size();
7171
while (total_written < data_size) {
72-
auto written = ::write(fd, data.data() + total_written, data_size - total_written);
72+
auto written =
73+
::write(fd, data.data() + total_written, static_cast<unsigned int>(data_size - total_written));
7374
if (written == -1) {
7475
close(fd);
7576
THROW std::runtime_error("Failed to write to file descriptor: " + filename);

barretenberg/cpp/src/barretenberg/chonk/chonk_verifier.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ template <> ChonkVerifier<false>::Output ChonkVerifier<false>::verify(const Proo
2727
HidingKernelIO kernel_io;
2828
kernel_io.reconstruct_from_public(verifier.get_public_inputs());
2929

30+
// Check accumulated pairing points from the IVC chain (inner recursive verifications)
31+
if (!kernel_io.pairing_inputs.check()) {
32+
info("ChonkVerifier: verification failed at PI pairing points check");
33+
return false;
34+
}
35+
3036
// Step 2: Perform databus consistency check
3137
const Commitment calldata_commitment = verifier.get_calldata_commitment();
3238
const Commitment return_data_commitment = kernel_io.kernel_return_data;

barretenberg/rust/bootstrap.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ function release {
6060
(cd ../ts && yarn generate)
6161
fi
6262

63+
# Check if this version is already published on crates.io (idempotent re-runs).
64+
if curl -sf -H "User-Agent: aztec-packages-ci (tech@aztec-labs.com)" "https://crates.io/api/v1/crates/barretenberg-rs/$version" | jq -e '.version.num' &>/dev/null; then
65+
echo "barretenberg-rs@$version already published on crates.io. Skipping."
66+
return 0
67+
fi
68+
6369
# Publish to crates.io (--allow-dirty because version was just set and generated files are gitignored)
6470
local extra_flags=""
6571
if ! gh release view "v$version" --repo AztecProtocol/aztec-packages &>/dev/null; then

docs/developer_versioned_docs/version-v4.1.0-rc.2/docs/foundational-topics/advanced/authwit.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ sequenceDiagram
120120

121121
The registry approach has a gas optimization: if authorization is set and consumed in the same transaction, the state changes cancel out, saving gas.
122122

123+
:::tip Why use Auth Registry for signatures in public?
124+
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](./circuits/avm_compatibility.md) for more details.
125+
:::
126+
123127
### Replay prevention
124128

125129
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.
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
---
2+
title: AVM Cryptographic Compatibility
3+
sidebar_position: 3
4+
description: Which Noir cryptographic primitives work in public (AVM) functions vs private, and workarounds for unsupported operations.
5+
tags: [protocol, circuits]
6+
---
7+
8+
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.
9+
10+
## Compatibility Table
11+
12+
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.
13+
14+
| Noir Primitive | Private (ACIR) | Public (AVM) | Notes |
15+
|---|---|---|---|
16+
| Poseidon2 Permutation | Supported | Supported | `POSEIDON2PERM` opcode |
17+
| Pedersen Hash / Commitment | Supported | Supported | Lowered to `ECADD` and `MSM` operations |
18+
| SHA-256 Compression | Supported | Supported | `SHA256COMPRESSION` opcode |
19+
| Keccak f1600 | Supported | Supported | `KECCAKF1600` opcode |
20+
| Embedded Curve Add | Supported | Supported | `ECADD` opcode (Grumpkin curve) |
21+
| Multi-Scalar Multiplication | Supported | Supported | Lowered to `TORADIXBE` + `ECADD` operations |
22+
| ToRadix | Supported | Supported | `TORADIXBE` opcode |
23+
| ECDSA secp256k1 | Supported | **Not supported** | Transpiler panics |
24+
| ECDSA secp256r1 | Supported | **Not supported** | Transpiler panics |
25+
| AES-128 Encrypt | Supported | **Not supported** | Transpiler panics |
26+
| Blake2s | Supported | **Not supported** | Transpiler panics |
27+
| Blake3 | Supported | **Not supported** | Transpiler panics |
28+
29+
## Why the Difference
30+
31+
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.
32+
33+
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.
34+
35+
## What Error Will I See?
36+
37+
If you use an unsupported blackbox function in a `#[external("public")]` function, the transpiler will panic at compile time with a message like:
38+
39+
```
40+
Transpiler doesn't know how to process EcdsaSecp256k1
41+
```
42+
43+
where the final token is the name of the unsupported `BlackBoxOp` variant (e.g. `AES128Encrypt`, `Blake2s`, `Blake3`).
44+
45+
## Signature Verification in Public: Workarounds
46+
47+
Since ECDSA signature verification is not available in public functions, use the **Authentication Registry** pattern:
48+
49+
1. Verify signatures in a **private** function (where all Noir primitives are available)
50+
2. Store approval hashes in the **Auth Registry** (a shared public contract)
51+
3. Consume the approvals in **public** functions
52+
53+
This is exactly how public authwits work. See [Authentication Witnesses](../authwit.md) for the full pattern.
54+
55+
:::tip Schnorr signatures
56+
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.
57+
:::
58+
59+
## ISA Reference
60+
61+
For the complete list of AVM opcodes, see the [AVM ISA Quick Reference](https://github.com/AztecProtocol/aztec-packages/blob/next/yarn-project/simulator/docs/avm/avm-isa-quick-reference.md).
62+
63+
## Related Pages
64+
65+
- [Public Execution (AVM)](./public_execution.md) – How the AVM executes public functions
66+
- [Authentication Witnesses](../authwit.md) – The Auth Registry pattern for public authorization
67+
- [Call Types](../../../foundational-topics/call_types.md) – How private and public functions interact
68+
- [Private Kernel](./private_kernel.md) – How private functions are processed

docs/developer_versioned_docs/version-v4.1.0-rc.2/docs/foundational-topics/advanced/circuits/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Circuits
3-
sidebar_position: 2
3+
sidebar_position: 0
44
tags: [protocol, circuits]
55
description: Explore Aztec's core protocol circuits that enforce privacy rules and transaction validity through zero-knowledge proofs, enabling private state and function execution.
66
---

docs/developer_versioned_docs/version-v4.1.0-rc.2/docs/foundational-topics/advanced/circuits/private_kernel.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Private Kernel Circuit
3-
sidebar_position: 0
3+
sidebar_position: 1
44
tags: [protocol, circuits]
55
description: Learn about the Private Kernel Circuit, the only zero-knowledge circuit in Aztec that handles private data and ensures transaction privacy by executing on user devices.
66
---

docs/developer_versioned_docs/version-v4.1.0-rc.2/docs/foundational-topics/advanced/circuits/public_execution.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Public Execution (AVM)
3-
sidebar_position: 1
3+
sidebar_position: 2
44
tags: [protocol, circuits]
55
description: Learn how the Aztec Virtual Machine (AVM) executes public functions and manages public state transitions.
66
---
@@ -22,6 +22,14 @@ For transactions containing public functions, the execution flow is:
2222
3. **AVM** - Executes all public functions, produces accumulated data
2323
4. **Rollup Circuits** - Validates proofs and includes in block
2424

25+
## Supported Cryptographic Operations
26+
27+
The AVM supports Poseidon2, Pedersen, SHA-256, Keccak, and Grumpkin curve operations (embedded curve add, multi-scalar multiplication). ECDSA signature verification, AES-128, Blake2s, and Blake3 are not available in public functions.
28+
29+
:::warning
30+
If your contract uses unsupported Noir blackbox functions in a public function, transpilation will fail at compile time. See [AVM Cryptographic Compatibility](./avm_compatibility.md) for the full compatibility table and workarounds.
31+
:::
32+
2533
## Execution Phases
2634

2735
The AVM executes public functions in three distinct phases:
@@ -72,6 +80,7 @@ These snapshots are validated in the rollup circuits to ensure continuity across
7280

7381
## Related Pages
7482

83+
- [AVM Cryptographic Compatibility](./avm_compatibility.md) – Which Noir primitives work in public functions
7584
- [Private Kernel](./private_kernel.md) – How private functions are processed
7685
- [Call Types](../../call_types.md) – How private and public functions interact
7786
- [State Management](../../state_management.md) – How public and private state works

docs/developer_versioned_docs/version-v4.1.0-rc.2/docs/foundational-topics/advanced/circuits/rollup_circuits.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Rollup Circuits
3-
sidebar_position: 2
3+
sidebar_position: 4
44
tags: [protocol, circuits]
55
description: Learn how Rollup Circuits compress transactions into a single proof using a hierarchical tree topology for efficient verification on Ethereum.
66
---

docs/developer_versioned_docs/version-v4.1.0-rc.2/docs/foundational-topics/call_types.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,10 @@ For this reason it is encouraged to try to avoid public function calls and inste
220220

221221
Contract functions marked with `#[external("public")]` can only be called publicly, and are executed by the sequencer. The computation model is very similar to the EVM: all state, parameters, etc. are known to the entire network, and no data is private. Static execution like the EVM's `STATICCALL` is possible too, with similar semantics (state can be accessed but not modified, etc.).
222222

223+
:::note
224+
The AVM supports a subset of Noir's cryptographic operations. Signature verification (ECDSA) is not available in public functions. See [AVM Cryptographic Compatibility](./advanced/circuits/avm_compatibility.md) for details.
225+
:::
226+
223227
Since private calls are always run in a user's device, it is not possible to perform any private execution from a public context. A reasonably good mental model for public execution is that of an EVM in which some work has already been done privately, and all that is known about it is its correctness and side-effects (new notes and nullifiers, enqueued public calls, etc.). A reverted public execution will also revert the private side-effects.
224228

225229
Public functions in other contracts can be called both regularly and statically, just like on the EVM.

0 commit comments

Comments
 (0)