The Zcash ArboretumThe Complete Arboretum PDF

10 Note encryption

This section constructs the in-band delivery of a created note: its plaintext, its encryption to the recipient by one-shot Diffie–Hellman on the diversified base, the outgoing ciphertext keyed from 𝗈𝗏𝗄 and the Action’s own public fields, and the trial decryption and acceptance checks by which a recipient obtains a note consistent with the published 𝖼𝗆𝗑. It states the two assumptions that note encryption adds, proves decryption correctness, confidentiality and key privacy of the encryption to the recipient, confidentiality of the outgoing ciphertext, and the consistency of accepted notes, and states what each key tier can decrypt.

10.1 The note plaintext

Every Action carries, beside the extracted commitment 𝖼𝗆𝗑 of its created note, a note ciphertext (𝖾𝗉𝗄⋆,C𝖾𝗇𝖼,C𝗈𝗎𝗍). The component C𝖾𝗇𝖼 encrypts the plaintext of the created note so that the holder of the recipient’s incoming viewing key 𝗂𝗏𝗄 recovers the note and its memo from the chain alone (protocol specification, §“In-band secret distribution (Sapling and Orchard)” and §“Action Descriptions”). The component C𝗈𝗎𝗍 lets the sender, or any party that holds the outgoing viewing key 𝗈𝗏𝗄 under which it was formed, recover the same plaintext (§10.3). The fields 𝖾𝗉𝗄⋆, C𝖾𝗇𝖼 and C𝗈𝗎𝗍 are not inputs of the Action statement (Definition 9.2), which therefore does not constrain them; the checks that make a decrypted note consistent with 𝖼𝗆𝗑 are made by the recipient (§10.4).

Definition 10.1 (Note plaintext).

Let a created note have recipient address (d,𝗉𝗄𝖽) and value v∈{0,…,264−1}. Its note plaintext is the tuple 𝗇𝗉:=(𝗅𝖾𝖺𝖽𝖡𝗒𝗍𝖾,d,v,𝗋𝗌𝖾𝖾𝖽,𝗆𝖾𝗆𝗈), encoded as the byte string

𝗅𝖾𝖺𝖽𝖡𝗒𝗍𝖾⁢‖𝖫𝖤𝖡𝖲𝟤𝖮𝖲𝖯88⁢(d)‖⁢𝖨𝟤𝖫𝖤𝖮𝖲𝖯64⁢(v)⁢‖𝗋𝗌𝖾𝖾𝖽‖⁢𝗆𝖾𝗆𝗈,

where 𝗅𝖾𝖺𝖽𝖡𝗒𝗍𝖾 is one byte, the format version of “The note seed” (§4.3), equal to 𝟶⁢𝚡⁢𝟶𝟹 for an Ironwood-pool output; d is the 88-bit diversifier of the address (11 bytes); v occupies 8 bytes; 𝗋𝗌𝖾𝖾𝖽 is the 32-byte note seed; and 𝗆𝖾𝗆𝗈 is a 512-byte string chosen by the sender, whose use is by agreement between sender and recipient (protocol specification, §“Note Plaintexts and Memo Fields” and §“Encodings of Note Plaintexts and Memo Fields”). The encoding has the fixed length 1+11+8+32+512=564 bytes, so the length of a ciphertext carries no information about the plaintext.

The plaintext omits 𝗉𝗄𝖽, ρ, ψ and 𝗋𝖼𝗆. The recipient computes 𝗉𝗄𝖽=[𝗂𝗏𝗄]⁢𝗀𝖽, takes ρ=𝗇𝖿𝗈𝗅𝖽 from the same Action (“Nullifier chaining”, §6.3), and derives ψ and 𝗋𝖼𝗆 from 𝗋𝗌𝖾𝖾𝖽 (§4.3).

For each output the sender draws 𝗋𝗌𝖾𝖾𝖽 uniformly from the 32-byte strings, independently of every other output. The ephemeral secret key of this section is

𝖾𝗌𝗄=ToScalar⁢(𝖯𝖱𝖥𝖾𝗑𝗉𝖺𝗇𝖽𝗋𝗌𝖾𝖾𝖽⁢([𝟶⁢𝚡⁢𝟶𝟺]∥𝖨𝟤𝖫𝖤𝖮𝖲𝖯256⁢(𝗇𝖿𝗈𝗅𝖽))),

derived in “The note seed” (§4.3) together with ψ and 𝗋𝖼𝗆. The sender redraws 𝗋𝗌𝖾𝖾𝖽 when 𝖾𝗌𝗄=0 or 𝖼𝗆𝗑=⊥, so 𝖾𝗌𝗄∈𝔽p𝖵𝖾𝗌𝗍𝖺∗ (protocol specification, §“Sending Notes (Orchard)”; ZIP 2005, “Changes to the Protocol Specification”, §4.7.3).

10.2 Encryption to the recipient

Construction 10.2 (Encryption to the recipient).

Let (d,𝗉𝗄𝖽) be the recipient’s address, 𝗀𝖽=𝖣𝗂𝗏𝖾𝗋𝗌𝗂𝖿𝗒𝖧𝖺𝗌𝗁⁢(d) its diversified base (“Diversified addresses”, §3.3), and 𝖾𝗌𝗄 as in §10.1. A star encoding P⋆ enters a byte string as the 32 bytes 𝖫𝖤𝖡𝖲𝟤𝖮𝖲𝖯256⁢(P⋆) (§2.1), with which it is identified below. The sender computes the ephemeral public key, the shared secret and the encryption key

𝖾𝗉𝗄 :=[𝖾𝗌𝗄]⁢𝗀𝖽,s:=[𝖾𝗌𝗄]⁢𝗉𝗄𝖽,
K𝖾𝗇𝖼 :=𝖪𝖣𝖥⁢(s,𝖾𝗉𝗄):=BLAKE2b⁢-⁢256⁢(Zcash_OrchardKDF,s⋆∥𝖾𝗉𝗄⋆),

