-
Notifications
You must be signed in to change notification settings - Fork 10
Address
A Contentbox address, is an identifier of 35 alphanumeric characters, beginning with "b1" or "b3", that can be generated from a ecdsa public key. Currently, there are two types of address:
- P2PKH address which starts with b1: b1Dy23MQ3NoKdCWWazygQNCk3AUEZ29nqU1
- P2SH type address which starts with b3: b32TwuDCFWaC9Jfhzqj7NSvrCeHzrbEAbS7
Contentbox uses elliptic curve secp256k1 as its basic signing algorithm, and the address is derived from public key.
A ecdsa public key consists of two parts, X and Y, both Big Integers and can take up to 32 bytes. Contentbox uses an array with 65 bytes to represent the public key: byte[0] is fixed content(0x4), byte[1:32] is X and byte[33:64] is Y. So a public key in byte array format is as following:
040f7ed5210cde2df4ea654c607e882244b22766c2fd3a7d7682f24a2340f4ba3ef10a21ef4891bdd897dfdf5ac4cd6d98df11e04e06763034b9c3fb5dfef72d3a
The public key byte array format can convert to a shorter hex format, which is using hash function ripmend160(sha256(byte[65])) to generate an array of 20 bytes.
Address generation takes public key hash(which would be referred as pkh) as input, and produces a base58 string. The following steps show how it's calculated:
- prefix = [0x13, 0x26] (if P2PKH) | [0x13, 0x2b] (if P2SH)
- checksum = sha256(sha256(prefix + pkh))[0:4]
- content = prefix + pkh + checksum
- address = base58(content)