Documentation

CslibFrontier.Crypto.Computational.Encryption.Functional

Functional encryption schemes and their semantic-security experiment #

A functional encryption scheme FE MPK MSK Fn SK M C Y has typed master public keys, master secret keys, function identifiers, secret keys for functions, messages, ciphertexts and outputs ([BS23], Section 15.7, Definition 15.13, pp. 658–659). Setup, key generation for a function identifier, and encryption are probabilistic programs; decryption is deterministic and returns Option Y. A functionality FE.Functionality Fn M Y pairs the evaluation map eval : Fn → M → Option Y (where none represents the book's special symbol ⊥) with the distinguished null identifier null : Fn (ε in [BS23], Section 15.7, p. 660) whose secret key captures the intentional leakage of a ciphertext.

FE.Correct (Definition 15.13, p. 659) requires that whenever F.eval f m = some y, decryption of any honest encryption of m under any key generated for f yields some y. FE.Robust (Definition 15.15, p. 661) requires that for every supported master key pair and every ciphertext c, there is a message m such that whenever E.decrypt sk c = some y for a key sk generated for f and F.eval f m = some y', the two outputs y and y' agree.

FE.ssExperiment is experiment b of the single-challenge semantic-security game for one fixed scheme ([BS23], Section 15.7, Attack Game 15.9, pp. 660–661): draw (mpk, msk), generate a null key skNull ← E.keyGen msk F.null, run both stages of an FE.Adversary against the logging key-generation oracle E.keyGen msk flanking a single challenge encryption of pair.select b, and accept the adversary's guess only when F.admissible holds on the logged function identifiers and F.null.

When the null function F.eval F.null is injective, the admissibility check forces msg₀ = msg₁ on every accepting run, so the two experiments of Attack Game 15.9 have identical output distributions and advantage 0 for every scheme and every adversary ([BS23], Section 15.7, Remark 15.13, p. 661). In particular, the cleartext scheme FE.cleartext F (ciphertext equal to the message and secret key equal to the function identifier) is both Correct and Robust for every functionality F and has semantic-security advantage 0 whenever F.eval F.null is injective.

For a public-key encryption scheme E : PKE PK SK M C and ciphertext-leakage function leak : C → L, E.toFE leak is the functional encryption scheme of Example 15.1 ([BS23], Section 15.7, p. 659, equation (15.33), and p. 660): some () is the identity function identifier I whose secret key is some sk, and none is the null identifier ε whose key none is public and evaluates leak on the ciphertext. E.toFE leak is correct for FE.Functionality.pke len if and only if E is correct and leak c = len m on every honest ciphertext c of m (PKE.toFE_correct_iff). Against an adversary that makes no key-generation queries (FE.Adversary.ofTwoStage A), the semantic-security experiment of E.toFE leak for FE.Functionality.pke len has the same output distribution as the chosen-plaintext experiment E.cpaExperiment with admissibility rule len m₀ = len m₁ (PKE.eval_ssExperiment_toFE_ofTwoStage).

Design decisions and deviations from [BS23], Section 15.7:

  1. Both F.eval and E.decrypt return Option Y, where Y is the book's output set without ⊥: none represents ⊥ in F.eval and represents both ⊥ and reject in E.decrypt. This does not affect FE.Correct or FE.ssExperiment. For FE.Robust, a scheme that is robust in the book's sense (with both ⊥ and reject mapped to none) satisfies FE.Robust, whereas the converse can fail for a scheme whose decryption outputs ⊥ where the functionality has a value; a scheme whose decryption never outputs ⊥ loses nothing.
  2. The challenger enforces the query restriction at the end of the experiment by returning guess && F.admissible ((log₁ ++ log₂).map Prod.fst) pair, so an inadmissible run returns false in both experiments (matching lrExperiment), because a post-challenge key query in stage 2 can violate the restriction on the challenge pair.
  3. The adversary makes a single challenge encryption query between its two stages (choose and guess), matching the book's restriction to a single encryption query.
  4. The null identifier null : Fn (ε) is bundled in FE.Functionality; FE.Correct and FE.Robust do not depend on null, while FE.ssExperiment generates sk_ε from it and includes it in FE.Functionality.admissible.
  5. Remark 15.13 (FE.eval_ssExperiment_eq_of_injective_null and FE.advantage_ssExperiment_eq_zero_of_injective_null) is proved under the hypothesis that F.eval F.null is injective, for every scheme and every adversary without assuming one-wayness or an asymptotic security definition.
  6. The Remark 15.13 scheme is named FE.cleartext rather than trivial because Exercise 15.21 ("The trivial functional encryption scheme", p. 679) refers to a different construction.
  7. In Example 15.1 (FE.Functionality.pke and PKE.toFE), the two-element identifier set {I, ε} is modeled as Option Unit (some () for I, none for ε), the output type is M ⊕ L so that the message and its leakage len m have disjoint tags, and the secret-key type is Option SK.
  8. As in PKE, FE and FE.Adversary are typed records for one fixed scheme without an asymptotic security parameter or efficiency predicate; FE.Adversary.ofTwoStage and PKE.eval_ssExperiment_toFE_ofTwoStage compare the two experiments and carry no efficiency claim or security reduction.
  9. The key-generation field is named keyGen after the book's key generation algorithm G.

Not formalized here: Definition 15.14 as an asymptotic security predicate over scheme families and efficient typed oracle adversaries (#4894), a security reduction between PKE.toFE and IND-CPA, Example 15.2 (identity-based encryption as functional encryption, equation (15.34), p. 659), Exercises 15.21 and 15.22 (pp. 679–681), the concrete functionality families of Section 15.7.1, chosen-ciphertext security for functional encryption (pp. 661–662), and multi-challenge encryption queries.

Main definitions #

Main results #

References #

structure Cslib.Crypto.FE (MPK MSK Fn SK M C Y : Type) :

A functional encryption scheme ([BS23], Section 15.7, Definition 15.13, pp. 658–659) with master public keys MPK, master secret keys MSK, function identifiers Fn, function secret keys SK, messages M, ciphertexts C and outputs Y. Both the functionality's ⊥ and decryption rejection are represented by none : Option Y.

  • setup : ProbComp (MPK × MSK)

    Setup algorithm S: draw a master public key and a master secret key.

  • keyGen : MSK → Fn → ProbComp SK

    Key generation algorithm G: derive a secret key for function identifier f from the master secret key.

  • encrypt : MPK → M → ProbComp C

    Encryption algorithm E: encrypt a message under the master public key.

  • decrypt : SK → C → Option Y

    Deterministic decryption algorithm D: evaluate a function secret key on a ciphertext, returning none for ⊥ or rejection.

A functionality F : Fn × M → Y ∪ {⊥} (none is ⊥) bundled with its distinguished null function identifier null (ε), whose secret key is given to every party to model intentional ciphertext leakage ([BS23], Section 15.7, Definition 15.13, p. 658, and p. 660).

  • eval : Fn → M → Option Y

    Evaluate function identifier f on message m; none represents ⊥ (decryption is unconstrained).

  • null : Fn

    The null function identifier ε whose secret key sk_ε is public.

def Cslib.Crypto.FE.Correct {MPK MSK Fn SK M C Y : Type} (E : FE MPK MSK Fn SK M C Y) (F : Functionality Fn M Y) :

Correctness of a functional encryption scheme for a functionality F ([BS23], Section 15.7, Definition 15.13, p. 659): for every supported master key pair, every function identifier f, every message m and every output y with F.eval f m = some y, decrypting any supported encryption of m under any supported key for f yields some y.

def Cslib.Crypto.FE.Robust {MPK MSK Fn SK M C Y : Type} (E : FE MPK MSK Fn SK M C Y) (F : Functionality Fn M Y) :

Robustness of a functional encryption scheme for a functionality F ([BS23], Section 15.7, Definition 15.15, p. 661): for every supported master key pair and every ciphertext c, there is a message m such that for every function identifier f and every supported secret key sk for f, if E.decrypt sk c = some y and F.eval f m = some y', then y = y'.

Because E.decrypt uses none for both ⊥ and reject, the book's robustness implies FE.Robust; the converse fails for a scheme whose decryption outputs ⊥ where the functionality has a value (a scheme whose decryption never outputs ⊥ loses nothing).

structure Cslib.Crypto.FE.Adversary (MPK Fn SK M C σ : Type) :

An adversary in the single-challenge semantic-security game for functional encryption ([BS23], Section 15.7, Attack Game 15.9, pp. 660–661). Both stages are oracle programs over the key-generation oracle Fn → SK: choose receives the master public key and a null key sk_ε and outputs a challenge message pair together with state σ; guess receives that state and the challenge ciphertext and outputs a Boolean guess.

  • choose : MPK → SK → ProbOracleComp (fun (x : Fn) => SK) (MessagePair M × σ)

    Stage 1: given mpk and sk_ε, query the key-generation oracle and output a challenge message pair and saved state.

  • guess : σ → C → ProbOracleComp (fun (x : Fn) => SK) Bool

    Stage 2: given the saved state and challenge ciphertext, query the key-generation oracle and output a Boolean guess.

def Cslib.Crypto.FE.Functionality.admissible {Fn M Y : Type} [DecidableEq Y] (F : Functionality Fn M Y) (queried : List Fn) (pair : MessagePair M) :

The query restriction of Attack Game 15.9 ([BS23], Section 15.7, p. 660): the null identifier F.null (ε) and every queried function identifier in queried agree on pair.msg₀ and pair.msg₁.

def Cslib.Crypto.FE.ssExperiment {MPK MSK Fn SK M C Y σ : Type} [DecidableEq Y] (E : FE MPK MSK Fn SK M C Y) (F : Functionality Fn M Y) (A : Adversary MPK Fn SK M C σ) (b : Bool) :

Experiment b of Attack Game 15.9 ([BS23], Section 15.7, pp. 660–661) for a single encryption query: generate (mpk, msk) and the null key skNull ← E.keyGen msk F.null, run A.choose mpk skNull and A.guess state challenge against the logged key-generation oracle E.keyGen msk around the challenge encryption of pair.select b, and return guess gated by F.admissible on all queried function identifiers and F.null.

theorem Cslib.Crypto.FE.Functionality.admissible_eq_false_of_null {Fn M Y : Type} [DecidableEq Y] (F : Functionality Fn M Y) (queried : List Fn) (pair : MessagePair M) (h : F.eval F.null pair.msg₀ ≠ F.eval F.null pair.msg₁) :
F.admissible queried pair = false

If the null function F.eval F.null distinguishes pair.msg₀ from pair.msg₁, then pair is inadmissible under Attack Game 15.9 ([BS23], Section 15.7, p. 660) regardless of which key queries were made.

theorem Cslib.Crypto.FE.eval_ssExperiment_eq_of_injective_null {MPK MSK Fn SK M C Y σ : Type} [DecidableEq Y] (E : FE MPK MSK Fn SK M C Y) (F : Functionality Fn M Y) (hF : Function.Injective (F.eval F.null)) (A : Adversary MPK Fn SK M C σ) :

If the null function F.eval F.null is injective, the two experiments of Attack Game 15.9 have the same output distribution for every scheme and every adversary, because any admissible challenge pair must satisfy msg₀ = msg₁ ([BS23], Section 15.7, Remark 15.13, p. 661).

theorem Cslib.Crypto.FE.advantage_ssExperiment_eq_zero_of_injective_null {MPK MSK Fn SK M C Y σ : Type} [DecidableEq Y] (E : FE MPK MSK Fn SK M C Y) (F : Functionality Fn M Y) (hF : Function.Injective (F.eval F.null)) (A : Adversary MPK Fn SK M C σ) :

If the null function F.eval F.null is injective, every adversary has semantic-security advantage 0 against every functional encryption scheme for F ([BS23], Section 15.7, Remark 15.13, p. 661).

Remark 15.13: the cleartext scheme #

def Cslib.Crypto.FE.cleartext {Fn M Y : Type} (F : Functionality Fn M Y) :
FE Unit Unit Fn Fn M M Y

The cleartext functional encryption scheme of [BS23], Section 15.7, Remark 15.13, p. 661: encryption outputs the message m in the clear, a secret key for f is f itself, and decryption evaluates F.eval f on the ciphertext.

The cleartext scheme cleartext F is correct for every functionality F ([BS23], Section 15.7, Definition 15.13 and Remark 15.13, pp. 659, 661).

theorem Cslib.Crypto.FE.cleartext_robust {Fn M Y : Type} (F : Functionality Fn M Y) :

The cleartext scheme cleartext F is robust for every functionality F ([BS23], Section 15.7, Definition 15.15 and Remark 15.13, p. 661).

Example 15.1: public-key encryption #

def Cslib.Crypto.FE.Functionality.pke {M L : Type} (len : M → L) :

The public-key encryption functionality of [BS23], Section 15.7, Example 15.1, equation (15.33), p. 659, extended with the null identifier of p. 660: some () is the identity identifier I returning Sum.inl m, and none is the null identifier ε returning the message leakage Sum.inr (len m).

theorem Cslib.Crypto.FE.advantage_ssExperiment_pke_eq_zero {MPK MSK SK M C σ L : Type} [DecidableEq M] [DecidableEq L] (E : FE MPK MSK (Option Unit) SK M C (M ⊕ L)) {π : M → L} (hπ : Function.Injective π) (A : Adversary MPK (Option Unit) SK M C σ) :

When the null leakage π in Functionality.pke π is injective, every adversary has semantic-security advantage 0 against every scheme for Functionality.pke π ([BS23], Section 15.7, Remark 15.13, p. 661).

def Cslib.Crypto.FE.Adversary.ofTwoStage {MPK Fn SK M C σ : Type} (A : TwoStage MPK (MessagePair M) C Bool σ) :
Adversary MPK Fn SK M C σ

Lift a TwoStage chosen-plaintext adversary to an FE.Adversary that ignores the null key and makes no key-generation queries ([BS23], Section 15.7, Example 15.1 and Attack Game 15.9, pp. 659–661). This checks the new game against the chosen-plaintext experiment already in the library; it is not a reduction, carries no efficiency claim, and closes no security item.

def Cslib.Crypto.PKE.toFE {PK SK M C L : Type} (E : PKE PK SK M C) (leak : C → L) :
FE PK SK (Option Unit) (Option SK) M C (M ⊕ L)

View a public-key encryption scheme E as a functional encryption scheme ([BS23], Section 15.7, Example 15.1, p. 659, and p. 660): the full key for some () is some sk, which decrypts with E.decrypt sk, and the null key for none is none, which reads leak c off the ciphertext.

theorem Cslib.Crypto.PKE.toFE_correct_iff {PK SK M C L : Type} (E : PKE PK SK M C) (len : M → L) (leak : C → L) :
(E.toFE leak).Correct (FE.Functionality.pke len) ↔ E.Correct ∧ ∀ keys ∈ E.keyGen.eval.support, ∀ (m : M), ∀ c ∈ (E.encrypt keys.1 m).eval.support, leak c = len m

E.toFE leak is a correct functional encryption scheme for FE.Functionality.pke len if and only if E is a correct public-key scheme and leak c = len m for every honestly generated key pair and every honest encryption c of m ([BS23], Section 15.7, Definition 15.13 and Example 15.1, p. 659, and p. 660).

theorem Cslib.Crypto.PKE.eval_ssExperiment_toFE_ofTwoStage {PK SK M C L σ : Type} [DecidableEq M] [DecidableEq L] (E : PKE PK SK M C) (len : M → L) (leak : C → L) (A : TwoStage PK (MessagePair M) C Bool σ) (b : Bool) :
ProbComp.eval ((E.toFE leak).ssExperiment (FE.Functionality.pke len) (FE.Adversary.ofTwoStage A) b) = ProbComp.eval (E.cpaExperiment (fun (x : PK) (m₀ m₁ : M) => decide (len m₀ = len m₁)) A b)

Played against an adversary FE.Adversary.ofTwoStage A that makes no key-generation queries, Attack Game 15.9 for E.toFE leak and FE.Functionality.pke len has the same output distribution as Attack Game 11.1 (E.cpaExperiment) with admissibility rule len m₀ = len m₁ ([BS23], Section 15.7, Example 15.1 and Attack Game 15.9, pp. 659–661, and Section 11.2, Attack Game 11.1, p. 436). This checks the new game against the chosen-plaintext experiment already in the library; it is not a reduction, carries no efficiency claim, and closes no security item.