with BLAKE2b⁢-⁢256⁢(P,x) unkeyed BLAKE2b with a 32-byte output and the 16-byte personalisation P, and the ciphertext C𝖾𝗇𝖼:=𝖤𝗇𝖼K𝖾𝗇𝖼⁢(𝗇𝗉). The pair 𝖤𝗇𝖼K, 𝖣𝖾𝖼K denotes ChaCha20-Poly1305 encryption and decryption under the 256-bit key K with the all-zero 96-bit nonce and empty associated data; decryption returns ⊥ when the tag does not verify (Crypto Guide, §“The ChaCha20-Poly1305 AEAD”, Construction “ChaCha20-Poly1305”). The Action publishes the 32-byte field 𝖾𝗉𝗄⋆ and C𝖾𝗇𝖼, of 564+16=580 bytes, the plaintext and the 16-byte tag (protocol specification, §“Encryption (Sapling and Orchard)”, §“Orchard Key Agreement”, §“Orchard Key Derivation” and §“Symmetric Encryption”).

The key agreement is Diffie–Hellman on Pallas: public keys are non-identity points, private keys lie in 𝔽p𝖵𝖾𝗌𝗍𝖺∗, and both the derivation of a public key from a base and the agreement are scalar multiplication (protocol specification, §“Orchard Key Agreement”). A consensus rule requires 𝖾𝗉𝗄⋆ to be the canonical encoding of a non-identity Pallas point (protocol specification, §“Action Descriptions”). The fixed nonce is safe because every key encrypts once: K𝖾𝗇𝖼 depends on the fresh 𝖾𝗌𝗄 of its output, and the key of C𝗈𝗎𝗍 is derived separately (§10.3). The scheme is the Crypto Guide’s Construction “DH-based hybrid public-key encryption” (§“Hybrid public-key encryption”) over the per-address base 𝗀𝖽 in place of a fixed generator, as the same volume records for deployed note delivery (§“Shielded-note delivery as deployed hybrid encryption”).

Proposition 10.3 (Decryption correctness).

Let (d,𝗉𝗄𝖽) be an address of the incoming viewing key 𝗂𝗏𝗄, so 𝗉𝗄𝖽=[𝗂𝗏𝗄]⁢𝗀𝖽 (§3.3), and let 𝖾𝗉𝗄=[𝖾𝗌𝗄]⁢𝗀𝖽 with 𝖾𝗌𝗄∈𝔽p𝖵𝖾𝗌𝗍𝖺∗. Then

[𝗂𝗏𝗄]⁢𝖾𝗉𝗄=[𝖾𝗌𝗄]⁢𝗉𝗄𝖽=s.

Hence the holder of 𝗂𝗏𝗄 computes K𝖾𝗇𝖼=𝖪𝖣𝖥⁢([𝗂𝗏𝗄]⁢𝖾𝗉𝗄,𝖾𝗉𝗄) from the published 𝖾𝗉𝗄⋆ and obtains 𝖣𝖾𝖼K𝖾𝗇𝖼⁢(C𝖾𝗇𝖼)=𝗇𝗉, and a party that knows (𝗉𝗄𝖽,𝖾𝗌𝗄) obtains the same shared secret as [𝖾𝗌𝗄]⁢𝗉𝗄𝖽.

Proof.

In the cyclic Pallas group [a]⁢([b]⁢P)=[a⁢b]⁢P=[b]⁢([a]⁢P), so [𝗂𝗏𝗄]⁢([𝖾𝗌𝗄]⁢𝗀𝖽)=[𝖾𝗌𝗄]⁢([𝗂𝗏𝗄]⁢𝗀𝖽)=[𝖾𝗌𝗄]⁢𝗉𝗄𝖽. The recipient decodes 𝖾𝗉𝗄=𝖺𝖻𝗌𝗍ℙ⁢(𝖾𝗉𝗄⋆), and because the star encoding is canonical (§2.1) it re-encodes to the published bytes. The function 𝖪𝖣𝖥 is deterministic and both parties apply it to (s⋆,𝖾𝗉𝗄⋆), so they derive the same K𝖾𝗇𝖼; correctness of ChaCha20-Poly1305 gives 𝖣𝖾𝖼K𝖾𝗇𝖼⁢(𝖤𝗇𝖼K𝖾𝗇𝖼⁢(𝗇𝗉))=𝗇𝗉. This is the Crypto Guide’s Theorem “Correctness of hybrid encryption” (§“Hybrid public-key encryption”) over the base 𝗀𝖽. □

Assumption 10.4 (The note-encryption hashes as random oracles).

In security arguments the key-derivation function 𝖪𝖣𝖥 (BLAKE2b-256 personalised Zcash_OrchardKDF), the function 𝖯𝖱𝖥𝗈𝖼𝗄 (BLAKE2b-256 personalised Zcash_Orchardock, constructed in §10.3), and 𝖯𝖱𝖥𝖾𝗑𝗉𝖺𝗇𝖽 on inputs with leading byte 𝟶⁢𝚡⁢𝟶𝟺, the derivation of 𝖾𝗌𝗄 from 𝗋𝗌𝖾𝖾𝖽, are modelled as independent random oracles (Crypto Guide, §“The random oracle model”, Definition “Random oracle”). The PRF assumption (Assumption 2.12) does not suffice for the last: it requires a key unknown to the adversary, whereas the plaintext that K𝖾𝗇𝖼 encrypts contains 𝗋𝗌𝖾𝖾𝖽, the key from which 𝖾𝗌𝗄, and hence K𝖾𝗇𝖼, is derived. On its other inputs 𝖯𝖱𝖥𝖾𝗑𝗉𝖺𝗇𝖽 is used only under Assumption 2.12. The assumption is a heuristic about BLAKE2b, not a theorem; every result that uses 𝖪𝖣𝖥, 𝖯𝖱𝖥𝗈𝖼𝗄 or the derivation of 𝖾𝗌𝗄 names it.

Assumption 10.5 (Confidentiality and integrity of ChaCha20-Poly1305).

For a uniform 256-bit key that encrypts a single plaintext, ChaCha20-Poly1305 with the all-zero nonce and empty associated data is

  1. (a)

    confidential: the encryptions of any two plaintexts of equal length are computationally indistinguishable; and

  2. (b)

    integral: no efficient adversary without the key outputs a ciphertext, other than one it was given, that decrypts to a value other than ⊥.

