feat: add PublicKey.toBytes and fix buffer incompatibility

This commit is contained in:
Justin Starry
2021-03-29 11:00:56 +08:00
committed by Justin Starry
parent abada56ba1
commit a622198235
6 changed files with 36 additions and 28 deletions

View File

@@ -195,14 +195,8 @@ export class Secp256k1Program {
`Private key must be ${PRIVATE_KEY_BYTES} bytes but received ${pkey.length} bytes`,
);
let privateKey;
if (Array.isArray(pkey)) {
privateKey = Uint8Array.from(pkey);
} else {
privateKey = pkey;
}
try {
const privateKey = toBuffer(pkey);
const publicKey = publicKeyCreate(privateKey, false).slice(1); // throw away leading byte
const messageHash = Buffer.from(
keccak_256.update(toBuffer(message)).digest(),