#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

#51 in #transactions

Download history 26/week @ 2023-12-18 19/week @ 2023-12-25 6/week @ 2024-01-01 21/week @ 2024-01-08 24/week @ 2024-01-15 9/week @ 2024-02-05 24/week @ 2024-02-12 46/week @ 2024-02-19 52/week @ 2024-02-26 28/week @ 2024-03-04 32/week @ 2024-03-11 37/week @ 2024-03-18 59/week @ 2024-03-25 91/week @ 2024-04-01

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

MIT license

5MB
20K 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
~846K SLoC