Skip to main content

Crate zk_encryption

Crate zk_encryption 

Source
Expand description

The post-quantum envelope channel of the folded eid + Emit V2 transfer, for wallets and receiver services: the complement to the circuits in noir/. PROTOCOL.md is the protocol; README.md the flows.

  • Primitives the circuits match: poseidon (Poseidon2 over BN254 and the domain tags), grumpkin (points and keys), lattice (K-PKE over a real ML-KEM-768 key with bounded noise, the key and ciphertext commitments), duplex (the keyed Poseidon2 duplex).
  • The channel: ratchet (the handshake, the chain step, keyed sealing, the receiver’s sessions).
  • The parties: receiver (long-term keys, bundle, scanning and opening) and sender (accepting a bundle, the handshake and ratchet witnesses). Both states serialise behind the serde feature.
  • What travels: emit (the Emit V2 hashes, the Envelope event, note openings, DG1’s encoding) and witness (the values as the session and envelope apps’ Noir inputs).

Modules§

bundle
The receiver bundle, as bytes for a QR code or link (PROTOCOL.md §3):
duplex
The envelope cipher: eid_envelope’s Poseidon2 duplex (width 4, rate 3), keyed with (key, a, b, CIPHER) and bound to ctx. Each ciphertext field is the plaintext field plus a state element and replaces it; one permutation per block of three.
emit
What a transfer carries on the channel, in Emit V2’s terms: the hashes (emit-v2/<label> domains, as noir/lib/emit), the note opening (a channel payload), the Envelope event and DG1’s encoding (a channel payload).
grumpkin
Grumpkin points: the classical half of the handshake (E = e·G, Z = e·V) and the receiver’s long-term key V = v·G.
lattice
The circuit-friendly lattice encryption: ML-KEM-768’s K-PKE (FIPS 203 Algorithm 14; k = 3, n = 256, q = 3329) with sender-chosen noise |x| ≤ 2 and no compression, over a real ML-KEM-768 key. The receiver decrypts with the ŝ inside its ML-KEM-768 decapsulation key (FIPS 203 Algorithm 15 without Decompress). Mirrors noir/channel/src/lattice.nr.
poseidon
Poseidon2 over BN254 as Noir’s Poseidon2::hash and permutation (the pso-poseidon crate, the same one eid-circuits uses), domain tags, and hex encoding of field elements.
ratchet
Pairwise handshake plus symmetric ratchet (PROTOCOL.md §§4–5).
receiver
The receiver’s state: its long-term keys, the channels opened to it (a window of chain keys each) and what it needs to recognise, open and de-duplicate transfers (PROTOCOL.md §§4–5, R6–R9).
sender
The sender’s state for one channel (one receiver): the accepted bundle, and after the handshake the chain (PROTOCOL.md §§4–6).
witness
The channel’s values as the circuits’ Noir inputs (Prover.toml text), in the layout noir/lib/emit’s Channel and the envelope app (noir/circuits/channel) take, so a wallet doesn’t re-derive the field packing.

Enums§

Error

Type Aliases§

Fr
BN254’s scalar field: Noir’s Field, and Grumpkin’s base field.