Documentation

CslibFrontier.Crypto.Primitives.SDitH.TweakSalt

SDitH tweakable salts #

SDitH v3 Algorithm 5 copies a lambda-bit salt, replaces its low 24 bits with the little-endian encoding of a tweak, and reserves high bits for domain separation. The hash-based grinding variant stores a tag in the highest bit. The cipher-based grinding variant clears the highest bit and stores its tag in the next-highest bit.

This module formalizes only that deterministic TweakSalt subroutine. It does not implement the counter-mode PRG, seed expansion, the SDitH protocol, or a signature security theorem. It is a function-level specification, not a native machine implementation: later consumers must certify the cost of producing the lambda-bit result and carry that time, output-size, and program-size cost through their reductions. It proves neither asymptotic scheme-family security nor finite instantiated candidate/parameter-set advantage bounds.

Main definitions #

Main results #

References #

The two grinding branches distinguished by SDitH v3 Algorithm 5.

def Cslib.Crypto.SDitH.tweakSalt (variant : GrindingVariant) {securityBits : ℕ} (salt : BitString securityBits) (tweak : Fin (2 ^ 24)) (tag : Bool) :
BitString securityBits

SDitH v3 Algorithm 5, TweakSalt.

The source assignments are interpreted in their listed order: a high domain-separation tag overrides a low tweak bit if the coordinates overlap. The standard parameter sets have securityBits >= 128; the useful exactness and injectivity results below assume only 26 <= securityBits, which keeps the low 24 tweak coordinates disjoint from both high tags.

theorem Cslib.Crypto.SDitH.tweakSalt_low (variant : GrindingVariant) {securityBits : ℕ} (hsecurity : 26 ≤ securityBits) (salt : BitString securityBits) (tweak : Fin (2 ^ 24)) (tag : Bool) (i : Fin securityBits) (hi : ↑i < 24) :
tweakSalt variant salt tweak tag i = (↑tweak).testBit ↑i

The low 24 bits of a sufficiently wide tweaked salt are the source's little-endian tweak.

@[simp]
theorem Cslib.Crypto.SDitH.tweakSalt_hash_high {securityBits : ℕ} (hsecurity : 26 ≤ securityBits) (salt : BitString securityBits) (tweak : Fin (2 ^ 24)) (tag : Bool) :
tweakSalt GrindingVariant.hashBased salt tweak tag ⟨securityBits - 1, ⋯⟩ = tag

The hash-based branch puts tag in the highest salt bit.

@[simp]
theorem Cslib.Crypto.SDitH.tweakSalt_cipher_high {securityBits : ℕ} (hsecurity : 26 ≤ securityBits) (salt : BitString securityBits) (tweak : Fin (2 ^ 24)) (tag : Bool) :
tweakSalt GrindingVariant.cipherBased salt tweak tag ⟨securityBits - 1, ⋯⟩ = false

The cipher-based branch clears the highest salt bit.

@[simp]
theorem Cslib.Crypto.SDitH.tweakSalt_cipher_nextHigh {securityBits : ℕ} (hsecurity : 26 ≤ securityBits) (salt : BitString securityBits) (tweak : Fin (2 ^ 24)) (tag : Bool) :
tweakSalt GrindingVariant.cipherBased salt tweak tag ⟨securityBits - 2, ⋯⟩ = tag

The cipher-based branch puts tag in the next-highest salt bit.

theorem Cslib.Crypto.SDitH.tweakSalt_hash_middle {securityBits : ℕ} (salt : BitString securityBits) (tweak : Fin (2 ^ 24)) (tag : Bool) (i : Fin securityBits) (hlow : 24 ≤ ↑i) (hhigh : ↑i ≠ securityBits - 1) :
tweakSalt GrindingVariant.hashBased salt tweak tag i = salt i

Away from the low tweak and highest tag coordinates, the hash-based branch preserves the salt.

theorem Cslib.Crypto.SDitH.tweakSalt_cipher_middle {securityBits : ℕ} (salt : BitString securityBits) (tweak : Fin (2 ^ 24)) (tag : Bool) (i : Fin securityBits) (hlow : 24 ≤ ↑i) (hnext : ↑i ≠ securityBits - 2) (hhigh : ↑i ≠ securityBits - 1) :
tweakSalt GrindingVariant.cipherBased salt tweak tag i = salt i

Away from the low tweak and two highest tag coordinates, the cipher-based branch preserves the salt.

theorem Cslib.Crypto.SDitH.tweakSalt_injective (variant : GrindingVariant) {securityBits : ℕ} (hsecurity : 26 ≤ securityBits) (salt : BitString securityBits) :
Function.Injective fun (input : Fin (2 ^ 24) × Bool) => tweakSalt variant salt input.1 input.2

For a fixed salt and grinding branch, the tweak and domain-separation tag are recoverable from the transformed salt.