Documentation

CslibFrontier.Crypto.Computational.TreeSignature

Stateless tree signatures from an indexed signature scheme #

The stateless Merkle signature system of [BS23], Section 14.6.3 (Fig. 14.7), over an indexed signature scheme used at indices 0 and 1. The signer owns a binary tree of depth depth n. Every node a ∈ {0, 1}^{< depth n} holds a key pair of the indexed scheme derived from a coin function coins k: the node's coins are coins k (keyInput a) budget, and the coins of the signature at its index u are coins k (signInput a u) budget. Deriving both from the secret key k makes every key pair and every internal signature a deterministic function of k, so repeated signatures reuse them ([BS23], Section 14.6.2, "The key management problem" and "Generating internal keys using a PRF"); the indexed scheme's own randomized signer is run on derived coins through IndexedSignatureScheme.Seeded (Exercise 13.6).

To sign msg, the signer checks that msg has length n (returning [] otherwise, matching SignatureScheme's n-bit message space), samples a uniform leaf a₁ ⋯ a_d, and certifies the path: the node a₁ ⋯ a_{i-1} signs the public key of its child a₁ ⋯ a_i at index a_i for i < d, and the node a₁ ⋯ a_{d-1} signs msg at index a_d. The signature is the leaf, the d - 1 certified child keys with their signatures, and the final signature. Verification recomputes the chain from the root, checking that the leaf has length depth n and the chain depth n - 1 certificates. The public key is (n, root public key) and the secret key (n, k) with k uniform of length keyLen n.

The scheme differs from Fig. 14.7 in four labelled ways: the root key pair is derived from k like every other node, rather than sampled by key generation and stored in the secret key; the tree is binary, using only the indices 0 and 1 of the indexed scheme; the public key carries n, from which verification fixes the depth, which the source leaves to global parameters; and verification checks the leaf length and the certificate count explicitly. The coins of a node's signature depend on the node and the index only, not on what is signed.

The coin function is a parameter with a polynomial-time certificate. This module provides the scheme, its completeness and its efficiency. Its security is [BS23], Theorem 14.6, p. 600, in the binary case q = 2. CslibFrontier.Crypto.Computational.TreeSignature.Security instantiates the coins with a pseudorandom function and proves steps toward that theorem, under a PRF premise stronger than the source's; the theorem itself is open (#5293).

Main definitions #

Main results #

References #

Derived keys and signatures #

The coin request of the key pair at node path.

The coin request of the signature at index u of node path.

The key pair of node path at parameter n under the secret key k.

def Cslib.Crypto.TreeSignature.signAt (S : IndexedSignatureScheme) (T : S.Seeded) (coins : List Bool → List Bool → ℕ → List Bool) (k path sk : List Bool) (u : ℕ) (msg : List Bool) :

The signature of msg at index u by node path holding the secret key sk, on the coins derived from k.

The certification chain #

The state of the certification chain: the current node, its key pair and the certificates issued so far, each a child public key with its signature.

Instances For
    theorem Cslib.Crypto.TreeSignature.CertState.ext {x y : CertState} (node : x.node = y.node) (keyPair : x.keyPair = y.keyPair) (certificates : x.certificates = y.certificates) :
    x = y
    def Cslib.Crypto.TreeSignature.certifyStep (S : IndexedSignatureScheme) (T : S.Seeded) (coins : List Bool → List Bool → ℕ → List Bool) (n : ℕ) (k : List Bool) (state : CertState) (a : Bool) :

    One step of the chain: derive the child at a, sign its public key at index a, and move to it.

    Certify the path bits from the root.

    A tree signature: the leaf, the certified child keys with their signatures, and the final signature on the message.

    Read the parameter and the word of a key: the public key is (n, root public key) and the secret key (n, k).

    def Cslib.Crypto.TreeSignature.signWithLeaf (S : IndexedSignatureScheme) (T : S.Seeded) (coins : List Bool → List Bool → ℕ → List Bool) (n : ℕ) (k leaf msg : List Bool) :

    Sign msg at the leaf leaf: certify the path to the leaf's parent, which signs msg at the leaf's last bit.

    The algorithms #

    noncomputable def Cslib.Crypto.TreeSignature.keyGen (S : IndexedSignatureScheme) (T : S.Seeded) (coins : List Bool → List Bool → ℕ → List Bool) (keyLen : ℕ → ℕ) (n : ℕ) :

    Key generation: a uniform secret k of length keyLen n; the public key is the root's.

    noncomputable def Cslib.Crypto.TreeSignature.sign (S : IndexedSignatureScheme) (T : S.Seeded) (coins : List Bool → List Bool → ℕ → List Bool) (depth : ℕ → ℕ) (sk msg : List Bool) :

    Signing: when msg has length n, sample a uniform leaf of the depth-depth n tree and sign there; otherwise return [].

    One verification step: check the certificate (pk', σ) of the child at a under the current public key, and move to the child.

    Verification: the leaf has length depth n with depth n - 1 certificates, the certificates chain from the root along the leaf's prefix, and the last certified key signs msg at the leaf's last bit.

    Completeness #

    theorem Cslib.Crypto.TreeSignature.certify_append {S : IndexedSignatureScheme} {T : S.Seeded} {coins : List Bool → List Bool → ℕ → List Bool} (n : ℕ) (k bits : List Bool) (a : Bool) :
    certify S T coins n k (bits ++ [a]) = certifyStep S T coins n k (certify S T coins n k bits) a
    theorem Cslib.Crypto.TreeSignature.certify_spec {S : IndexedSignatureScheme} {T : S.Seeded} {coins : List Bool → List Bool → ℕ → List Bool} (n : ℕ) (hcap : 2 ≤ S.capacity n) (k bits : List Bool) :
    have state := certify S T coins n k bits; state.node = bits ∧ state.keyPair = nodeKey S T coins n k bits ∧ state.certificates.length = bits.length ∧ List.foldl (verifyStep S) (true, (nodeKey S T coins n k []).1) (bits.zip state.certificates) = (true, (nodeKey S T coins n k bits).1)

    The chain reaches the node bits with its key, issues one certificate per bit, and its certificates verify from the root when both indices are below the capacity.

    theorem Cslib.Crypto.TreeSignature.verify_signWithLeaf {S : IndexedSignatureScheme} {T : S.Seeded} {coins : List Bool → List Bool → ℕ → List Bool} {depth : ℕ → ℕ} (n : ℕ) (hcap : 2 ≤ S.capacity n) (hdepth : 1 ≤ depth n) (k leaf : List Bool) (hleaf : leaf.length = depth n) (msg : List Bool) :

    Completeness at a leaf: a signature at a leaf of length depth n ≥ 1 verifies under the public key of the root.

    Every supported key pair is ((n, root public key), (n, k)) for a k of length keyLen n.

    theorem Cslib.Crypto.TreeSignature.verify_sign {S : IndexedSignatureScheme} {T : S.Seeded} {coins : List Bool → List Bool → ℕ → List Bool} {keyLen depth : ℕ → ℕ} (hcap : ∀ (n : ℕ), 2 ≤ S.capacity n) (hdepth : ∀ (n : ℕ), 1 ≤ depth n) (n : ℕ) (keys : List Bool × List Bool) (hkeys : keys ∈ (keyGen S T coins keyLen n).eval.support) (msg : List Bool) (hmsg : msg.length = n) (sig : List Bool) (hsig : sig ∈ (sign S T coins depth keys.2 msg).eval.support) :
    verify S depth keys.1 msg sig = true

    Completeness: every honest signature on an n-bit message verifies, when the indexed scheme has at least two indices and the tree has depth at least one.

    Efficiency #

    theorem Cslib.Crypto.TreeSignature.encCertState_mk_inO {γ : Type} {encIn : γ ↪ List Bool} {x0 : γ → List Bool} {T0 S0 : γ → ℕ} {x1 : γ → List Bool × List Bool} {T1 S1 : γ → ℕ} {x2 : γ → List (List Bool × List Bool)} {T2 S2 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInO x0 encIn Turing.MultiTapeTM.encBits T0 S0) (h1 : Turing.MultiTapeTM.ComputableInO x1 encIn (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encBits Turing.MultiTapeTM.encBits) T1 S1) (h2 : Turing.MultiTapeTM.ComputableInO x2 encIn (Turing.MultiTapeTM.encList (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encBits Turing.MultiTapeTM.encBits)) T2 S2) :
    Turing.MultiTapeTM.ComputableInO (fun (x : γ) => { node := x0 x, keyPair := x1 x, certificates := x2 x }) encIn encCertState (fun (x : γ) => T0 x + (T1 x + T2 x)) fun (x : γ) => S0 x + (S1 x + S2 x)

    The encoding of a certification-chain state CertState: the current tree path node framed, then the node's key pair keyPair framed (pk framed followed by sk unframed), followed by the list certificates of framed (childPk, sig) pairs (childPk framed followed by sig unframed), with every component a bit word (encBits).

    theorem Cslib.Crypto.TreeSignature.encCertState_node_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → CertState} :

    The stateless tree signature scheme ([BS23], Section 14.6.3, Fig. 14.7) over an indexed scheme S with at least two indices, seeded by T, with node coins from coins, secrets of length keyLen n and trees of depth depth n ≥ 1.