Documentation

CslibFrontier.Crypto.Primitives.SLHDSA.Address

SLH-DSA addresses #

This module formalizes the address (ADRS) formats from FIPS 205, Sections 4.2--4.4, Figures 2--9 and Table 1. An address consists of a 32-bit layer address, a 96-bit tree address, a 32-bit type, and three 32-bit type-dependent words. Address.setTypeAndClear implements the standard's requirement that changing the type clears the final 12 bytes.

Address.toBits is the canonical 32-byte, big-endian encoding used by the SHAKE parameter sets, and Address.toBytes gives its typed byte view. The SHA2 parameter sets instead use the 22-byte compressed address Address.toCompressedBits from FIPS 205, Section 11.2, Figure 18 and Table 3; Address.toCompressedBytes gives its typed byte view. Compression retains only one byte of the layer, eight bytes of the tree, and one byte of the type. Address.FitsCompressed records the bounds under which that projection is injective; the unrestricted compressed encoding is deliberately not claimed to be injective.

This is only the address-domain layer. It does not define the FIPS 205 hash instantiations, WOTS+, XMSS, FORS, the hypertree, signing or verification, or any security reduction.

Main definitions #

Main results #

References #

@[reducible, inline]

One four-byte FIPS 205 address word.

@[reducible, inline]

The three-word tree address in an SLH-DSA address.

The seven address types from FIPS 205, Section 4.2, Figures 3--9.

  • wotsHash : AddressType

    A hash step within a WOTS+ chain (type 0).

  • wotsPK : AddressType

    WOTS+ public-key compression (type 1).

  • tree : AddressType

    A hash-tree node within XMSS (type 2).

  • forsTree : AddressType

    A node within one of the FORS trees (type 3).

  • forsRoots : AddressType

    Compression of the FORS roots (type 4).

  • wotsPRF : AddressType

    Generation of a WOTS+ secret value (type 5).

  • forsPRF : AddressType

    Generation of a FORS secret value (type 6).

