Skip to content

feat: add toId(hdkey) #33

Description

@coolaj86

As per dashpay/dips#134 (comment).

DashHd.toIdBytes = async function (hdkey) {
  let xpubBytes = await DashHd.toXPubBytes(hdkey);

  let hashBytes = await crypto.subtle.digest("SHA-256", xpubBytes)
  let idBytes = hashBytes.slice(0, 8);
  return idBytes;
}

let hdkey = await DashHd.fromXKey(xkey);
let idBytes = DashHd.toIdBytes(hdkey);

let id = bytesToBase64Url(idBytes);
let idBase32Crock = base32crockford.encode(idBytes);
let idHex = DashKeys.utils.bytesToHex(idBytes);
let idInt64 = BigInt(`0x${idHex}`);

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions