Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async publicKey(): Promise {
return b58cencode(this._publicKey, pref[this.curve].pk);
}
async publicKey(): Promise {
await this.isInit;
return b58cencode(this._publicKey, prefix['edpk']);
}
async publicKeyHash(): Promise {
await sodium.ready;
return b58cencode(
sodium.crypto_generichash(20, new Uint8Array(this._publicKey)),
pref[this.curve].pkh
);
}
async sign(bytes: string, bytesHash: Uint8Array) {
const key = new elliptic.ec(this.curve).keyFromPrivate(this._key);
const sig = key.sign(bytesHash, { canonical: true });
const signature = new Uint8Array(sig.r.toArray().concat(sig.s.toArray()));
const signatureBuffer = toBuffer(signature);
const sbytes = bytes + buf2hex(signatureBuffer);
return {
bytes,
sig: b58cencode(signature, prefix.sig),
prefixSig: b58cencode(signature, pref[this.curve].sig),
sbytes,
};
}
async secretKey(): Promise {
let key = this._key;
return b58cencode(key, pref[this.curve].sk);
}
}