The Crypto Guide’s Theorem “Security of ChaCha20-Poly1305” (§“The ChaCha20-Poly1305 AEAD”) derives both, with explicit bounds, from the pseudorandomness of ChaCha20. The protocol specification requires one-time INT-CTXT and IND-CPA security of the scheme, properties (b) and (a) above (Crypto Guide, Definitions “Ciphertext integrity, INT-CTXT” and “CPA security”, §“Authenticated encryption with associated data” and §“Chosen-plaintext security”; protocol specification, §“Symmetric Encryption”). The scheme is not key-committing: a party that chooses two keys can construct one ciphertext that decrypts validly under both (Crypto Guide, §“The ChaCha20-Poly1305 AEAD”, Remark “Wrong-key rejection and key commitment”). No result of this volume relies on the tag against a sender who chooses the key.

Proposition 10.6 (Confidentiality and key privacy of note encryption).

Let a key be generated honestly with 𝗎𝗌𝖾⁢_⁢𝗊𝗌𝗄=𝖿𝖺𝗅𝗌𝖾. An efficient adversary receives the address (d,𝗉𝗄𝖽) of the key at an index of its choice and data z that an efficient algorithm computes independently of the key and of 𝗋𝗌𝖾𝖾𝖽; it chooses a value v, a memo and ρ∈𝔽p𝖯𝖺𝗅𝗅𝖺𝗌. An output to (d,𝗉𝗄𝖽) with these values and ρ=𝗇𝖿𝗈𝗅𝖽 is formed as in §10.1 and the construction above, with 𝗋𝗌𝖾𝖾𝖽 uniform, and 𝖼𝗆𝗑 is the extracted commitment of its note. Then the triple (𝖾𝗉𝗄⋆,C𝖾𝗇𝖼,𝖼𝗆𝗑) is computationally indistinguishable from (E⋆,C′,𝖼𝗆𝗑), where E is a uniform non-identity Pallas point and C′ is the encryption of a fixed 564-byte string under an independent uniform key. The hypotheses are Assumptions 3.16, 10.4, 10.5, 2.8 (for 𝗀𝖽), 3.13 (for the joint distribution of 𝗂𝗏𝗄 and d) and 2.12 (for the dependence of 𝖼𝗆𝗑 on 𝗋𝗌𝖾𝖾𝖽), together with Assumption 2.22 for Lemma “Rejection in key generation” (§3.2).

Since E and C′ are computed from neither the plaintext nor the address, the pair (𝖾𝗉𝗄⋆,C𝖾𝗇𝖼) reveals neither the plaintext, 𝗋𝗌𝖾𝖾𝖽 included, nor the recipient’s address: given two addresses of independent keys, the data z may contain the second, and the ciphertext is indistinguishable from one independent of both. The value 𝖼𝗆𝗑 is included so that the result applies within an Action. Of the hypotheses only Assumption 3.16, used through the computational Diffie–Hellman problem that it implies, concerns the one-shot key agreement between 𝖾𝗌𝗄 and 𝗉𝗄𝖽; Assumptions 10.4 and 10.5 concern the hash functions and the cipher. The adversary is passive: the volume does not claim indistinguishability of encryptions against an adversary that may also obtain decryptions of ciphertexts of its choice other than the challenge, before and after receiving it (IND-CCA2), which the protocol specification, §“Key Derivation”, requires of the scheme.

Proof.

The proof is a sequence of games (Crypto Guide, §“Security as a game”, Remark “Game-hopping”); each reduction below runs the adversary and the rest of the game. Let Q be the event that the adversary queries the oracle of Assumption 10.4 for 𝖯𝖱𝖥𝖾𝗑𝗉𝖺𝗇𝖽 at an input keyed by 𝗋𝗌𝖾𝖾𝖽.

Preliminary step. As in the proof of Proposition 3.18, the key is replaced by a single draw without rejection and its triple (𝖺𝗌𝗄,𝗇𝗄,𝗋𝗂𝗏𝗄) by independent uniform elements (Lemma 2.15, Assumption 2.12; Lemma “Rejection in key generation”, §3.2, Assumptions 2.22 and 2.8). Then (𝗂𝗏𝗄,𝖽𝗄) is replaced by (𝖢𝗈𝗆𝗆𝗂𝗍𝗋𝗂𝗏𝗄′𝗂𝗏𝗄⁢(𝖺𝗄,𝗇𝗄),u1) (Assumption 3.13; the reduction draws 𝖺𝗌𝗄 and 𝗇𝗄 itself). Now d=𝖥𝖥𝟣⁢-⁢𝖠𝖤𝖲𝟤𝟧𝟨u1⁢(LE88⁢(j)), and 𝗂𝗏𝗄 is, independently of d, 0 with probability 1/p𝖵𝖾𝗌𝗍𝖺 and otherwise uniform on the set X𝖯𝖺𝗅𝗅𝖺𝗌 of x-coordinates of non-identity points, of (p𝖵𝖾𝗌𝗍𝖺−1)/2 elements, except on the negligible event M^=⊥ (Lemma “Distribution of 𝗂𝗏𝗄”, §3.2). The redraw of 𝗋𝗌𝖾𝖾𝖽 is replaced by a single trial, at the cost of the redraw probability, negligible as in the proof of Proposition 4.8.

(1) By Assumption 10.4, 𝖾𝗌𝗄 is ToScalar of a random-oracle output at an input keyed by 𝗋𝗌𝖾𝖾𝖽. It is replaced by an independent uniform element of 𝔽p𝖵𝖾𝗌𝗍𝖺∗. The oracle’s value at that input is used nowhere else, so the games are identical until Q occurs; they differ by at most Pr⁢[Q] in the new game plus the reduction distance of ToScalar, below 2−257, and 1/p𝖵𝖾𝗌𝗍𝖺 for the value 0 (Crypto Guide, §“Security as a game”, Remark “Game-hopping”; §2.3).

