-
Notifications
You must be signed in to change notification settings - Fork 158
NKN Wallet Specification: Wallet Address Format
gdmmx edited this page Nov 11, 2019
·
10 revisions
Prefix | Uint160 | Uint32 |
---|---|---|
Fool-proof design | 160 bits Hash of RedeemScript | Checksum |
- Fool-proof:
Fix 0x35 in v0.8 for base58.encode got string start with "N"
Fix 0x02b825 in v0.9 for base58.encode got string start with "NKN"
- 160 bits Hash of RedeemScript:
generate RedeemScript vmCode from publicKey, and hash it with ripemd160
- Checksum:
SHA256 hash twice with (Prefix + Uint160), retain lowest 32bits
As part #1 definition, the valid address range (without consider Checksum
) should be:
Minimal | Maximum | |
---|---|---|
Expr | (0x2b825<<192) | (0^160)<<32 | 0^32 |
(0x2b825<<192) | ((1<<160)-1)<<32 | (1<<32)-1 |
Hex | 0x2b8250000000000...00000000000000L | 0x2b825ffffffffffff...ffffffffffffffffffffL |
Base58 | NKNBV71h5oUBjknMHPikPU7nraw9KtkegU1m | NKNaphzoP6BNCdbnRUkAinbv8NZeaqTtGJL6 |
- publicKey
- commpress publicKey
- generated
RedeemScript vmCode
- sha256 & ripemd160 RedeemScript got 160bits Hash
- calc
Checksum
of (Prefix
+160 bits Hash
) - append
Checksum
- base58.encode
https://github.com/nknorg/nkn/blob/v0.9/util/pubkey2addr.go
if k, err = hex.DecodeString(key); err == nil {
if pk, err = crypto.DecodePoint(k); err == nil {
if redeemHash, err = contract.CreateRedeemHash(pk); err == nil {
return redeemHash.ToAddress()
}
}
}