• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
      • Apt
      • Zfc
      • Acre
      • Milawa
      • Smtlink
      • Abnf
      • Vwsim
      • Isar
      • Wp-gen
      • Dimacs-reader
      • Pfcs
      • Legacy-defrstobj
      • Proof-checker-array
      • Soft
      • C
      • Farray
      • Rp-rewriter
      • Instant-runoff-voting
      • Imp-language
      • Sidekick
      • Leftist-trees
      • Java
      • Taspi
      • Bitcoin
      • Riscv
      • Des
      • Ethereum
      • X86isa
      • Sha-2
      • Yul
      • Zcash
      • Proof-checker-itp13
      • Regex
      • ACL2-programming-language
      • Json
      • Jfkr
      • Equational
      • Cryptography
      • Poseidon
        • Poseidon-main-definition
          • Param
          • Hashp
          • Absorb1
          • Sponge
          • Hash
          • All-rounds
          • Sponge-validp
          • Squeeze1
          • Sub-words-partial
          • Squeeze
          • Round
          • Partial-rounds
          • Mode
          • Full-rounds
          • Permute
          • Sub-words
          • Add-round-constants
            • Mix-layer
            • Dot-product
            • Absorb
            • Pow-by-alpha
            • Param->size
            • Sub-words-full
            • Param->capacity-then-rate-p
            • Param->partial-last-p
            • Param-additional-theorems
            • Param->rounds
            • Param->descending-p
            • Init-sponge
          • Poseidon-instantiations
        • Where-do-i-place-my-book
        • Axe
        • Bigmems
        • Builtins
        • Execloader
        • Aleo
        • Solidity
        • Paco
        • Concurrent-programs
        • Bls12-377-curves
      • Debugging
      • Std
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Poseidon-main-definition

    Add-round-constants

    Add round constants to the state vector.

    Signature
    (add-round-constants stat constants prime) → new-stat
    Arguments
    stat — Guard (fe-listp stat prime).
    constants — Guard (fe-listp constants prime).
    prime — Guard (primep prime).
    Returns
    new-stat — Type (fe-listp new-stat prime), given (posp prime).

    This is the \mathit{AddRoundConstants} function in the paper.

    Besides the state, it needs the constants for the round, in number that matches the state vector.

    This could be a more general ACL2 function to add two vectors of field elements.

    Definitions and Theorems

    Function: add-round-constants

    (defun add-round-constants (stat constants prime)
      (declare (xargs :guard (and (primep prime)
                                  (fe-listp stat prime)
                                  (fe-listp constants prime))))
      (declare (xargs :guard (equal (len constants) (len stat))))
      (let ((__function__ 'add-round-constants))
        (declare (ignorable __function__))
        (cond ((endp stat) nil)
              (t (cons (add (car stat) (car constants) prime)
                       (add-round-constants (cdr stat)
                                            (cdr constants)
                                            prime))))))

    Theorem: fe-listp-of-add-round-constants

    (defthm fe-listp-of-add-round-constants
      (implies
           (posp prime)
           (b* ((new-stat (add-round-constants stat constants prime)))
             (fe-listp new-stat prime)))
      :rule-classes :rewrite)

    Theorem: len-of-add-round-constants

    (defthm len-of-add-round-constants
      (b* ((?new-stat (add-round-constants stat constants prime)))
        (equal (len new-stat) (len stat))))