(2) The key K𝖾𝗇𝖼 is replaced by an independent uniform key. The games differ only on the event C that the adversary queries the 𝖪𝖣𝖥 oracle at s⋆∥𝖾𝗉𝗄⋆, and s=[𝖾𝗌𝗄]⁢𝗉𝗄𝖽 solves the computational Diffie–Hellman instance (𝗀𝖽,𝗉𝗄𝖽,𝖾𝗉𝗄). This is the game hop of the Crypto Guide’s Theorem “Passive security of hybrid encryption” (§“Hybrid public-key encryption”), with loss factor the number qK of 𝖪𝖣𝖥 queries, run over 𝗀𝖽. A distinguisher 𝒟 for Assumption 3.16 receives ([a]⁢P,[b]⁢P,[c]⁢P) with a uniform on X𝖯𝖺𝗅𝗅𝖺𝗌 and b,c uniform. It answers each new query of 𝖦𝗋𝗈𝗎𝗉𝖧𝖺𝗌𝗁 under the domain z.cash:Orchard-gd with [t]⁢P for a fresh uniform t, recorded, a uniform point as in the model of Assumption 2.8, so that 𝗀𝖽=[t]⁢P with t known. It sets 𝗉𝗄𝖽:=[t]⁢([a]⁢P)=[a]⁢𝗀𝖽, which embeds a as 𝗂𝗏𝗄, and 𝖾𝗉𝗄:=[t]⁢([b]⁢P)=[b]⁢𝗀𝖽, which embeds b as 𝖾𝗌𝗄; it draws u1 and 𝗋𝗌𝖾𝖾𝖽, computes d, 𝖼𝗆𝗑 and C𝖾𝗇𝖼 under a uniform key itself, and answers the other oracles lazily. It then decodes the first 32 bytes of a uniformly chosen 𝖪𝖣𝖥 query to a point S and outputs 1 exactly when S=[t]⁢([c]⁢P). The simulation differs from the game only when 𝗂𝗏𝗄=0 in the game, or b=0 or t=0 in the simulation, of total probability at most 3/p𝖵𝖾𝗌𝗍𝖺. On a Diffie–Hellman triple 𝒟 therefore outputs 1 with probability at least Pr⁢[C]/qK−3/p𝖵𝖾𝗌𝗍𝖺; on a random triple the point [t]⁢([c]⁢P) is, for t≠0, uniform and independent of the view, and 𝒟 outputs 1 with probability at most 4/p𝖵𝖾𝗌𝗍𝖺. An algorithm that computes Diffie–Hellman secrets on Pallas thus decides DDH, and Pr⁢[C]≤qK⁢(ϵ𝒟+7/p𝖵𝖾𝗌𝗍𝖺) for the advantage ϵ𝒟 of 𝒟. The exponent embedded as 𝗂𝗏𝗄 is uniform on X𝖯𝖺𝗅𝗅𝖺𝗌 in Assumption 3.16. Against the computational Diffie–Hellman problem with a uniform exponent on 𝔽p𝖵𝖾𝗌𝗍𝖺, which lies in X𝖯𝖺𝗅𝗅𝖺𝗌 with probability (p𝖵𝖾𝗌𝗍𝖺−1)/(2⁢p𝖵𝖾𝗌𝗍𝖺) and on those instances gives an exact simulation, the same reduction loses a factor 2⁢p𝖵𝖾𝗌𝗍𝖺/(p𝖵𝖾𝗌𝗍𝖺−1), about 2 (proof of Proposition 3.18, part (d)).

(3) Now 𝖾𝗉𝗄=[𝖾𝗌𝗄]⁢𝗀𝖽 with 𝖾𝗌𝗄 uniform on 𝔽p𝖵𝖾𝗌𝗍𝖺∗ is a uniform non-identity point for every generator 𝗀𝖽, and the 𝖪𝖣𝖥 context contains no key of the recipient (Crypto Guide, §“Key privacy”, Remark “What key privacy buys upstairs”). The ciphertext C𝖾𝗇𝖼 is an encryption under a uniform key used once, and Assumption 10.5(a) replaces 𝗇𝗉 by the fixed string; the reduction obtains C𝖾𝗇𝖼 from its challenger and computes the rest. The last game outputs (E⋆,C′,𝖼𝗆𝗑).

(4) In the last game 𝗋𝗌𝖾𝖾𝖽 enters the view only through 𝖼𝗆𝗑, that is through 𝖯𝖱𝖥𝖾𝗑𝗉𝖺𝗇𝖽𝗋𝗌𝖾𝖾𝖽 under the leading bytes 𝟶⁢𝚡⁢𝟶𝟿 and 𝟶⁢𝚡⁢𝟶⁢𝙱. A distinguisher with oracle access to 𝖯𝖱𝖥𝖾𝗑𝗉𝖺𝗇𝖽𝗋𝗌𝖾𝖾𝖽 or to a random function computes 𝖼𝗆𝗑 from its oracle, runs the adversary, and outputs 1 when some key k of a query at a leading byte 𝟶⁢𝚡⁢𝟶𝟺 satisfies 𝖯𝖱𝖥𝖾𝗑𝗉𝖺𝗇𝖽k⁢([𝟶⁢𝚡⁢𝟶𝟿]∥𝖨𝟤𝖫𝖤𝖮𝖲𝖯256⁢(ρ)) equal to its oracle’s answer at that input. It outputs 1 with probability at least Pr⁢[Q] in the first case. In the second the view depends on that answer only through 𝖼𝗆𝗑, and the trapdoor 𝗋𝖼𝗆, ToScalar of the independent answer at the 𝟶⁢𝚡⁢𝟶⁢𝙱 input, is within 2−257 of uniform; by Proposition 4.5(a), 𝖼𝗆𝗑 is therefore independent of that answer up to 2−257+ϵ⊥, for ϵ⊥ the probability that the hash point of M⁢(n) is ⊥, negligible as in the proof of Proposition 4.8. The distinguisher thus outputs 1 with probability at most q⋅2−512+2−257+ϵ⊥, for q such queries, and Pr⁢[Q] in the last game is negligible under Assumption 2.12 (with Lemma 2.15). Every reduction of hops (2) and (3) draws 𝗋𝗌𝖾𝖾𝖽 itself and detects Q, so each hop changes the probability of Q by at most its own cost. Hence Pr⁢[Q] is negligible in the game of hop (1) as well, and the sum of the costs of all hops is negligible.

The DDH hybrid of the Crypto Guide’s Theorem “ElGamal is key-private under DDH” (§“Key privacy”) is not used: as stated it embeds a uniform exponent of 𝔽p𝖵𝖾𝗌𝗍𝖺 as the recipient’s key, whereas 𝗂𝗏𝗄 is not uniform on 𝔽p𝖵𝖾𝗌𝗍𝖺; and the factor-2 argument above transfers a search problem such as computational Diffie–Hellman, not a decision problem, since on instances outside X𝖯𝖺𝗅𝗅𝖺𝗌 a distinguisher’s output is unconstrained. □

10.3 The outgoing ciphertext

Construction 10.7 (Outgoing ciphertext).

The sender chooses an outgoing viewing key 𝗈𝗏𝗄 of its own, such as that of the address whose note the Action consumes (“Viewing keys”, §3.2), or 𝗈𝗏𝗄=⊥. If 𝗈𝗏𝗄≠⊥, the outgoing cipher key is

𝗈𝖼𝗄 :=𝖯𝖱𝖥𝗈𝗏𝗄𝗈𝖼𝗄⁢(𝖼𝗏𝗇𝖾𝗍,𝖼𝗆𝗑,𝖾𝗉𝗄)
:=BLAKE2b⁢-⁢256⁢(Zcash_Orchardock,𝗈𝗏𝗄⁢‖(𝖼𝗏𝗇𝖾𝗍)⋆‖⁢𝖨𝟤𝖫𝖤𝖮𝖲𝖯256⁢(𝖼𝗆𝗑)∥𝖾𝗉𝗄⋆),

where 𝖼𝗏𝗇𝖾𝗍 is the Action’s net value commitment (Definition 8.2) and 𝖼𝗆𝗑 its extracted note commitment (Definition 4.4), and the outgoing plaintext is the 32+32=64-byte string 𝗈𝗉:=𝗉𝗄𝖽⋆∥𝖨𝟤𝖫𝖤𝖮𝖲𝖯256⁢(𝖾𝗌𝗄). If 𝗈𝗏𝗄=⊥, the sender draws 𝗈𝖼𝗄 uniformly from the 256-bit strings and 𝗈𝗉 uniformly from the 64-byte strings. In both cases C𝗈𝗎𝗍:=𝖤𝗇𝖼𝗈𝖼𝗄⁢(𝗈𝗉), of 64+16=80 bytes, and the Action publishes it; with 𝗈𝗏𝗄=⊥ no outgoing viewing key recovers it (protocol specification, §“Encryption (Sapling and Orchard)”, §“Sending Notes (Orchard)” and §“Pseudo Random Functions”).

Construction 10.8 (Recovery with 𝗈𝗏𝗄).

For an Ironwood-pool output, the holder of 𝗈𝗏𝗄

  1. (i)

    computes 𝗈𝖼𝗄 from 𝗈𝗏𝗄 and the Action’s public 𝖼𝗏𝗇𝖾𝗍, 𝖼𝗆𝗑 and 𝖾𝗉𝗄⋆, and decrypts C𝗈𝗎𝗍 under 𝗈𝖼𝗄 to the outgoing plaintext 𝗈𝗉, rejecting ⊥;

  2. (ii)

    parses 𝗈𝗉 as a 32-byte string b1 followed by a 32-byte string b2, and reads 𝖾𝗌𝗄 as the integer 𝖫𝖤𝖮𝖲𝟤𝖨𝖯256⁢(b2), rejecting 𝖾𝗌𝗄≥p𝖵𝖾𝗌𝗍𝖺, and 𝗉𝗄𝖽 as the point 𝖺𝖻𝗌𝗍ℙ⁢(b1), rejecting ⊥ and 𝒪;

  3. (iii)

    computes s:=[𝖾𝗌𝗄]⁢𝗉𝗄𝖽, K𝖾𝗇𝖼:=𝖪𝖣𝖥⁢(s,𝖾𝗉𝗄) and 𝗇𝗉:=𝖣𝖾𝖼K𝖾𝗇𝖼⁢(C𝖾𝗇𝖼), rejecting ⊥;

  4. (iv)

    rejects unless 𝗅𝖾𝖺𝖽𝖡𝗒𝗍𝖾=𝟶⁢𝚡⁢𝟶𝟹;

  5. (v)

    with ρ:=𝗇𝖿𝗈𝗅𝖽 of the same Action, rejects unless

    𝖾𝗌𝗄=ToScalar⁢(𝖯𝖱𝖥𝖾𝗑𝗉𝖺𝗇𝖽𝗋𝗌𝖾𝖾𝖽⁢([𝟶⁢𝚡⁢𝟶𝟺]∥𝖨𝟤𝖫𝖤𝖮𝖲𝖯256⁢(ρ)));
  6. (vi)

    computes 𝗀𝖽:=𝖣𝗂𝗏𝖾𝗋𝗌𝗂𝖿𝗒𝖧𝖺𝗌𝗁⁢(d), then ψ, then 𝗋𝖼𝗆 under 𝟶⁢𝚡⁢𝟶𝟹 from 𝗀𝖽, 𝗉𝗄𝖽, v, ρ and ψ, by steps (iv) and (v) of the derivation of §4.3;

  7. (vii)

    rejects if the note commitment of ((d,𝗉𝗄𝖽),v,ρ,ψ,𝗋𝖼𝗆) (Definition 4.4) is ⊥ or its x-coordinate differs from 𝖼𝗆𝗑, or if ([𝖾𝗌𝗄]⁢𝗀𝖽)⋆≠𝖾𝗉𝗄⋆;

  8. (viii)

    otherwise returns the note ((d,𝗉𝗄𝖽),v,ρ,ψ,𝗋𝖼𝗆) and 𝗆𝖾𝗆𝗈.

The order 𝗀𝖽 and 𝗉𝗄𝖽, then ψ, then 𝗋𝖼𝗆 is forced because 𝗋𝖼𝗆 depends on all three. The specification’s decryption sections still use the legacy derivation of 𝗋𝖼𝗆; ZIP 2005 specifies the reordered procedure (protocol specification, §“Decryption using an Outgoing Viewing Key (Sapling and Orchard)”; ZIP 2005, “Changes to the Protocol Specification”, §4.20.2 and §4.20.3). The specification’s further check that b1 re-encodes 𝗉𝗄𝖽 holds for every string that 𝖺𝖻𝗌𝗍ℙ decodes, the star encoding being canonical (§2.1). For 𝗉𝗄𝖽 the specification’s procedure rejects only ⊥; the rejection of 𝒪 in step (ii) makes the returned 𝗉𝗄𝖽 a transmission key of Definition “Note” (§4.1).

Remark 10.9 (Transplant resistance).

The key 𝗈𝖼𝗄 is a function of the Action’s own 𝖼𝗏𝗇𝖾𝗍, 𝖼𝗆𝗑 and 𝖾𝗉𝗄. A ciphertext C𝗈𝗎𝗍 that a party without 𝗈𝗏𝗄 copies into an Action whose (𝖼𝗏𝗇𝖾𝗍,𝖼𝗆𝗑,𝖾𝗉𝗄) differ is decrypted by the holder of 𝗈𝗏𝗄 under a key that, by Assumption 10.4, is uniform and independent of the copied ciphertext; by Assumption 10.5(b) that decryption returns ⊥ except with negligible probability. A copied C𝗈𝗎𝗍 is therefore rejected, not attributed to the other Action.

Proposition 10.10 (Confidentiality of the outgoing ciphertext).

Let the sending key be generated honestly with 𝗎𝗌𝖾⁢_⁢𝗊𝗌𝗄=𝖿𝖺𝗅𝗌𝖾. To an efficient party that holds neither its 𝗈𝗏𝗄 nor its 𝗋𝗂𝗏𝗄, and may hold its 𝖺𝗄, 𝗇𝗄, 𝗂𝗏𝗄 and 𝖽𝗄, each ciphertext C𝗈𝗎𝗍 that the holder of the key forms is computationally indistinguishable, jointly with every other public field of its Action, from the encryption of a fixed 64-byte string under an independent uniform key. The hypotheses are Assumptions 2.12, 3.13, 10.4, 10.5, 9.14, 2.22 and 2.8.

Proof.

As in the preliminary step of the proof of Proposition 10.6, the key is replaced by a single draw without rejection and its triple (𝖺𝗌𝗄,𝗇𝗄,𝗋𝗂𝗏𝗄) by independent uniform elements (Lemma 2.15, Assumption 2.12; Lemma “Rejection in key generation”, §3.2, Assumptions 2.22 and 2.8). After this step, Assumption 3.13 makes 𝗈𝗏𝗄 indistinguishable from a uniform 32-byte string independent of 𝗂𝗏𝗄 and 𝖽𝗄; the reduction draws 𝖺𝗌𝗄 and 𝗇𝗄 itself, obtains (𝗂𝗏𝗄,𝖽𝗄,𝗈𝗏𝗄) from its challenger, computes every other field, and simulates the Action proof, whose witness contains 𝗋𝗂𝗏𝗄, under Assumption 9.14. Then 𝗈𝖼𝗄 is a random-oracle output (Assumption 10.4) at an input that the party queries with negligible probability, hence uniform, and distinct Actions give distinct inputs, their 𝖾𝗉𝗄 differing except with negligible probability, so each 𝗈𝖼𝗄 encrypts once; Assumption 10.5(a) then applies. With 𝗈𝗏𝗄=⊥, 𝗈𝖼𝗄 is uniform by construction. The ciphertext C𝗈𝗎𝗍 thus reveals nothing about (𝗉𝗄𝖽,𝖾𝗌𝗄). □

A holder of 𝗈𝗏𝗄 recovers, for every output sent under that 𝗈𝗏𝗄, the pair (𝗉𝗄𝖽,𝖾𝗌𝗄), hence the shared secret [𝖾𝗌𝗄]⁢𝗉𝗄𝖽 (Proposition 10.3), K𝖾𝗇𝖼, the note plaintext and the recipient’s address (d,𝗉𝗄𝖽); in this way the sender, or a party to whom the sender discloses 𝗈𝗏𝗄, reads outgoing notes (protocol specification, §“Decryption using an Outgoing Viewing Key (Sapling and Orchard)”). By this route it reads only outputs sent under that 𝗈𝗏𝗄. Detecting the notes sent to the key’s own addresses by trial decryption requires 𝗂𝗏𝗄 (§10.4), and 𝗈𝗏𝗄 yields no 𝗂𝗏𝗄 (Proposition 3.18, “Capability separation”, part (c), for keys generated with 𝗎𝗌𝖾⁢_⁢𝗊𝗌𝗄=𝖿𝖺𝗅𝗌𝖾).

10.4 Trial decryption and note acceptance

Construction 10.11 (Trial decryption).

No public field of an Action names its recipient, so the holder of an incoming viewing key attempts every output: it computes 𝖾𝗉𝗄:=𝖺𝖻𝗌𝗍ℙ⁢(𝖾𝗉𝗄⋆), rejecting ⊥, which consensus excludes, then s:=[𝗂𝗏𝗄]⁢𝖾𝗉𝗄, K𝖾𝗇𝖼:=𝖪𝖣𝖥⁢(s,𝖾𝗉𝗄) and 𝗇𝗉:=𝖣𝖾𝖼K𝖾𝗇𝖼⁢(C𝖾𝗇𝖼) (protocol specification, §“Decryption using an Incoming Viewing Key (Sapling and Orchard)”). A result other than ⊥ is a candidate, not an accepted note.

The same 𝗂𝗏𝗄 serves the outputs of both pools, since keys and addresses are defined for the Orchard protocol, not for a pool (§3.4), and an address does not name a pool (ZIP 326, “Scanning for Ironwood-pool and Orchard-pool notes”); the pool of an output is that of the bundle that carries it. For an honestly produced ciphertext under a key independent of the trial key, decryption returns ⊥ except with negligible probability (Assumption 10.5(b); Crypto Guide, §“The ChaCha20-Poly1305 AEAD”, Remark “Wrong-key rejection and key commitment”); against a sender who chooses the keys the tag gives no such guarantee.

Construction 10.12 (Acceptance of an Ironwood-pool output).

Given a candidate 𝗇𝗉=(𝗅𝖾𝖺𝖽𝖡𝗒𝗍𝖾,d,v,𝗋𝗌𝖾𝖾𝖽,𝗆𝖾𝗆𝗈) of an Ironwood-pool output, the recipient accepts only if every check passes:

  1. (i)

    𝗅𝖾𝖺𝖽𝖡𝗒𝗍𝖾=𝟶⁢𝚡⁢𝟶𝟹, the recipient’s enforcement of the lead-byte rule of “The note seed” (§4.3);

  2. (ii)

    with ρ:=𝗇𝖿𝗈𝗅𝖽 of the same Action and ρ¯:=𝖨𝟤𝖫𝖤𝖮𝖲𝖯256⁢(ρ), the note is re-derived in the order

    𝗀𝖽 :=𝖣𝗂𝗏𝖾𝗋𝗌𝗂𝖿𝗒𝖧𝖺𝗌𝗁⁢(d),𝗉𝗄𝖽:=[𝗂𝗏𝗄]⁢𝗀𝖽,
    ψ :=ToBase⁢(𝖯𝖱𝖥𝖾𝗑𝗉𝖺𝗇𝖽𝗋𝗌𝖾𝖾𝖽⁢([𝟶⁢𝚡⁢𝟶𝟿]∥ρ¯)),
    𝗋𝖼𝗆 :=ToScalar⁢(𝖯𝖱𝖥𝖾𝗑𝗉𝖺𝗇𝖽𝗋𝗌𝖾𝖾𝖽⁢(𝗉𝗋𝖾⁢_⁢𝗋𝖼𝗆)),

    with the 137-byte string 𝗉𝗋𝖾⁢_⁢𝗋𝖼𝗆 of §4.3 formed from 𝗀𝖽, 𝗉𝗄𝖽, v, ρ and ψ;

  3. (iii)

    ([𝖾𝗌𝗄]⁢𝗀𝖽)⋆=𝖾𝗉𝗄⋆ for

    𝖾𝗌𝗄:=ToScalar⁢(𝖯𝖱𝖥𝖾𝗑𝗉𝖺𝗇𝖽𝗋𝗌𝖾𝖾𝖽⁢([𝟶⁢𝚡⁢𝟶𝟺]∥ρ¯)),

    a check that ZIP 2005 places directly after the computation of 𝗀𝖽;

  4. (iv)

    the note commitment 𝖼𝗆′ of the re-derived note (Definition 4.4) is not ⊥ and 𝖤𝗑𝗍𝗋𝖺𝖼𝗍ℙ⁢(𝖼𝗆′)=𝖼𝗆𝗑.

The accepted note is n=((d,𝗉𝗄𝖽),v,ρ,ψ,𝗋𝖼𝗆), with 𝗆𝖾𝗆𝗈 (ZIP 2005, “Changes to the Protocol Specification”, §4.20.2 and §4.20.3; protocol specification, §“Decryption using an Incoming Viewing Key (Sapling and Orchard)” and §“Note Plaintexts and Memo Fields”).

The order in (ii) is forced because 𝗋𝖼𝗆 depends on 𝗀𝖽, 𝗉𝗄𝖽 and ψ; the recovery with 𝗈𝗏𝗄 of §10.3 follows the same order. The specification’s decryption sections still use the legacy derivation of 𝗋𝖼𝗆; ZIP 2005 specifies both reordered procedures. The specification’s check 𝗋𝖼𝗆<p𝖵𝖾𝗌𝗍𝖺 holds for every output of ToScalar.

Remark 10.13 (Role of check (iii)).

The Action statement (Definition 9.2) does not constrain 𝖾𝗉𝗄. Check (iii) makes the recipient accept only an 𝖾𝗉𝗄 formed on the base 𝗀𝖽 of the diversifier in the plaintext. Without it a sender could agree the key with one address of a recipient while naming the diversifier of another, and link the two addresses by observing whether the recipient accepts (ZIP 212, “Motivation”).

Remark 10.14 (Where the Ironwood derivation is checked).

The Action statement takes ψ and 𝗋𝖼𝗆 as witnesses and does not check their derivation from 𝗋𝗌𝖾𝖾𝖽 (Definition 9.2). An accepted Ironwood-pool note has, by checks (i), (ii) and (iv), ψ and 𝗋𝖼𝗆 derived under 𝟶⁢𝚡⁢𝟶𝟹 and the commitment 𝖼𝗆𝗑. For a coinbase output, consensus runs the recovery with 𝗈𝗏𝗄 of §10.3 under the all-zero 𝗈𝗏𝗄 (“Chain state and pool rules”, §11.4), which checks the lead byte and the whole 𝟶⁢𝚡⁢𝟶𝟹 derivation. For every other output, these recipient checks are the only check of the 𝟶⁢𝚡⁢𝟶𝟹 note format.

Orchard-pool outputs carry lead byte 𝟶⁢𝚡⁢𝟶𝟸 and use the legacy trapdoor derivation of the protocol specification, §“Sending Notes (Orchard)”; the recipient decrypts them with the same 𝗂𝗏𝗄 under that byte and derivation (§“Note Plaintexts and Memo Fields”), on which this volume does not rely.

Proposition 10.15 (Consistency of accepted notes).

