Trunc.lean
Declarations on this page (11)
8-Byte MAC Truncation
DyLean term constructor and attacker deduction rule for 8-byte tag truncation (MAC_LENGTH = 8).
namespace DY.Truncclass CanTrunc8
public
class CanTrunc8 (Bytes: Type u) where
trunc8: (x: Bytes) → Bytesexport CanTrunc8 (trunc8)def trunc8Length
@[expose] public
def trunc8Length := 8namespace Trunc8structure SubF
public
structure SubF (Bytes: Type) where
input: Bytesinstance
public instance: ALaCarte.FunctorSizeOf SubF := .unary SubF.inputinstance
public instance: SubBytesFunctor SubF := .unary SubF.input SubF.mk
def SubF.
@[expose] public
def SubF.length [BytesFunctor]: Bytes.PartialLength SubF :=
fun ⟨input⟩ rec => Nat.min (rec input) trunc8Lengthend Trunc8#combine
#combine into BytesFunctor, BytesLength from
Trunc8,variable [BytesFunctor] [BytesFunctor.Has SubF]
abbrev Trunc8.
public
abbrev Trunc8.SubF.pack (x: Trunc8.SubF Bytes) := BytesView.pack xinstance
public
instance: CanTrunc8 Bytes where
trunc8 input := ({input}: Trunc8.SubF Bytes).pack
def trunc8.
@[expose] public
def trunc8.attackerKnowledge: SubAttackerKnowledge SubF where
pred p out := ∃ inp, out = trunc8 inp ∧ p inp#combine
#combine [BytesFunctor.Has SubF] into attackerKnowledge' from
trunc8,end DY.Trunc