UNPKG

@polkadot/util-crypto

Version:
20 lines (19 loc) 708 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.sr25519Sign = sr25519Sign; const tslib_1 = require("tslib"); const sr25519 = tslib_1.__importStar(require("@scure/sr25519")); const util_1 = require("@polkadot/util"); /** * @name sr25519Sign * @description Returns message signature of `message`, using the supplied pair */ function sr25519Sign(message, { publicKey, secretKey }) { if (publicKey?.length !== 32) { throw new Error('Expected a valid publicKey, 32-bytes'); } else if (secretKey?.length !== 64) { throw new Error('Expected a valid secretKey, 64-bytes'); } return sr25519.sign(secretKey, (0, util_1.u8aToU8a)(message)); }