Skip to content

DIP: Canonical, Deterministic Wallet & XPub IDs - #134

Open
coolaj86 wants to merge 1 commit into
dashpay:masterfrom
dashhive:aj-wallet-fingerprint
Open

DIP: Canonical, Deterministic Wallet & XPub IDs#134
coolaj86 wants to merge 1 commit into
dashpay:masterfrom
dashhive:aj-wallet-fingerprint

Conversation

@coolaj86

@coolaj86coolaj86 commented Jul 14, 2023

Copy link
Copy Markdown

Defines a 64-bit Wallet ID (and encodings) for applications that manage multiple Wallets Phrases.

Also provides an alternate HD Key ID, as Hierarchical Deterministic Wallets: Key Identifiers actually recommends NOT using their 32-bit fingerprint for these types of scenarios (and ripemd160 is weak and deprecated).

Preview

https://github.com/dashhive/DIPs/blob/aj-wallet-fingerprint/aj-wallet-id.md

Example

Wallet

Wallet Phrase:

zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo wrong

Wallet Salt:

TREZOR

Wallet ID

Base64Url: ZoR59UQ1QPA (11 characters)
64-Bit Int: 7387163383112745200 (8 bytes)
Hex: 668479f5443540f0 (16 characters)
CB32: CT27KXA46N0F0 (13 characters)

HD Key (a.k.a. X Key, a.k.a. XPub)

Wallet ZoR59UQ1QPA @ m/44'/5'/0'/0:

XPrv: xprvA2L7qar7dyJNhxnE47gK5J6cc1oEHQuAk8WrZLnLeHTtnkeyP4w6E
o6Tt65trtdkTRtx8opazGnLbpWrkhzNaL6ZsgG3sQmc2yS8AxoMjfZ
XPub: xpub6FKUF6P1ULrfvSrhA9DKSS3MA3digsd27MSTMjBxCczsfYz7vcFLn
bQwjP9CsAfEJsnD4UwtbU43iZaibv4vnzQNZmQAVcufN4r3pva8kTz

XPub ID:

64-Bit Int: 13572668744561724463
Hex: bc5bce4fe5a60c2f
CB32: QHDWWKZ5MR62Y
Base64Url: vFvOT-WmDC8

In Pseudocode

letseedBytes=awaitDashPhrase.toSeed(phrase,salt);letwalletKey=awaitDashHd.fromSeed(seedBytes);letxpubBytes=awaitDashHd.toXPubBytes(walletKey);lethashBytes=awaitcrypto.subtle.digest("SHA-256",xpubBytes);letidBytes=hashBytes.slice(0,8);letid=bytesToBase64Url(idBytes);letidBase32Crock=base32crockford.encode(idBytes);letidHex=bytesToHex(idBytes);letidInt64=BigInt(`0x${idHex}`);
lethdkey=awaitDashHd.fromXKey(xkey);letxpubBytes=awaitDashHd.toXPubBytes(hdkey);lethashBytes=awaitcrypto.subtle.digest("SHA-256",xpubBytes);letidBytes=hashBytes.slice(0,8);letid=bytesToBase64Url(idBytes);letidBase32Crock=base32crockford.encode(idBytes);letidHex=bytesToHex(idBytes);letidInt64=BigInt(`0x${idHex}`);

Implementation

@coolaj86coolaj86 changed the title WIP-DIP: Canonical, Deterministic Wallet IDsDIP: Canonical, Deterministic Wallet IDsJul 14, 2023
@coolaj86
coolaj86force-pushed the aj-wallet-fingerprint branch 3 times, most recently from c177474 to 63d2201CompareJuly 15, 2023 05:41
@coolaj86coolaj86 changed the title DIP: Canonical, Deterministic Wallet IDsDIP: Canonical, Deterministic Wallet & XPub IDsJul 15, 2023
@coolaj86

coolaj86 commented Jul 15, 2023

Copy link
Copy Markdown
Author

Note: the methodology has been simplified to use the HD Key as the basis of the ID for both the Wallet Phrase and the XPub / XPrv use cases.

@coolaj86
coolaj86force-pushed the aj-wallet-fingerprint branch from 63d2201 to 761ed6cCompareJuly 20, 2023 18:17
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@coolaj86