UNPKG

847 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.privateKeyToBytes = void 0;
4const utils_1 = require("./utils");
5function privateKeyToBytes(privateKey) {
6 const privateKeyBuffer = typeof privateKey === 'string' ? (0, utils_1.hexToBytes)(privateKey) : privateKey;
7 if (privateKeyBuffer.length != 32 && privateKeyBuffer.length != 33) {
8 throw new Error(`Improperly formatted private-key. Private-key byte length should be 32 or 33. Length provided: ${privateKeyBuffer.length}`);
9 }
10 if (privateKeyBuffer.length == 33 && privateKeyBuffer[32] !== 1) {
11 throw new Error('Improperly formatted private-key. 33 bytes indicate compressed key, but the last byte must be == 01');
12 }
13 return privateKeyBuffer;
14}
15exports.privateKeyToBytes = privateKeyToBytes;
16//# sourceMappingURL=keys.js.map
\No newline at end of file