• 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
        • Mmp-trees
        • Semaphore
          • Verify-semaphore-r1cs
          • Mimc
          • Semaphore-specification
            • Prime-field-abbreviations
            • Pedersen-hash
              • Pedersen-scalar
              • Pedersen-generator
              • Pedersen-enc
                • Pedersen-pad
                • Pedersen
                • Pedersen-addend
              • Pedersen-hash-base-points
              • Baby-jubjub
            • Semaphore-proofs
          • Database
          • Cryptography
          • Rlp
          • Transactions
          • Hex-prefix
          • Basics
          • Addresses
        • X86isa
        • Sha-2
        • Yul
        • Zcash
        • Proof-checker-itp13
        • Regex
        • ACL2-programming-language
        • Json
        • Jfkr
        • Equational
        • Cryptography
        • Poseidon
        • 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
    • Pedersen-hash

    Pedersen-enc

    Encode a window of 4 bits.

    Signature
    (pedersen-enc 4bits) → i
    Arguments
    4bits — Guard (bit-listp 4bits).
    Returns
    i — Type (integerp i), given (bit-listp 4bits).

    This is the function \mathit{enc} in [IS], while in [ES] it is part of the double summation.

    There is a discrepancy between [ES] and [IS] in the treatment of the fourth bit: [ES] maps 0 to 1 and 1 to -1, while [IS] maps 0 to -1 and 1 to 1. The Circom code in the Semaphore repository is consistent with [ES], so we follow [ES] here.

    There is also a discrepancy between [ES] and [IS] in the treatment of the other three bits: [IS] adds 1 to their weighted sum, while [ES] does not. The Circom code in the Semaphore repository is consistent with [IS], and we have confirmed with the authors of Semaphore that the sum must include the 1 addend and that [IS] should be fixed, which we have done in Overleaf.

    Definitions and Theorems

    Function: pedersen-enc

    (defun pedersen-enc (4bits)
      (declare (xargs :guard (bit-listp 4bits)))
      (declare (xargs :guard (= (len 4bits) 4)))
      (let ((acl2::__function__ 'pedersen-enc))
        (declare (ignorable acl2::__function__))
        (b* ((b0 (first 4bits))
             (b1 (second 4bits))
             (b2 (third 4bits))
             (b3 (fourth 4bits)))
          (* (if (= b3 0) 1 -1)
             (+ 1 b0 (* 2 b1) (* 4 b2))))))

    Theorem: integerp-of-pedersen-enc

    (defthm integerp-of-pedersen-enc
      (implies (bit-listp 4bits)
               (b* ((i (pedersen-enc 4bits)))
                 (integerp i)))
      :rule-classes :rewrite)