Instances For

    The integer type code specified by FIPS 205.

    Every FIPS 205 address-type code fits in one byte.

    The type code as a four-byte address word.

    Distinct address types have distinct FIPS 205 integer codes.

    The big-endian bits of one four-byte address word.

    @[simp]

    A serialized four-byte address word has 32 bits.

    @[simp]

    Reading a serialized four-byte address word recovers its unsigned value.

    The big-endian bits of the 12-byte tree address.

    @[simp]

    A serialized tree address has 96 bits.

    @[simp]

    Reading a serialized tree address recovers its unsigned value.

    A FIPS 205 address as its common fields and three type-dependent words.

    The field names word5, word6, and word7 refer to their zero-based positions in the eight-word address. Their meanings are fixed by addressType; use the typed constructors below to obtain a well-formed address for a particular purpose.

    • layerAddress : AddressWord

      The XMSS layer, stored in word 0.

    • treeAddress : TreeAddress

      The XMSS tree within the layer, stored in words 1--3.

    • addressType : AddressType

      The address type, stored in word 4.

    • word5 : AddressWord

      The first type-dependent word.

    • word6 : AddressWord

      The second type-dependent word.

    • word7 : AddressWord

      The third type-dependent word.

    Instances For
      theorem Cslib.Crypto.SLHDSA.Address.ext {a b : Address} (hlayer : a.layerAddress = b.layerAddress) (htree : a.treeAddress = b.treeAddress) (htype : a.addressType = b.addressType) (h5 : a.word5 = b.word5) (h6 : a.word6 = b.word6) (h7 : a.word7 = b.word7) :
      a = b

      Two addresses are equal when all seven semantic fields agree.

      The big-endian four-byte encoding of an address type.

      @[simp]

      A serialized address type occupies one four-byte word.

      The canonical 32-byte encoding of an address (FIPS 205, Figure 2 and Table 1).

      @[simp]

      A canonical SLH-DSA address encoding is exactly 32 bytes.

      The canonical address as exactly 32 big-endian bytes.

      The canonical 32-byte address encoding is injective.

      The canonical 32-byte encoding is injective for arbitrary addresses.

      The 22-byte compressed address used by the FIPS 205 SHA2 parameter sets.

      This is ADRS[3] || ADRS[8:16] || ADRS[19] || ADRS[20:32]: the low byte of the layer, the low eight bytes of the tree, the low byte of the type, and all three type-dependent words.

      @[simp]

      A SHA2 compressed address encoding is exactly 22 bytes.

      The compressed SHA2 address as exactly 22 big-endian bytes.

      If a layer address fits in the retained byte, reading that byte recovers it.

      If a tree address fits in the retained eight bytes, reading those bytes recovers it.

      Reading the retained type byte recovers the FIPS 205 type code.

      The bound under which the one-byte layer and eight-byte tree fields of the compressed SHA2 address lose no information. FIPS 205 parameter sets satisfy these bounds at every call site.

      Instances For

        Compressed SHA2 address serialization is injective when neither shortened field overflows.

        The compressed 22-byte encoding is injective when neither shortened field overflows.

        Set the layer address, preserving every other word.

        Set the 12-byte tree address, preserving every other word.

        Change the address type and clear all three type-dependent words (FIPS 205, Section 4.3).

        Set the key-pair address in word 5.

        Set the WOTS+ chain address in word 6.

        Set the tree height in word 6.

        Set the WOTS+ hash address in word 7.

        Set the tree index in word 7.

        @[simp]

        Changing the type preserves the layer and tree fields.

        @[simp]

        Changing the type sets the requested type and clears all final 12 bytes.

        The padding and fixed-field requirements of FIPS 205, Figures 3--9.

        Instances For
          def Cslib.Crypto.SLHDSA.Address.wotsHash (layer : AddressWord) (tree : TreeAddress) (keyPair chain hash : AddressWord) :

          A WOTS+ hash-chain address (FIPS 205, Figure 3).

          A WOTS+ public-key compression address (FIPS 205, Figure 4).

          An XMSS hash-tree address (FIPS 205, Figure 5).

          A FORS tree address (FIPS 205, Figure 6). The FORS layer is fixed to zero.

          A FORS roots-compression address (FIPS 205, Figure 7).

          A WOTS+ secret-value generation address (FIPS 205, Figure 8).

          A FORS secret-value generation address (FIPS 205, Figure 9).

          @[simp]
          theorem Cslib.Crypto.SLHDSA.Address.wellFormed_wotsHash (layer : AddressWord) (tree : TreeAddress) (keyPair chain hash : AddressWord) :
          (wotsHash layer tree keyPair chain hash).WellFormed
          @[simp]
          theorem Cslib.Crypto.SLHDSA.Address.wellFormed_wotsPK (layer : AddressWord) (tree : TreeAddress) (keyPair : AddressWord) :
          (wotsPK layer tree keyPair).WellFormed
          @[simp]
          theorem Cslib.Crypto.SLHDSA.Address.wellFormed_tree (layer : AddressWord) (treeAddress : TreeAddress) (height index : AddressWord) :
          (tree layer treeAddress height index).WellFormed
          @[simp]
          theorem Cslib.Crypto.SLHDSA.Address.wellFormed_forsTree (tree : TreeAddress) (keyPair height index : AddressWord) :
          (forsTree tree keyPair height index).WellFormed
          @[simp]
          theorem Cslib.Crypto.SLHDSA.Address.wellFormed_wotsPRF (layer : AddressWord) (tree : TreeAddress) (keyPair chain : AddressWord) :
          (wotsPRF layer tree keyPair chain).WellFormed
          @[simp]
          theorem Cslib.Crypto.SLHDSA.Address.wellFormed_forsPRF (tree : TreeAddress) (keyPair index : AddressWord) :
          (forsPRF tree keyPair index).WellFormed