Messing with Bitcoin Keys and Addresses, A Blog by Richard Smooch

Taste the Excitement™

The “bu” instrument is obsolete, which makes this postbode not-so-useful. Look at this opstopping instead.

The directive line utility “bu” (for “Bitcoin utilities”) is included with my Python-based pycoin library. This utility makes it effortless to overeenkomst with Bitcoin private keys and addresses te their native and various intermediate formats. Let’s go through some examples.

The most basic form of a Bitcoin private key is simply an oprecht inbetween 1 and 115792089237316195423570985008687907852837564279074904382605163141518161494336 1.15e77 (inclusive). That’s it! This oprecht is a “secret exponent”, because generating the public key involves exponentiation, and there is no known way to go from the public key to the secret exponent.

Let’s take a look at the very very first private key, also known spil “1”.

You can see from blockchain.informatie that the addresses corresponding to this private key (1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH and 1EHNa6Q4Jz2uvNExL497mE43ikXhwF6kZm) are used a lotsbestemming te tests. Of course, neither has any funds te it (well, at least not at this time), since draining the funds is spil elementary spil injecting one of the WIF values above into a Bitcoin client.

There is a bunch of information here. The secret exponent is displayed ter decimal and te hex.

The corresponding WIF (“wallet invoer format”) key is displayed, both ter compressed and uncompressed format, with this information, you can invoer the corresponding bitcoin address into your client. Note that the WIF simply contains the exponent encoded using “hashed base 58”.

The “hashed base 58” encoding is used to represent an oprecht with a checksum for validity. A 32-bit checksum is appended to the binary form of the rechtschapen, forming another oprecht. This oprecht is then represented ter base 58 using the alphabet of all digits and all letters of the upper and lower case English alphabet except 0, o, O and l (presumably left out because of potential confusion).

So encoding the WIF ter this format truly provides no extra (non-redundant) information beyond the secret exponent.

The public pair x and y correspond to the ECDSA (elliptical curve digital signature algorithm) public key that is used to verify digital signatures. Bitcoin clients use public keys to validate that transactions are signed by an entity that has skill of the corresponding secret exponent. The x, y value is on the elliptical curve used by bitcoin. Te other words

You can check this lightly te Python:

For a given x value, you can rewrite spil y = sqrt(x^3+7) (mod P). Since numbers have two square roots even ter a finite field, there are two values y0 and y1 that sate this equation, where y1 = P – y0. Since P is odd, exactly one of y0 and y1 is even, and the other is odd. Ter other words, with x and skill of whether y is even or odd, wij can figure out the value for y. (This is how compressed keys work. they include the value for x along with a boolean indicating even or odd rather than the total value for y.)

The SEC (“Standards for Efficient Cryptography”) format provides an alternate way of encoding the public key. This is the internal format that Bitcoin uses te transaction signatures to encode public keys. There is an uncompressed format, which has a prefix of a single 04 byte, followed by the x and y coordinates, and a compressed format, which has a prefix of 02 or 03 depending upon whether the y coordinate is even or odd, followed by the x coordinate.

The hash160 value is the ripemd160 hash of the sha256 hash of the bytestream of the sec version of the key.

The Bitcoin address is the hashed base 58 representation of the hash160 value.

The bu utility will accept input te almost any format, automatically determining the input type, and display output of all values that can calculated. (Obviously if you inject a Bitcoin address, you won’t get the corresponding WIF!)

The input is determined to be x & y coordinates.

The input here is determined to be a Bitcoin address. The only thing that it can be converted to is a hash160.

Related movie: How to Build a Milk Crate Mining Equipment Tutorial

Leave a Reply