Bitcoin Forum
November 14, 2024, 07:41:30 PM *
News: Check out the artwork 1Dq created to commemorate this forum's 15th anniversary
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Type of cryptographic algorithm used by full Pri & Pub Keys and for P2SH  (Read 616 times)
No_2 (OP)
Hero Member
*****
Offline Offline

Activity: 906
Merit: 1034


BTC: the beginning of stake-based public resources


View Profile
May 13, 2015, 03:13:50 PM
 #1

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?
DannyHamilton
Legendary
*
Offline Offline

Activity: 3486
Merit: 4851



View Profile
May 13, 2015, 03:40:53 PM
 #2

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.
No_2 (OP)
Hero Member
*****
Offline Offline

Activity: 906
Merit: 1034


BTC: the beginning of stake-based public resources


View Profile
May 15, 2015, 11:13:21 AM
 #3

Thanks again DannyHamilton. You're an asset to this forum.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!