Skip to content

feat(aztec-nr)!: app-silo getSharedSecret oracle#22020

Merged
nchamo merged 4 commits into
merge-train/fairiesfrom
feat/app-silo-shared-secret
Mar 25, 2026
Merged

feat(aztec-nr)!: app-silo getSharedSecret oracle#22020
nchamo merged 4 commits into
merge-train/fairiesfrom
feat/app-silo-shared-secret

Conversation

@nchamo

@nchamo nchamo commented Mar 25, 2026

Copy link
Copy Markdown
Contributor

Why we are doing this

The getSharedSecret oracle returns a raw ECDH shared secret S = addressSecret * ephPk. Since both address and ephPk are public, any contract can call this oracle and get the same S. A malicious contract could trick a user into executing it, call the oracle for every known ephemeral public key, and decrypt messages intended for other contracts.

Our fix

We app-silo the shared secret by hashing it with the calling contract's address before returning it from the oracle:

S     = addressSecret * ephPk                                          (raw ECDH point, as today)
s_app = h(DOM_SEP__APP_SILOED_ECDH_SHARED_SECRET, S.x, S.y, contract) (app-siloed scalar)

Each contract now receives a different s_app from the same raw ECDH exchange, making cross-contract decryption impossible. The oracle validates that the passed contract address matches its execution context.

Key derivation (AES keys/IVs, field masks) is restructured to use separate domain separators instead of index offsets, strengthening the independence argument:

  • DOM_SEP__ECDH_SUBKEY for AES symmetric key/IV derivation
  • DOM_SEP__ECDH_FIELD_MASK for ciphertext field masking

The old domain separators (DOM_SEP__SYMMETRIC_KEY, DOM_SEP__SYMMETRIC_KEY_2, DOM_SEP__CIPHERTEXT_FIELD_MASK) are removed.

The oracle interface changes from returning a Point to returning a Field, and now requires a contract_address parameter. The MessageEncryption trait's encrypt and decrypt signatures also gain a contract_address parameter. Oracle version is bumped to 20.

Fixes F-477
Fixes #12656

@nchamo nchamo self-assigned this Mar 25, 2026
@nchamo nchamo added ci-no-fail-fast Sets NO_FAIL_FAST in the CI so the run is not aborted on the first failure ci-draft Run CI on draft PRs. labels Mar 25, 2026
@nchamo nchamo changed the title feat!(aztec-nr): app-silo getSharedSecret oracle feat(aztec-nr)!: app-silo getSharedSecret oracle Mar 25, 2026
Comment thread noir-projects/aztec-nr/aztec/src/keys/ecdh_shared_secret.nr Outdated
Comment thread noir-projects/aztec-nr/aztec/src/oracle/aes128_decrypt.nr Outdated
@nchamo nchamo marked this pull request as ready for review March 25, 2026 20:14
@nchamo nchamo requested a review from LeilaWang as a code owner March 25, 2026 20:14
@nchamo nchamo enabled auto-merge (squash) March 25, 2026 20:18
@nchamo nchamo merged commit 1c74bf6 into merge-train/fairies Mar 25, 2026
20 of 28 checks passed
@nchamo nchamo deleted the feat/app-silo-shared-secret branch March 25, 2026 20:36
@AztecBot

Copy link
Copy Markdown
Collaborator

❌ Failed to cherry-pick to v4-next due to conflicts. (🤖) View backport run.

AztecBot pushed a commit that referenced this pull request Mar 25, 2026
Cherry-pick of 1c74bf6 with conflicts in yarn-project/pxe/src/oracle_version.ts
AztecBot added a commit that referenced this pull request Mar 25, 2026
The cherry-pick of PR #22020 modified domain separators in constants.nr
but the generated files (constants.gen.ts, aztec_constants.hpp,
constants_gen.pil) were not regenerated. Run remake-constants to sync.
nventuro added a commit that referenced this pull request Mar 25, 2026
…ckport] (#22025)

## Summary

Backport of #22020
to v4-next.

The `getSharedSecret` oracle now app-silos the shared secret by hashing
it with the calling contract's address, preventing cross-contract
decryption attacks. Key derivation uses new domain separators
(`DOM_SEP__APP_SILOED_ECDH_SHARED_SECRET`, `DOM_SEP__ECDH_SUBKEY`,
`DOM_SEP__ECDH_FIELD_MASK`).

## Cherry-pick conflicts

Only one conflict in `yarn-project/pxe/src/oracle_version.ts` — the
oracle interface hash differs between `next` and `v4-next` because the
Oracle class has diverged. Regenerated the hash for the v4-next Oracle
interface.

## Commits

1. **Cherry-pick with conflicts** — raw cherry-pick of 1c74bf6 with
conflict markers
2. **Conflict resolution** — resolved hash conflict in oracle_version.ts
3. **Build fix** — regenerated oracle interface hash for v4-next
(`09ca7d52...`)

ClaudeBox log: https://claudebox.work/s/c95bc78416dda66e?run=1
github-merge-queue Bot pushed a commit that referenced this pull request Mar 26, 2026
BEGIN_COMMIT_OVERRIDE
feat(aztec-nr): add initialization check to utility functions (#21751)
refactor(aztec-nr): remove storage from init_test_contract (#21996)
chore: remove claude file (#22012)
refactor!: more consistent oracle names (#22018)
feat(aztec-nr)!: app-silo getSharedSecret oracle (#22020)
fix: disallow infinite pubkeys (#22026)
feat: aztecnr log prefixing (#22027)
feat(aztec-nr)!: domain-separated tags on log emission (#21910)
END_COMMIT_OVERRIDE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-to-v4-next ci-draft Run CI on draft PRs. ci-no-fail-fast Sets NO_FAIL_FAST in the CI so the run is not aborted on the first failure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants