docs(confidential): specify the client SDK layer - #822
Draft
brozorec wants to merge 8 commits into
Draft
Conversation
Fills the `SDK (to be added)` placeholder in the design doc's register. The client is load-bearing here — commitment openings exist only off-chain, so a client that mis-derives one makes funds permanently unspendable — but three requirements were stranded as obligations on "wallets and SDKs" in documents that do not own the client layer, and the seed-to-`sk` derivation the recovery guarantee depends on was never specified at all. Also records, in §16, six places where the protocol docs are silent, mutually inconsistent, or behind the circuits, each with the assumption this document makes in the meantime.
Contributor
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Removes amplification, second-register restatements, rhetorical framing, and paragraph-closing punchlines throughout, and repairs the three inbound §16 references left stale by that section's renumbering.
…_field vector Distinct domain tags are not sufficient: SpongeSqueeze_2(d, s, sigma)[0] equals poseidon_with_domain(d, [s, sigma]), so a tag used in both modes over the same inputs reproduces the other mode's pad. address_to_field is the only primitive implemented twice, on-chain and per client, and had no conformance vector.
Specifies the sponge construction in §2.5, replaces the n-squeeze phrasing with the two-lane form, and requires each domain tag to be confined to a single sponge mode. Also types the read methods' return values and renames `get_spender` to `get_spender_delegation`.
Replaces the prohibition on the SEP-0005 signing key with two root classes — the BIP-39 seed and a SEP-0053 signature by a signer on the account — keyed to custody shape, with the tradeoff comparison in §5.2. Also trims §4 to defer to DESIGN.md now that the sponge construction is normative there.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Uses RFC 5869's `IKM` throughout §5, pins the exact byte string each root class supplies (BIP-39 seed output, RFC 8032 `R ‖ S` signature, raw 32 bytes), and states that it is passed verbatim rather than hashed or re-encoded.
An ed25519-controlled address now derives sk from a SEP-0053 signature by its signer, and an address with no ed25519 key of its own from raw bytes supplied by whatever custody mechanism controls it. A seed root added no reach a signer root lacks and made an irreversible per-client commitment out of a class the address should determine.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
packages/tokens/src/confidential/docs/SDK.md, filling theSDK (to be added)placeholder inDESIGN.md's Project Documents register — the last unwritten document in the confidential-token set.Why a normative document
The client is load-bearing here, not convenience tooling. Commitment openings
(v, r)exist only off-chain, so a client that loses or mis-derives one makes funds permanently unspendable while the commitment sits visibly on-chain. Three requirements were also stranded — stated as obligations on "wallets and SDKs" in documents that don't own the client layer (DESIGN.md§5.2,DESIGN_cont.md§9.5,INDEXER.md§1/§7,SELECTIVE_DISCLOSURE.md§15.2).SDK.mdcites and discharges them rather than restating them at their current sites.Registered in the same style as
INDEXER.md: RFC-2119, explicit normative audience, conformance section. Requirements are language-neutral; the@ctd/sdkprototype is named as the reference implementation.Two substantive additions
§5 —
skderivation.DESIGN.md§4 begins fromskwithout saying where it comes from, while three documents describe recovery "from the master secret". A docs-wide grep for BIP-39/BIP-32/SLIP-0010/SEP-0005/mnemonic returns zero hits, and the prototype samplesskfrom a bare CSPRNG. §5 specifies one derivation — rejection-sampled HKDF-SHA-512 over the BIP-39 seed, bound toaddr_fandacct_f. Notably, bindingacct_fis a privacy MUST, not hygiene:vkdepends only on(sk, addr_f), so the sameskregistered under two addresses publishes identicalYandPVKunder both, linking two otherwise-unlinkable addresses at zero cost to an observer.§4.3 — the Poseidon2 sponge convention.
DESIGN.md§2.5 cites external references for the permutation but fixes neither the sponge construction nor the padding rule; the only authority iscircuits/lib/src/lib.nr. An implementer who follows §2.5 and reaches for a general-purpose Poseidon2 hash gets different digests for every derivation and fails every proof. §4.3 pins it.Verification
circuits/lib/testdata/were reproduced from §4.3 and §4.8's prose alone, using only a raw permutation and no code from the reference implementation — including the self-check that lane 0 of the two-lane squeeze equalsposeidon_with_domain(d, [s, sigma]).§Nreference and relative link resolves (checked programmatically; the docs use hand-maintained numbering).NonCanonicalEncoding = 3514and the §16.5 interface-drift claim verified againstmod.rs.cargo test/clippyare unaffected.§16 — protocol questions this surfaced
Drafting turned up six places where the protocol docs are silent, mutually inconsistent, or behind the circuits. Each is recorded with the assumption
SDK.mdmakes in the meantime, so implementations agree in the interim, but each needs a decision in the document that owns it. The two that most need a maintainer call:r_esampling is specified two opposite ways.DESIGN.md§7.6 step 1 says sample it;SELECTIVE_DISCLOSURE.md§7/§15.2 says derive it asPoseidon2(δ_eph, vk, σ). A client built to §7.6 alone permanently forecloses sender-side disclosure. §10.5 adopts derivation (matching the prototype). Adopting it protocol-wide also revisesDESIGN_cont.md§9.4 — avkholder can then construct openings, retroactively, of every transfer commitment the account created — and §8.2's scoping of that capability to the recipient's auditor.δ_eph,δ_disc,δ_disc_bindhave no assigned values, though §13 requires implementations to hardcode exact numbers. §4.8 pins them at 14–16 to match the prototype, which also documents repairing a real collision (δ_discwas at 13, colliding withδ_ecdh).The others: the §2.5 "sequential squeezes" wording versus the single-permutation implementation;
DESIGN_cont.md§11's read methods versus the contract's typed returns andget_spender_delegationname; and an optional hardening (bindingacct_fintovk) that would make the linkage above structurally impossible at the cost of R2 and every VK.No issue number — this completes an existing documented placeholder rather than introducing a feature.
PR Checklist
🤖 Generated with Claude Code