Repository navigation
Description
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 8andzeroState n.Parameters(stateBytes,rateBytes,outputBytes,suffix),Parameters.capacityBytes,Parameters.Valid, helperParameters.valid_of_toNat, and validated standard parameter sets (sha3_224,sha3_256,sha3_384,sha3_512,keccak256).ratePart,capacityPart,digestPart, andabsorbBlockwithcapacityPart_absorbBlockandabsorbBlock_injective.
- Multi-rate
pad10*1padding and rate-block decomposition:paddedBlockCount,spongePadding, andpaddedBlocks, provingspongePadding_length,spongePadding_length_dvd(p.rateBytes ∣ (spongePadding p input).length),spongePadding_injective,flatten_paddedBlocks, andpaddedBlocks_injective.
- Abstract sponge hash and partial-permutation bridge:
spongeHash,spongeCalls, andrecordSpongeover an arbitraryEquiv.Perm (ByteState p.stateBytes), provingrecordSponge_localandinput_eq_of_spongeHash_eq(takingCapacityCollisionFreeandSet.InjOn (digestPart p) (forwardOutputs table)as separate orthogonal hypotheses).
Acceptance criteria
Tests.Spongeverifies:- Boundary
spongePaddingcases on a 4-byte / 2-byte-rate sponge: empty input ([0x06, 0x80]), lengthrateBytes - 1(padZeros = 0OR 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, andkeccak256, plus injectivity ofspongePaddingandpaddedBlocks. - Recording locality (
recordSponge_local) and collision-freeness under decoupled capacity and digest invariants (input_eq_of_spongeHash_eq). #print axiomson key exported theorems confirming dependence only onpropext,Classical.choice, andQuot.sound.
- Boundary
lake build --wfail,scripts/check-sources.sh,scripts/check-axioms.sh, andlake env lean -Dweak.linter.mathlibStandardSet=truepass with zero warnings.
Activity