Skip to content

Commit b38d30c

Browse files
author
AJ ONeal
committed
ref!: normalize pubKeyHash, pubkey, and publicKey
1 parent c1d0bd0 commit b38d30c

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,13 @@ theoretically be used for).
132132
// Bi-Directional Conversions
133133
await DashKeys.addrToPkh(address); // PubKey Hash Uint8Array (ShaRipeBytes)
134134
await DashKeys.pkhToAddr(hashBytes, { version }); // Address (Base58Check-encoded)
135-
await DashKeys.pubKeyToAddr(pubBytes); // Address (Base58Check-encoded)
135+
await DashKeys.pubkeyToAddr(pubBytes); // Address (Base58Check-encoded)
136136
await DashKeys.privKeyToWif(privBytes, { version }); // WIF (Base58Check-encoded)
137137
await DashKeys.wifToPrivKey(wif); // Private Key Uint8Array
138138

139139
// One-Way Conversions
140140
await DashKeys.wifToAddr(wif); // Address (Base58Check-encoded)
141-
await DashKeys.pubKeyToPkh(pubBytes); // shaRipeBytes Uint8Array
141+
await DashKeys.pubkeyToPkh(pubBytes); // shaRipeBytes Uint8Array
142142
```
143143

144144
**Note**: these all output either Base58Check Strings, or Byte Arrays
@@ -408,8 +408,8 @@ The indicator is `0x02`, if `Y` is ever, or `0x03` if `Y` is odd. \
408408
In essence:
409409
410410
```js
411-
let expectOdd = 0x03 === pubKey[0];
412-
let xBuf = pubKey.subarray(1);
411+
let expectOdd = 0x03 === pubkey[0];
412+
let xBuf = pubkey.subarray(1);
413413
let xHex = toHex(xBuf);
414414
let x = BigInt(xHex);
415415

@@ -621,7 +621,7 @@ let dash58check = Base58Check.create({
621621
* @param {String} addr
622622
* @returns {Promise<Uint8Array>} - p2pkh (no magic byte or checksum)
623623
*/
624-
async function addrToPubKeyHash(addr) {
624+
async function addrToPkh(addr) {
625625
let b58cAddr = dash58check.decode(addr);
626626
let pubKeyHash = toBytes(b58cAddr.pubKeyHash);
627627
return pubKeyHash;
@@ -631,17 +631,17 @@ async function addrToPubKeyHash(addr) {
631631
* @param {Uint8Array} pubKeyHash - no magic byte or checksum
632632
* @returns {Promise<String>} - Pay Addr
633633
*/
634-
async function pubKeyHashToAddr(pubKeyHash) {
634+
async function pkhToAddr(pubKeyHash) {
635635
let hex = toHex(pubKeyHash);
636-
let addr = await dash58check.encode({ pubkeyHash: hex });
636+
let addr = await dash58check.encode({ pubKeyHash: hex });
637637
return addr;
638638
}
639639

640640
/**
641641
* @param {String} wif
642642
* @returns {Promise<Uint8Array>} - private key (no magic byte or checksum)
643643
*/
644-
async function wifToPrivateKey(wif) {
644+
async function wifToPrivKey(wif) {
645645
let b58cWif = dash58check.decode(wif);
646646
let privateKey = toBytes(b58cWif.privateKey);
647647
return privateKey;
@@ -651,7 +651,7 @@ async function wifToPrivateKey(wif) {
651651
* @param {Uint8Array} privKey
652652
* @returns {Promise<String>} - wif
653653
*/
654-
async function privateKeyToWif(privKey) {
654+
async function privKeyToWif(privKey) {
655655
let privateKey = toHex(privKey);
656656

657657
let wif = await dash58check.encode({ privateKey: privateKey });

dashkeys.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,7 +1021,7 @@ var DashKeys = ("object" === typeof module && exports) || {};
10211021
}
10221022

10231023
if (33 === keyBytes.length) {
1024-
let pkhBytes = await _DashKeys.pubKeyToPkh(keyBytes);
1024+
let pkhBytes = await _DashKeys.pubkeyToPkh(keyBytes);
10251025
if (!opts.version) {
10261026
opts.version = DASH_PKH;
10271027
}
@@ -1169,15 +1169,15 @@ var DashKeys = ("object" === typeof module && exports) || {};
11691169
};
11701170

11711171
/** @type {PublicKeyToAddress} */
1172-
_DashKeys.pubKeyToAddr = async function (pubBytes, opts) {
1173-
let shaRipeBytes = await _DashKeys.pubKeyToPkh(pubBytes);
1172+
_DashKeys.pubkeyToAddr = async function (pubBytes, opts) {
1173+
let shaRipeBytes = await _DashKeys.pubkeyToPkh(pubBytes);
11741174
let addr = await _DashKeys.pkhToAddr(shaRipeBytes, opts);
11751175

11761176
return addr;
11771177
};
11781178

11791179
/** @type {PublicKeyToPubKeyHash} */
1180-
_DashKeys.pubKeyToPkh = async function (pubBytes) {
1180+
_DashKeys.pubkeyToPkh = async function (pubBytes) {
11811181
let shaBytes = await Utils.sha256sum(pubBytes);
11821182
let shaRipeBytes = await Utils.ripemd160sum(shaBytes);
11831183

@@ -1189,7 +1189,7 @@ var DashKeys = ("object" === typeof module && exports) || {};
11891189
let privBytes = await _DashKeys.wifToPrivKey(wif);
11901190

11911191
let pubBytes = await Utils.toPublicKey(privBytes);
1192-
let pubKeyHash = await _DashKeys.pubKeyToPkh(pubBytes);
1192+
let pubKeyHash = await _DashKeys.pubkeyToPkh(pubBytes);
11931193
let pubKeyHashHex = Utils.bytesToHex(pubKeyHash);
11941194

11951195
let addr = await dash58check.encode({

test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ async function main() {
1111
"hex",
1212
);
1313

14-
let wif = await DashKeys.privateKeyToWif(privKey);
14+
let wif = await DashKeys.privKeyToWif(privKey);
1515

1616
let decoded = await dash58check.decode(wif);
1717
let encoded = await dash58check.encode(decoded);

0 commit comments

Comments
 (0)