Skip to content

feat(aztec-nr): extend OnchainDelivery builder for secret origin#23865

Merged
vezenovm merged 49 commits into
merge-train/fairies-v5from
mv/f-697-general-delivery-builder
Jun 10, 2026
Merged

feat(aztec-nr): extend OnchainDelivery builder for secret origin#23865
vezenovm merged 49 commits into
merge-train/fairies-v5from
mv/f-697-general-delivery-builder

Conversation

@vezenovm

@vezenovm vezenovm commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Fixes F-697
Fixes F-649

Summary

  • Extends MessageDelivery with separate typed builders for unconstrained and constrained on-chain delivery.
  • Adds internal tag-secret derivation config:
    • offchain: none
    • onchain unconstrained: address-pair by default, with optional non-interactive handshake selection
    • onchain constrained: non-interactive handshake
  • Introduces OnchainDeliveryMode as the typed on-chain mode used by tagging-index helpers and the HandshakeRegistry ABI instead of raw u8 values.
  • Keeps invalid delivery/tag-derivation combinations rejected at compile time where possible.
  • Stops linking constrained-tagged note logs to note-hash squashing, so removing a squashed note does not break the recipient tag index chain.
  • Re-pins the HandshakeRegistry standard contract and updates the generated standard-contract metadata.

