OpenZeppelin / OpenZeppelin/compact-contracts

crypto: add a Field plaintext pad to EcdhMask

Open
#735 0 comments 0 reactions 1 assignee View on GitHub

@0xisk is already working on this.

Since Sep 7, 2026.

0-high effort: 2-S enhancement feat:crypto
Dominant language
TypeScript
Stars
55
Forks
29
Avg merge
5d 7h
Merged PRs (30d)
25

Description

🧐 Motivation

Note delivery needs to hand a recipient a (value, nonce) pair under one ECDH. EcdhMask.encrypt only pads a Uint<128>, and the nonce is a Field. A separate crypto/NoteDelivery module would duplicate the KDF for one extra plaintext type.

📝 Details

contracts/src/crypto/EcdhMask.compact

  • Add encryptField / decryptField (or a pair variant sharing one ephemeral) with the same identity and zero-ephemeral guards as encrypt.
  • Document the hiding margin: the pad is below 2^248, so a full-width Field plaintext does not get the margin Uint<128> values have.
  • Mock re-export and tests follow MockEcdhMask / EcdhMask.test.ts.

Replaces the crypto/NoteDelivery draft from #679. The note structs, OZ:note:* tags and wallet-side recovery move to the Delivery extension (#727).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.