-
Notifications
You must be signed in to change notification settings - Fork 158
NKN Wallet Specification: Wallet Address Format
gdmmx edited this page Apr 18, 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
- 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()
}
}
}