• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
      • Apt
      • Zfc
      • Acre
      • Milawa
      • Smtlink
      • Abnf
      • Vwsim
      • Isar
      • Wp-gen
      • Dimacs-reader
      • Pfcs
      • Legacy-defrstobj
      • C
      • Proof-checker-array
      • Soft
      • Farray
      • Rp-rewriter
      • Instant-runoff-voting
      • Imp-language
      • Sidekick
      • Ethereum
        • Mmp-trees
        • Semaphore
        • Database
        • Cryptography
        • Rlp
        • Transactions
        • Hex-prefix
        • Basics
        • Addresses
          • Public-key-to-address
            • Private-key-to-address
        • Leftist-trees
        • Java
        • Riscv
        • Taspi
        • Bitcoin
        • Zcash
        • Des
        • X86isa
        • Sha-2
        • Yul
        • Proof-checker-itp13
        • Regex
        • ACL2-programming-language
        • Json
        • Jfkr
        • Equational
        • Cryptography
        • Axe
        • Poseidon
        • Where-do-i-place-my-book
        • Aleo
        • Bigmems
        • Builtins
        • Execloader
        • Solidity
        • Paco
        • Concurrent-programs
        • Bls12-377-curves
      • Debugging
      • Community
      • Std
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • 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)