• Top
    • Documentation
    • Books
    • Recursion-and-induction
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
      • Kestrel-books
        • Crypto-hdwallet
        • Error-checking
        • Apt
        • Abnf
        • Fty-extensions
        • Isar
        • Kestrel-utilities
        • Prime-field-constraint-systems
        • Soft
        • Bv
        • Imp-language
        • Event-macros
        • Bitcoin
        • Ethereum
          • Mmp-trees
          • Semaphore
          • Database
          • Cryptography
          • Rlp
          • Transactions
          • Hex-prefix
          • Basics
          • Addresses
            • Public-key-to-address
              • Private-key-to-address
          • Yul
          • Zcash
          • ACL2-programming-language
          • Prime-fields
          • Java
          • C
          • Syntheto
          • Number-theory
          • Cryptography
          • Lists-light
          • File-io-light
          • Json
          • Built-ins
          • Solidity
          • Axe
          • Std-extensions
          • Htclient
          • Typed-lists-light
          • Arithmetic-light
        • X86isa
        • Execloader
        • Axe
      • Testing-utilities
      • Math
    • Addresses

    Public-key-to-address

    Calculate the address for a public key.

    Signature
    (public-key-to-address pub-key) → address
    Arguments
    pub-key — Guard (secp256k1-pub-key-p pub-key).
    Returns
    address — Type (byte-list20p address).

    The address consists of the rightmost 160 bits of the 256-bit Keccak-256 hash of the serialized public key [YP:(284)]. This is equivalent to the rightmost 20 bytes of the 32-byte hash.

    This function corresponds to ``part of'' the function A [YP:(284)], because it takes a public key as argument, corresponding to \mathtt{ECDSAPUBKEY}(p_\mathrm{r}) in [YP:(284)]. The function \mathtt{ECDSAPUBKEY} returns an array of 64 bytes [YP:(277)] which suggests that the public key is represented as an elliptic curve point in uncompressed form. Thus, we use the library function secp256k1-point-to-bytes to turn the public key into that form.

    The function private-key-to-address calculates an address from a private key instead.

    Definitions and Theorems

    Function: public-key-to-address

    (defun
     public-key-to-address (pub-key)
     (declare (xargs :guard (secp256k1-pub-key-p pub-key)))
     (let
         ((__function__ 'public-key-to-address))
         (declare (ignorable __function__))
         (b* ((pub-key (mbe :logic (secp256k1-pub-key-fix pub-key)
                            :exec pub-key))
              (uncompressed-form (secp256k1-point-to-bytes pub-key nil))
              (hash (keccak-256-bytes uncompressed-form))
              (address (nthcdr 12 hash)))
             address)))

    Theorem: byte-list20p-of-public-key-to-address

    (defthm byte-list20p-of-public-key-to-address
            (b* ((address (public-key-to-address pub-key)))
                (byte-list20p address))
            :rule-classes :rewrite)

    Theorem: public-key-to-address-of-secp256k1-pub-key-fix-pub-key

    (defthm
         public-key-to-address-of-secp256k1-pub-key-fix-pub-key
         (equal (public-key-to-address (secp256k1-pub-key-fix pub-key))
                (public-key-to-address pub-key)))

    Theorem: public-key-to-address-secp256k1-pub-key-equiv-congruence-on-pub-key

    (defthm
     public-key-to-address-secp256k1-pub-key-equiv-congruence-on-pub-key
     (implies (ecurve::secp256k1-pub-key-equiv pub-key pub-key-equiv)
              (equal (public-key-to-address pub-key)
                     (public-key-to-address pub-key-equiv)))
     :rule-classes :congruence)