Skip to content

Add generic byte-oriented sponge construction and pad10*1 injectivity #478

Done

Description

@MarcIlunga

Background

How can ideal-permutation security proofs for byte-oriented sponge hashes (SHA-3, Keccak-256, and custom rate/capacity parameterizations) prove pad10*1 block-alignment, padding injectivity, absorption locality, and collision avoidance without duplicating the byte-vector sponge model per scheme?

Commons.Schemes.Hash.Keccak provides an executable ByteArray / Array UInt64 implementation of concrete Keccak-f[1600], and Commons.Schemes.Sponge.Table (#469) provides the abstract directed partial-permutation edge table. A generic byte-oriented single-squeeze sponge construction parameterized over an arbitrary permutation π : Equiv.Perm (Fin stateBytes → BitVec 8) is needed to connect byte padding and absorption to Commons.Schemes.Sponge.Table.

Proposed change

Add Commons.Schemes.Sponge.Basic (src/Commons/Schemes/Sponge/Basic.lean), building on Commons.Schemes.Sponge.Table:

  • Generic byte states and parameters:
    • ByteState n := Fin n → BitVec 8 and zeroState n.
    • Parameters (stateBytes, rateBytes, outputBytes, suffix), Parameters.capacityBytes, Parameters.Valid, helper Parameters.valid_of_toNat, and validated standard parameter sets (sha3_224, sha3_256, sha3_384, sha3_512, keccak256).
    • ratePart, capacityPart, digestPart, and absorbBlock with capacityPart_absorbBlock and absorbBlock_injective.
  • Multi-rate pad10*1 padding and rate-block decomposition:
    • paddedBlockCount, spongePadding, and paddedBlocks, proving spongePadding_length, spongePadding_length_dvd (p.rateBytes ∣ (spongePadding p input).length), spongePadding_injective, flatten_paddedBlocks, and paddedBlocks_injective.
  • Abstract sponge hash and partial-permutation bridge:
    • spongeHash, spongeCalls, and recordSponge over an arbitrary Equiv.Perm (ByteState p.stateBytes), proving recordSponge_local and input_eq_of_spongeHash_eq (taking CapacityCollisionFree and Set.InjOn (digestPart p) (forwardOutputs table) as separate orthogonal hypotheses).

Acceptance criteria

  • Tests.Sponge verifies:
    • Boundary spongePadding cases on a 4-byte / 2-byte-rate sponge: empty input ([0x06, 0x80]), length rateBytes - 1 (padZeros = 0 OR branch [0x2A, 0x86]), and full-block wrap ([0x11, 0x22, 0x06, 0x80]).
    • Parameter validity and rate-block alignment for sha3_224, sha3_256, sha3_384, sha3_512, and keccak256, plus injectivity of spongePadding and paddedBlocks.
    • Recording locality (recordSponge_local) and collision-freeness under decoupled capacity and digest invariants (input_eq_of_spongeHash_eq).
    • #print axioms on key exported theorems confirming dependence only on propext, Classical.choice, and Quot.sound.
  • lake build --wfail, scripts/check-sources.sh, scripts/check-axioms.sh, and lake env lean -Dweak.linter.mathlibStandardSet=true pass with zero warnings.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions