Skip to content

feat(token): confidential note fungible token draft - #679

Draft
0xisk wants to merge 4 commits into
mainfrom
feat/hybrid-confidential-token
Draft

feat(token): confidential note fungible token draft#679
0xisk wants to merge 4 commits into
mainfrom
feat/hybrid-confidential-token

Conversation

@0xisk

@0xisk 0xisk commented Jul 15, 2026

Copy link
Copy Markdown
Member

Types of changes

What types of changes does your code introduce to OpenZeppelin Midnight Contracts?
Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices apply)

Fixes #???

DRAFT tier-4 exploration: a note-based confidential token with full graph privacy (amounts — including issuance and burns — sender, and recipient hidden), built as composable pieces:

  • ConfidentialNoteToken — the core: commitment tree, nullifier single-spend, value conservation, issuer gate, plus ungated _-prefixed building blocks for composition.
  • extensions/ConfidentialNoteTokenAudit — mandatory auditor viewing; every output nonce derives from the audit ECDH, so all notes are auditor-recoverable by construction.
  • extensions/ConfidentialNoteTokenDelivery — on-chain note delivery so recipients discover funds by scanning chain data.
  • extensions/ConfidentialNoteTokenSupply — supply as a homomorphic ElGamal ciphertext with attestSupply publishing a proof-backed public total.
  • presets/RegulatedConfidentialNoteToken — the wired deployable token: issuer mint, burns, and escrow-free shared-nullifier seizure.
  • crypto/NoteDelivery — the ECDH note-delivery primitive (unit-tested, 7 passing).
  • Mocks, simulators, and witness harnesses; design doc at contracts/src/token/docs/hybrid-confidential-token.md and a privacy exploration overview at contracts/privacy_readme.md.

NOT audited, NOT production — opened as a draft for design discussion.

Known gaps (deliberate for the draft):

  • No vitest suites for the token modules yet (only the NoteDelivery primitive is unit-tested); simulators/witness harnesses are in place for them.
  • privacy_readme.md references privacy-spectrum-*.svg/.html visuals that are not committed yet.
  • Preset circuits are large (transfer k=18, ~136k rows); cost-reduction ideas tracked separately (see the feat/crypto-hashers branch and its compact-bug-report/).

PR Checklist

Further comments

The note-based (UTXO) design was chosen over encrypted-balance accounts to get sender/recipient unlinkability, escrow-free seizure (owner-spend and seizure race on the same nullifier), and auditor completeness by construction (nonces derive from the audit ECDH). Compliance and UX concerns live in optional extensions rather than the core, so each piece is independently reusable.

Draft tier-4 exploration: a note-based confidential token with full
graph privacy (amounts - including issuance and burns - sender, and
recipient hidden), built as composable pieces:

* ConfidentialNoteToken: the core (commitment tree, nullifier
  single-spend, value conservation, issuer gate) with ungated
  _-prefixed building blocks for composition
* extensions: ConfidentialNoteTokenAudit (mandatory auditor viewing
  via audit-derived nonces), ConfidentialNoteTokenDelivery (on-chain
  note delivery for wallet scanning), ConfidentialNoteTokenSupply
  (homomorphic ElGamal supply with proof-backed attestation)
* presets/RegulatedConfidentialNoteToken: the wired deployable token
  with issuer mint, burns, and escrow-free shared-nullifier seizure
* crypto/NoteDelivery: the ECDH note-delivery primitive (7 passing
  tests)
* mocks, simulators, and witness harnesses for the above; design doc
  and privacy exploration README

NOT audited, NOT production.
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 71225613-1f58-4bd5-8207-12f10fbb2f7f

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/hybrid-confidential-token

Comment @coderabbitai help to get the list of available commands.

@0xisk 0xisk self-assigned this Jul 15, 2026
* rename the family: ConfidentialNoteToken becomes
  ConfidentialNoteFungibleToken (asset class in the name, keeping the
  FungibleToken suffix family); the supply extension becomes
  ConfidentialNoteFungibleTokenPrivateSupply
* split the issuer role out of the core into
  extensions/ConfidentialNoteFungibleTokenIssuer; the core is now
  role-free and initialization-free (pure note machinery) with two
  ungated value-creation blocks: _mint (core-derived fresh nonce) and
  _mintNote (policy-built note, e.g. audit-derived nonces)
* convert presets/RegulatedConfidentialNoteFungibleToken from a
  top-level contract into a ready-to-use module: a one-shot initialize
  replaces the constructor, and the composed modules' observable
  ledgers and artifact types re-export under stable bare names; the
  new MockRegulatedConfidentialNoteFungibleToken carries the
  deployable shape for the simulators
* drop the CNT_ import prefix (Core_ for the core internally, Token_
  for the preset in consumers)
* add compliance extensions: Freeze (freeze-before-seize via a frozen
  nullifier set), Allowlist (ZK Merkle-membership KYC with tombstone
  revocation), Review (selective disclosure to approved reviewer
  keys), plus self-rotation blocks for the issuer/audit/supply keys
  and rotateAuthority in the preset
* mocks, simulators, and witness harnesses updated accordingly;
  verified via direct compact compile (skip-zk plus full keygen for
  circuit tags), tsc, and biome

NOT audited, NOT production.
@0xisk 0xisk changed the title feat(token): confidential note token draft feat(token): confidential note fungible token draft Jul 23, 2026
0xisk added 2 commits July 23, 2026 17:08
Complete the compliance layer on the confidential note token family and
add a concurrency track alongside it.

* Compliance:
  - Split the seizure authority into its own
    ConfidentialNoteFungibleTokenAuthority extension (key, secret
    witness, _assertAuthority, self-rotation), mirroring Issuer; the
    preset keeps only the seize wiring and _seizureCount.
  - Wire Freeze into the regulated preset: transfer/burn assert
    not-frozen at the owner-spend chokepoint, seize deliberately does
    not, plus freeze/unfreeze circuits gated on the authority.
  - Harden extensions: nonzero issuer-key guards, supply-key custody
    warning, Review record-correctness and reviewer-selection caveats,
    audit-scalar range note, unsalted-allowlist privacy caveat, and
    @circuitInfo annotations across the family.

* Concurrency:
  - Add utils/concurrency building blocks (UintDeltaInbox,
    ElGamalDeltaInbox, ShardedCounter, RevocableMembershipTree) with
    per-module docs.
  - Add the ConfidentialNoteFungibleTokenConcurrentSupply extension and
    a ConcurrentConfidentialNoteFungibleToken demo preset: encrypted
    supply deltas commute via the inbox and a permissionless fold, and
    attestation proves the inbox empty in-circuit.
  - Document the conflict model, matrix, and fixes in the design doc
    (new section) and in standalone concurrency.md and
    cross-contract-calls.md.
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.

1 participant