UNPKG

@runonflux/aa-schnorr-multisig-sdk

Version:

Account Abstraction Schnorr Multi-Signatures SDK

29 lines (28 loc) 900 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.KeyPair = void 0; const key_1 = require("./key"); class KeyPair { constructor({ publicKey, privateKey }) { this.privateKey = new key_1.Key(privateKey); this.publicKey = new key_1.Key(publicKey); } static fromJson(params) { try { const data = JSON.parse(params); const publicKey = key_1.Key.fromHex(data.publicKey); const privateKey = key_1.Key.fromHex(data.privateKey); return new KeyPair({ publicKey: publicKey.buffer, privateKey: privateKey.buffer }); } catch { throw new Error("Invalid JSON"); } } toJson() { return JSON.stringify({ publicKey: this.publicKey.toHex(), privateKey: this.privateKey.toHex(), }); } } exports.KeyPair = KeyPair;