Author

Topic: Type of cryptographic algorithm used by full Pri & Pub Keys and for P2SH (Read 621 times)

hero member
Activity: 906
Merit: 1034
BTC: the beginning of stake-based public resources
Thanks again DannyHamilton. You're an asset to this forum.
legendary
Activity: 3472
Merit: 4801
What specific cryptographic algorithm are used to create a bitcoin private key

A Bitcoin private key is simply a randomly generated number between 1 and 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364140

It can be encoded into any of various representations for ease of use.  Some of those representations are:
  • Decimal
  • Binary
  • Hexadecimal
  • Base58
  • WIF (Wallet Import Format)

Of those, one of the most common representations is WIF.

The steps to get WIF from a Hex value private key are:

  • Add a 0x80 byte in front of it for mainnet addresses or 0xef for testnet addresses. Also add a 0x01 byte at the end if the private key will correspond to a compressed public key. (This is the Extended Key)
  • Perform SHA-256 hash on the numeric value (not the alphanumeric representation)
  • Perform SHA-256 hash on the numeric value result of SHA-256 hash (not the alphanumeric representation)
  • Take the first 4 bytes of the second SHA-256 hash, this is the checksum
  • Add the 4 checksum bytes to the end of the extended key
  • Convert the result into a base58 string using Base58Check encoding

and public key

A public key is a coordinate point on a line.  It is calculated using the ECDSA algorithm with the Secp256k1 curve.  It consists of two numeric values (an X coordinate and a Y coordinate).

It can be encoded into any of various representations for ease of use.

how are they stored, e.g. an unsigned integer of 64 bytes.

How they are stored is up to the programmer that is making use of them.  Most commonly, I'd expect each of the values to be stored as an unsigned integer of either 32 or 64 bytes while they are being used for calculations.  They may be stored in other formats on non-volatile memory (such as a hard disk).

What specific cryptographic algorithm is used to generate a P2SH address?

Minimally, SHA256 and RIPEMD-160.  Additional algorithms may be used to process the script itself (such as an algorithm to validate any signatures).

I assume the value (before a 3 is prepended and checksum appended) is 32 bytes as it’s the same length as a bitcoin public key hash?

Incorrect.  Both a script hash and a bitcoin public key hash are 20 bytes long (the 160 bit output of the RIPEMD-160 algorithm.

A bit off topic but for the above cryptographic algorithms does anyone know if there been any variations for any altcurrencies?

I'm sure there have been many variations.  There are many more altcurrencies that have come and gone than I would ever care to keep track of.
hero member
Activity: 906
Merit: 1034
BTC: the beginning of stake-based public resources
Apologies if this has been asked before but I cannot find this information on-line.

What specific cryptographic algorithm are used to create a bitcoin private key and public key, i.e. what format are they. And how are they stored, e.g. an unsigned integer of 64 bytes.

What specific cryptographic algorithm is used to generate a P2SH address? I assume the value (before a 3 is prepended and checksum appended) is 32 bytes as it’s the same length as a bitcoin public key hash?

A bit off topic but for the above cryptographic algorithms does anyone know if there been any variations for any altcurrencies?
Jump to: