UNPKG

@yubing744/rooch-sdk

Version:
54 lines (53 loc) 1.81 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var keypair_exports = {}; __export(keypair_exports, { BaseSigner: () => BaseSigner, Keypair: () => Keypair, LEGACY_PRIVATE_KEY_SIZE: () => LEGACY_PRIVATE_KEY_SIZE, PRIVATE_KEY_SIZE: () => PRIVATE_KEY_SIZE }); module.exports = __toCommonJS(keypair_exports); var import_sha3 = require("@noble/hashes/sha3"); var import_signature = require("./signature"); const PRIVATE_KEY_SIZE = 32; const LEGACY_PRIVATE_KEY_SIZE = 64; class BaseSigner { async signMessage(bytes) { const digest = (0, import_sha3.sha3_256)(bytes); return this.signMessageWithHashed(digest); } async signMessageWithHashed(bytes) { const signature = (0, import_signature.toSerializedSignature)({ signature: await this.sign(bytes), signatureScheme: this.getKeyScheme(), pubKey: this.getPublicKey() }); return { signature, bytes }; } toRoochAddress() { return this.getPublicKey().toRoochAddress(); } } class Keypair extends BaseSigner { } //# sourceMappingURL=keypair.js.map