Documentation

VCVio.CryptoFoundations.HardnessAssumptions.CollisionResistance

Collision-Resistant Hash Functions #

This file defines collision resistance for unkeyed hash functions and for keyed hash function families, together with their security experiments.

Collision Resistance #

A function f : X → Y is collision-resistant if no efficient adversary can find two distinct inputs x ≠ x' with f x = f x'.

Keyed Hash Function Families #

A keyed hash family samples a public key k : K and the adversary must find a collision under f k. This is the form used in practical constructions and in the Merkle-tree / FRI commitment-scheme setting where the hash key is a protocol parameter.

Main Definitions #

See also #

Unkeyed Collision Resistance #

A collision-resistance adversary outputs a candidate pair of inputs that it hopes form a collision under the target hash function.

Instances For
    def CollisionResistance.crExp {X Y : Type} [DecidableEq X] [DecidableEq Y] (f : XY) (adversary : CRAdversary X) :

    Collision-resistance experiment: the adversary proposes a pair (x, x'), and the experiment returns true iff the two inputs are distinct and map to the same image under f.

    Instances For
      noncomputable def CollisionResistance.crAdvantage {X Y : Type} [DecidableEq X] [DecidableEq Y] (f : XY) (adversary : CRAdversary X) :

      Collision-resistance advantage: the probability that the adversary produces a valid collision for f.

      Instances For

        Keyed Hash Function Families #

        A keyed hash family with key space K, domain X, and range Y. The key-sampling algorithm is probabilistic; the hash itself is a deterministic function of the key and input.

        Instances For

          A keyed CR adversary receives the public key and outputs a candidate collision pair.

          Instances For

            Keyed collision-resistance experiment: sample a key, run the adversary on the key, and return true iff the adversary's pair is a valid collision under H.hash k.

            Instances For
              noncomputable def CollisionResistance.keyedCRAdvantage {X Y K : Type} [DecidableEq X] [DecidableEq Y] (H : KeyedHashFamily K X Y) (adversary : KeyedCRAdversary K X) :

              Keyed collision-resistance advantage: the probability of producing a valid collision under the sampled key.

              Instances For

                ROM-Level Collision Resistance #

                Companion section modelling collision resistance directly in the random-oracle model. A ROM-CR adversary is an oracle computation outputting a candidate collision pair (x, x'), expressed in the adversary-facing ROMHashSpec X Y which carries no probability instances. The experiment lifts the adversary into the post-simulation companion ROMHashSpec.cached X Y (defeq, distinct head symbol) where IsUniformSpec is in scope, then runs it inside cachingOracle and queries the random oracle on both candidates sharing the same cache; it wins iff x ≠ x' and the queried outputs coincide.

                For any t-query ROM-CR adversary the advantage is bounded by the birthday term (t+2) * (t+1) / (2 * |Y|) — a (t+2)-query game once the two verification queries are accounted for.

                Closes one of the layers requested in Verified-zkEVM/VCV-io#284.

                The random-oracle spec with domain X and range Y, as seen by the adversary. Each input x : X is a distinct oracle index returning a value in Y. This pre-cache spec carries no probability instances: a ROM-CR adversary is a syntactic object, and probability semantics only attach to the post-simulation spec ROMHashSpec.cached (defeq, distinct head symbol).

                Instances For

                  The post-simulation companion to ROMHashSpec: definitionally the same OracleSpec X, but with a distinct head symbol so the IsUniformSpec instance below is opted into only where probability reasoning is intended. The adversary's pre-cache computation is converted into a post-cache computation only via simulateQ ROMHashSpec.cachingOracle.

                  Instances For
                    @[reducible, inline]

                    Bridge caching oracle: a QueryImpl that takes adversary-facing ROMHashSpec X Y queries and dispatches them through the generic cachingOracle on the post-cache spec ROMHashSpec.cached X Y. The spec transition from pre to cached happens only here, via simulateQ.

                    Instances For
                      @[simp]

                      Specialised simulateQ_query lemma for the bridge: simulating a single pre-spec query through ROMHashSpec.cachingOracle is the generic cachingOracle action at the post-cache spec. True by rfl because the two specs are definitionally equal as OracleSpec X.

                      A ROM-CR adversary is an oracle computation outputting a candidate collision pair under the random oracle.

                      Instances For

                        A ROM-CR adversary bundled with a total query bound.

                        Instances For

                          ROM collision-resistance experiment: run the adversary inside the ROMHashSpec.cachingOracle bridge from the empty cache, then query the random oracle on both candidate inputs (verification queries share the cache). Win iff the inputs are distinct and the queried outputs coincide. The bridge takes the entire computation from OracleComp (ROMHashSpec X Y) into OracleComp (ROMHashSpec.cached X Y) in one step — no separate oracle-comp lift is needed.

                          Instances For

                            ROM collision-resistance advantage: probability that the adversary produces a valid collision under the random oracle.

                            Instances For
                              theorem CollisionResistance.romCRAdvantage_le_birthday {X Y : Type} [DecidableEq X] [DecidableEq Y] [Fintype Y] [Inhabited X] [Inhabited Y] {t : } (hY : 0 < Fintype.card Y) (A : BoundedROMCRAdversary X Y t) :
                              romCRAdvantage A ↑((t + 2) * (t + 1)) / (2 * (Fintype.card Y))

                              ROM Collision Resistance birthday bound: for any t-query ROM-CR adversary A over a hash range of cardinality |Y| > 0, the advantage is bounded by (t+2) * (t+1) / (2 * |Y|). The two extra queries account for the experiment's verification queries, which share the adversary's cache.