#private-key #bitcoin #wallet #transaction #address #translation #generate

bitcoinwallet-library

a wallet maintains a set of transactions and balances, and provides the ability to create new transactions

2 releases

0.1.16-alpha.0 Apr 2, 2023
0.1.12-alpha.0 Jan 20, 2023

#90 in #transactions

Download history 29/week @ 2024-08-26 23/week @ 2024-09-02 13/week @ 2024-09-09 26/week @ 2024-09-16 45/week @ 2024-09-23 19/week @ 2024-09-30 30/week @ 2024-10-14 9/week @ 2024-10-21 9/week @ 2024-10-28 27/week @ 2024-11-04 19/week @ 2024-11-18 28/week @ 2024-11-25 26/week @ 2024-12-02 50/week @ 2024-12-09

123 downloads per month
Used in 13 crates (11 directly)

MIT license

5MB
19K SLoC

bitcoinwallet-library

This Rust crate is a direct translation from C++ to Rust of the Bitcoin Core wallet implementation. It provides functions for creating and managing Bitcoin wallets, including generating new private keys, signing transactions, and synchronizing with the Bitcoin network.

Notice: This crate is part of a direct translation from C++ to Rust of the Bitcoin Core. As such, some of the function bodies may still be in the process of translation. Please note that this system will become testable once the translation process is complete.

The following mathematical concepts are associated with some of the tokens used in this crate:

  • Private key: A private key in Bitcoin is a randomly generated 256-bit integer. It is used to generate the public key, which in turn is used to create a Bitcoin address. The private key is also used to sign transactions. The security of the Bitcoin system relies on the fact that it is computationally infeasible to derive the private key from the public key or the Bitcoin address. The equation for generating a Bitcoin public key from a private key is:

    public_key = G * private_key
    

    where G is the generator point of the elliptic curve used in Bitcoin's digital signature algorithm.

  • Public key: A public key in Bitcoin is a point on the elliptic curve generated by multiplying the generator point G by the private key. The public key is used to create a Bitcoin address and to verify the digital signature of a transaction. The equation for verifying a digital signature in Bitcoin is:

    sG = R + eP
    

    where s is the signature, R is the signature's first component, e is the message hash, G is the generator point, and P is the public key.

  • Bitcoin address: A Bitcoin address is a 160-bit hash of the public key. It is used to receive Bitcoin payments. The equation for generating a Bitcoin address from a public key is:

    address = RIPEMD160(SHA256(public_key))
    

    where RIPEMD160 and SHA256 are hash functions used in Bitcoin.

  • Transaction: A transaction in Bitcoin is a signed message that transfers Bitcoin from one address to another. The transaction includes the input(s), which are the Bitcoin(s) to be spent, and the output(s), which are the Bitcoin(s) to be received. The equation for signing a Bitcoin transaction is:

    s = k^(-1)(e + da) mod n
    

    where s is the signature, k is a random number, e is the message hash, d is the private key, a is the ephemeral public key, and n is the order of the elliptic curve.

Dependencies

~104MB
~879K SLoC