UNPKG

@chorus-one/signer-local

Version:

Local signer for Chorus One SDK that utilizes a BIP39 mnemonic for signing operations

17 lines (16 loc) 582 B
import { derivePath, getPublicKey } from 'ed25519-hd-key'; import { ed25519 } from '@noble/curves/ed25519'; export function deriveKey(seed, hdPath) { const { key } = derivePath(hdPath, Buffer.from(seed).toString('hex')); const publicKey = getPublicKey(key, false); return { publicKey: Uint8Array.from(publicKey), privateKey: Uint8Array.from(key) }; } export async function sign(content, privKey) { const signature = ed25519.sign(Buffer.from(content, 'hex'), privKey); return { fullSig: Buffer.from(signature).toString('hex') }; }