Constrained tagging is still not fully wired up: the delivery config is validated, but tag emission remains mocked through the existing wallet-derived unconstrained path behind TODO(#14565).

Stack: #23875, then this PR, then #23866, then #23867.

AztecBot and others added 8 commits June 4, 2026 17:42
This PR's merge-train/fairies-v5 base already bumped the noir packages to
1.0.0-beta.22, but the branch still carries the beta.21 lockfile. CI's
yarn install --immutable rejects the mismatched @aztec/noir-noir_js file:
hash (294c27 -> 893a3e) and the npm:1.0.0-beta.21 references for the
noir-* packages.

Regenerated against the v5 noir commit c57152f (1.0.0-beta.22) via
yarn install --mode=update-lockfile so the lockfile now resolves to
hash=893a3e and version 1.0.0-beta.22 for the noir-* packages.
Add the secret-origin selection API to the on-chain delivery builder:
SecretOrigin (address-pair ECDH or handshake registry), selected via
.via_address_pair() / .via_handshake(registry), alongside .with_sender().
Introduce the typed OnchainDeliveryMode newtype (replacing the mode_u8
accessor) and migrate the HandshakeRegistry standard contract to take it.

Constrained tagging is mocked behind TODO(#14565): the handshake origin and
sender are validated, but the discovery tag reuses the unconstrained
derivation. The real handshake-derived tag and chain nullifier land with the
calculate_secret_and_index (F-669) and emit (F-670) helpers.

NOTE: migrating the registry changes its bytecode, so the HandshakeRegistry
standard-contract pins must be regenerated before merge:
  ./bootstrap.sh build noir-contracts && ./bootstrap.sh build yarn-project
(regenerates standard_contract_data.ts and standard_addresses.nr x2).
…delivery API

Make the OnchainDeliveryMode constructors private so consumers derive
modes through the delivery builder (MessageDelivery::onchain_X().mode())
and branch via predicates instead of raw discriminants:

- Drop pub(crate) from the ONCHAIN_* discriminant globals; only
  messages/delivery/mod.nr references them now.
- Add OnchainDeliveryMode::is_constrained() and a pub(crate) to_u8()
  oracle-boundary accessor; add a module-private MessageDelivery::mode().
- get_next_tagging_index takes OnchainDeliveryMode and converts at the
  oracle boundary (the #[oracle] ABI keeps its u8 parameter).
- Registry tests derive their mode globals via the delivery API; reword
  comments that named the now-private discriminants.

Also regenerate the HandshakeRegistry standard-contract pins
(standard_contract_data.ts + both standard_addresses.nr twins), the
re-pin deferred by the previous commit's NOTE. Verified the mode
refactor itself is bytecode-neutral: a clean-HEAD build derives the
same classId/address as this commit.
Rebuild the handshake registry artifact against the new base and update
pinned-standard-contracts.tar.gz alongside the derived pins (the prior
re-pin updated the data files but not the pinned artifact tarball). The
other three standard contracts keep their existing pinned artifacts.
@vezenovm vezenovm changed the base branch from merge-train/fairies to mv/move-message-delivery-module June 5, 2026 01:33
@vezenovm vezenovm force-pushed the mv/f-697-general-delivery-builder branch from b9f12b8 to befb4ea Compare June 5, 2026 01:34
@vezenovm vezenovm requested a review from nchamo June 5, 2026 14:22
/// emitted in the current transaction. This is typically only used for note messages: since the note will not actually
/// be created, there is no point in delivering the message.
///
/// `delivery_mode` must be a value that implements [`MessageDeliveryBuilder`], such as [`OffchainDelivery`] or

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This felt clear enough with the function signature constraints: where D: MessageDeliveryBuilder.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This revealed noir-lang/noir#12952

@vezenovm vezenovm requested review from nchamo June 8, 2026 17:54

@nchamo nchamo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like we are almost there, this is going to be great!

Comment thread noir-projects/aztec-nr/aztec/src/oracle/notes.nr Outdated
Comment thread noir-projects/aztec-nr/aztec/src/oracle/notes.nr Outdated
Comment thread noir-projects/aztec-nr/aztec/src/messages/logs/utils.nr
Comment thread noir-projects/aztec-nr/aztec/src/messages/delivery/mod.nr Outdated
Comment thread noir-projects/aztec-nr/aztec/src/messages/delivery/mod.nr Outdated
Comment thread noir-projects/aztec-nr/aztec/src/messages/delivery/mod.nr Outdated
Comment thread noir-projects/aztec-nr/aztec/src/messages/delivery/mod.nr Outdated
Comment thread noir-projects/aztec-nr/aztec/src/messages/delivery/mod.nr Outdated
Comment thread noir-projects/aztec-nr/aztec/src/messages/delivery/mod.nr Outdated

@nchamo nchamo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there, a small thing related to TagSecretDerivation

Comment thread noir-projects/aztec-nr/aztec/src/messages/delivery/tag_secret_derivation.nr Outdated
Comment thread noir-projects/aztec-nr/aztec/src/messages/delivery/mod.nr Outdated
Comment thread noir-projects/aztec-nr/aztec/src/messages/delivery/mode.nr Outdated
Comment thread noir-projects/aztec-nr/aztec/src/messages/delivery/builder.nr
Comment thread noir-projects/aztec-nr/aztec/src/messages/delivery/builder.nr
Comment thread noir-projects/aztec-nr/aztec/src/messages/delivery/builder.nr Outdated
Comment thread noir-projects/aztec-nr/aztec/src/messages/delivery/builder.nr Outdated
Comment thread noir-projects/aztec-nr/aztec/src/messages/delivery/builder.nr Outdated
@vezenovm vezenovm requested a review from nchamo June 10, 2026 15:04

@nchamo nchamo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing ❤️

@AztecBot

Copy link
Copy Markdown
Collaborator

Flakey Tests

🤖 says: This CI run detected 3 tests that failed, but were tolerated due to a .test_patterns.yml entry.

\033FLAKED\033 (8;;http://ci.aztec-labs.com/ad65dd827a1bde5a�ad65dd827a1bde5a8;;�): yarn-project/kv-store/scripts/run_test.sh src/bench/sqlite-opfs-encrypted/map_bench.test.ts (1s) (code: 0)
\033FLAKED\033 (8;;http://ci.aztec-labs.com/713b544deafd3c9d�713b544deafd3c9d8;;�): yarn-project/kv-store/scripts/run_test.sh src/sqlite-opfs/internal/ordered-binary-browser.test.ts (1s) (code: 0)
\033FLAKED\033 (8;;http://ci.aztec-labs.com/b409325ec1e368ff�b409325ec1e368ff8;;�): yarn-project/end-to-end/scripts/run_test.sh ha src/composed/ha/e2e_ha_full.test.ts (231s) (code: 0)

@vezenovm vezenovm merged commit 78c91d1 into merge-train/fairies-v5 Jun 10, 2026
12 checks passed
@vezenovm vezenovm deleted the mv/f-697-general-delivery-builder branch June 10, 2026 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants