@chorus-one/signer-local
Version:
Local signer for Chorus One SDK that utilizes a BIP39 mnemonic for signing operations
22 lines (21 loc) • 790 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.sign = exports.deriveKey = void 0;
const ed25519_hd_key_1 = require("ed25519-hd-key");
const ed25519_1 = require("@noble/curves/ed25519");
function deriveKey(seed, hdPath) {
const { key } = (0, ed25519_hd_key_1.derivePath)(hdPath, Buffer.from(seed).toString('hex'));
const publicKey = (0, ed25519_hd_key_1.getPublicKey)(key, false);
return {
publicKey: Uint8Array.from(publicKey),
privateKey: Uint8Array.from(key)
};
}
exports.deriveKey = deriveKey;
async function sign(content, privKey) {
const signature = ed25519_1.ed25519.sign(Buffer.from(content, 'hex'), privKey);
return {
fullSig: Buffer.from(signature).toString('hex')
};
}
exports.sign = sign;