Let the acceptance procedure accept an Ironwood-pool output with note n=((d,𝗉𝗄𝖽),v,ρ,ψ,𝗋𝖼𝗆).

  1. (a)

    The note n is addressed to (d,[𝗂𝗏𝗄]⁢𝗀𝖽), an address of the recipient’s key; it has ρ=𝗇𝖿𝗈𝗅𝖽 of the same Action; and its ψ and 𝗋𝖼𝗆 are derived from its 𝗋𝗌𝖾𝖾𝖽 under 𝟶⁢𝚡⁢𝟶𝟹.

  2. (b)

    The extracted commitment of n satisfies 𝖤𝗑𝗍𝗋𝖺𝖼𝗍ℙ⁢(𝖭𝗈𝗍𝖾𝖢𝗈𝗆𝗆𝗂𝗍𝗋𝖼𝗆⁢(M⁢(n)))=𝖼𝗆𝗑.

  3. (c)

    For every efficient sender, which may choose 𝖾𝗉𝗄⋆, C𝖾𝗇𝖼, C𝗈𝗎𝗍 and the keys under which they are formed, the probability that the recipient accepts n while the sender outputs a note n′≠n with 𝖼𝗆𝗑⁢(n′)=𝖼𝗆𝗑 is negligible, under the binding of note commitments (Proposition 4.5), hence under Assumptions 2.22 and 2.8. In particular, under Assumption 9.11, the committed values and the trapdoor of the created note that an extractor recovers from the Action proof, which satisfy condition A2 of the Action statement (Definition 9.2), are (𝗀𝖽,𝗉𝗄𝖽,v,ρ,ψ) and 𝗋𝖼𝗆 modulo p𝖵𝖾𝗌𝗍𝖺, those of n, except with negligible probability.

Proof.

Parts (a) and (b) hold by construction: acceptance requires checks (i), (ii) and (iv), and check (iv) recomputes the commitment of n deterministically and compares its x-coordinate with 𝖼𝗆𝗑, whatever the ciphertext and whichever key decrypted it. The address (d,[𝗂𝗏𝗄]⁢𝗀𝖽) is an address of the key because 𝖥𝖥𝟣⁢-⁢𝖠𝖤𝖲𝟤𝟧𝟨𝖽𝗄 is a permutation of the 88-bit strings, so every d is the diversifier of one index (§3.3).

(c) Consider the algorithm that generates the recipient’s key, runs the sender, runs the acceptance procedure on its output, and outputs n and the sender’s n′. When the recipient accepts, n opens 𝖼𝗆𝗑≠⊥ by (b), so an n′≠n with 𝖼𝗆𝗑⁢(n′)=𝖼𝗆𝗑 gives two distinct notes with equal extracted commitments other than ⊥, which Proposition 4.5(b) excludes except with negligible probability. For the particular case, the extractor of Assumption 9.11 run on the sender is such a sender-side algorithm, with an opening of the committed values and a trapdoor in place of a note. Outside the negligible ⊥-weakened case of condition A2, which yields an input on which 𝖭𝗈𝗍𝖾𝖢𝗈𝗆𝗆𝗂𝗍 returns ⊥ (Proposition 2.24(iii)), its opening (M′,𝗋𝖼𝗆′) satisfies 𝖤𝗑𝗍𝗋𝖺𝖼𝗍ℙ⁢(𝖭𝗈𝗍𝖾𝖢𝗈𝗆𝗆𝗂𝗍𝗋𝖼𝗆′⁢(M′))=𝖼𝗆𝗑. Step 2 of the proof of Proposition 4.5(b), which uses Proposition 2.24(ii) and the fact that HD≠𝒪, then gives M′=M⁢(n) and 𝗋𝖼𝗆′≡𝗋𝖼𝗆(modp𝖵𝖾𝗌𝗍𝖺) except with negligible probability, and M⁢(n) determines (𝗀𝖽,𝗉𝗄𝖽,v,ρ,ψ) because the encoding is injective. The proof uses neither the integrity of ChaCha20-Poly1305 nor key commitment, which the scheme lacks (Assumption 10.5): a ciphertext valid under two keys yields under each a candidate that must still pass check (iv). □

On acceptance the recipient records n with its note position, the index of 𝖼𝗆𝗑 among the leaves of the note commitment tree of the output’s pool, fixed by the order in which the chain appends extracted commitments (“The Merkle hash and the tree”, §5.1; protocol specification, §“Note Commitment Trees”). The position determines the authentication path, which the recipient computes from public data (Lemma 5.15) and which, with the opening n of the leaf 𝖼𝗆𝗑 (Proposition 10.15), a later Action consuming n requires (conditions A1 and A3 of Definition 9.2).

The key tiers of Proposition 3.18 (“Capability separation”) have the following powers over note ciphertexts, for keys generated with 𝗎𝗌𝖾⁢_⁢𝗊𝗌𝗄=𝖿𝖺𝗅𝗌𝖾.

Incoming tier. A holder of the incoming viewing key (𝖽𝗄,𝗂𝗏𝗄), of which trial decryption and acceptance use only 𝗂𝗏𝗄, detects and reads every note sent to any address of the key, value and memo included. It cannot compute the nullifiers of these notes, which require 𝗇𝗄, and (𝖽𝗄,𝗂𝗏𝗄) yields neither 𝗇𝗄 nor 𝖺𝗌𝗄 (Proposition 3.18(b)). It cannot link a published nullifier to one of them, for notes with pairwise distinct ρ (Proposition 6.10), so the nullifier sets alone do not show it which are consumed; and it cannot authorise a spend.

Full-viewing tier. A holder of the full viewing key (𝖺𝗄,𝗇𝗄,𝗋𝗂𝗏𝗄) derives (𝖽𝗄,𝗂𝗏𝗄) and 𝗈𝗏𝗄 (“Viewing keys”, §3.2). It detects and reads incoming notes as above, and reads the outputs sent under its 𝗈𝗏𝗄 (§10.3), not those sent under 𝗈𝗏𝗄=⊥ or another outgoing viewing key. With 𝗇𝗄 it computes the nullifier 𝗇𝖿=𝖣𝖾𝗋𝗂𝗏𝖾𝖭𝗎𝗅𝗅𝗂𝖿𝗂𝖾𝗋𝗇𝗄⁢(ρ,ψ,𝖼𝗆) of each accepted note (Definition 6.3) and detects its consumption by the membership of 𝗇𝖿 in the nullifier set of the note’s pool (“Nullifier sets”, §6.2; protocol specification, §“Decryption using an Incoming Viewing Key (Sapling and Orchard)”, notes). It cannot spend, since it yields no 𝖺𝗌𝗄 (Proposition 3.18(a)). For each unspent note the owner thus holds the note, its position, its authentication path and its nullifier, the consumed-note inputs of an Action (Definition 9.2); spending authority is 𝖺𝗌𝗄.