@plugnet/util-crypto
Version:
A collection of useful crypto utilities for @plugnet
31 lines (25 loc) • 950 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = schnorrkelSign;
require("../polyfill");
var _util = require("@plugnet/util");
var _wasmCrypto = require("@plugnet/wasm-crypto");
// Copyright 2017-2019 @polkadot/util-crypto authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
/**
* @name schnorrkelSign
* @description Returns message signature of `message`, using the supplied pair
*/
function schnorrkelSign(message, _ref) {
let {
publicKey,
secretKey
} = _ref;
(0, _util.assert)(publicKey && publicKey.length === 32, 'Expected valid publicKey, 32-bytes');
(0, _util.assert)(secretKey && secretKey.length === 64, 'Expected valid secretKey, 64-bytes');
const messageU8a = (0, _util.u8aToU8a)(message);
return (0, _wasmCrypto.sr25519Sign)(publicKey, secretKey, messageU8a);
}