Documentation

CatCryptCore.Examples.Cryptobox.Scheme

Cryptobox Scheme Definitions #

Abstract type definitions and scheme records for NaCl's Cryptobox construction. Cryptobox combines a Non-Interactive Key Exchange (NIKE, e.g., X25519) with a Nonce-Based Symmetric Encryption Scheme (NBSES, e.g., XSalsa20-Poly1305) to achieve Public-Key Authenticated Encryption (PKAE).

Main definitions #

Design choices #

Following the Rocq SSProve Cryptobox (nominal-ssprove), all key types (PK, SK, SharedKey) are Fintype to enable uniform sampling. Messages and ciphertexts are also Fintype for simplicity (the Rocq version uses choice_type which allows infinite types, but Lean's SPComp.sample requires Fintype).

All scheme operations are pure SPComp computations (no state). State is introduced only in the game definitions (PKEY, KEY, SAE, etc.).

References #

Abstract types #

These are parameters throughout the Cryptobox formalization. Each file will declare the necessary variables.

Abstract type bundle for Cryptobox. All types are finite (for uniform sampling) and have decidable equality (for map lookups and equality checks in games).

Instances

    Nonce-Based Symmetric Encryption Scheme (NBSES) #

    Corresponds to Rocq's NBSES_scheme. In NaCl, this is XSalsa20-Poly1305. All operations are pure SPComp (no state, no oracle access).

    Nonce-Based Symmetric Encryption Scheme. Parameterized by a CryptoTypes instance providing the abstract types.

    Instances For

      Non-Interactive Key Exchange (NIKE) #

      Corresponds to Rocq's NIKE_scheme. In NaCl, this is X25519. The shared key computation is deterministic (pure function).

      Non-Interactive Key Exchange scheme.

      Instances For

        Key Injection #

        Corresponds to Rocq's inj record. Maps between NIKE shared keys and NBSES shared keys. In practice, this is often the identity or a hash.

        Injection between key spaces (NIKE shared keys ↔ NBSES shared keys). Allows composing NIKE and NBSES even if their key types differ abstractly.

        Instances For

          Session Identifiers (SID) #

          A session ID is a canonical pair of public keys identifying a communication session between two parties. The canonical ordering ensures both parties compute the same SID regardless of who is sender/receiver.

          Canonical sort for session IDs. Ensures sortSID pk_a pk_b = sortSID pk_b pk_a.

          Equations
          Instances For

            sortSID is symmetric: the order of arguments doesn't matter.

            NIKE Commutativity #

            The key property for Cryptobox: the shared key is the same regardless of which party acts as sender/receiver. This is stated as a property of (NIKEScheme, pkgen output) pairs rather than as a field of NIKEScheme, following the Rocq approach.

            NIKE commutativity: shared key is the same regardless of role. For honestly generated key pairs (pk_a, sk_a) and (pk_b, sk_b): sharedkey pk_a sk_b = sharedkey pk_b sk_a

            Equations
            • One or more equations did not get rendered due to their size.
            Instances For

              Nonce-Based Public-key Encryption Scheme (NBPES/PKAE) #

              The target construction: public-key authenticated encryption. Corresponds to Rocq's NBPES_scheme.

              Nonce-Based Public-key Encryption Scheme (PKAE target).

              Instances For

                Cryptobox Construction #

                The main construction: combine NIKE + NBSES into a PKAE scheme.

                Construct a PKAE scheme from NIKE + NBSES + key injection. This is the Cryptobox construction:

                • pkgen = NIKE.pkgen
                • enc(sk_s, pk_r, m, n) = NBSES.enc(inj(NIKE.sharedkey(pk_r, sk_s)), m, n)
                • dec(sk_r, pk_s, c, n) = NBSES.dec(inj(NIKE.sharedkey(pk_s, sk_r)), c, n)
                Equations
                • One or more equations did not get rendered due to their size.
                Instances For

                  Operation identifiers #

                  Fixed natural number identifiers for each oracle operation. These correspond to the Rocq operation IDs and are used for interface matching in the package system.

                  Operation ID for key generation

                  Equations
                  Instances For

                    Operation ID for corrupt set public key

                    Equations
                    Instances For

                      Operation ID for get secret key

                      Equations
                      Instances For

                        Operation ID for check honest public key

                        Equations
                        Instances For

                          Operation ID for NIKE shared key computation

                          Equations
                          Instances For

                            Operation ID for honest key set

                            Equations
                            Instances For

                              Operation ID for corrupt key set

                              Equations
                              Instances For

                                Operation ID for key get

                                Equations
                                Instances For

                                  Operation ID for honesty check

                                  Equations
                                  Instances For

                                    Operation ID for encryption

                                    Equations
                                    Instances For

                                      Operation ID for decryption

                                      Equations
                                      Instances For