"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = schnorrkelSign;

require("../polyfill");

var _util = require("@polkadot/util");

var _wasmCrypto = require("@polkadot/wasm-crypto");

// Copyright 2017-2020 @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, {
  publicKey,
  secretKey
}) {
  (0, _util.assert)((publicKey === null || publicKey === void 0 ? void 0 : publicKey.length) === 32, 'Expected valid publicKey, 32-bytes');
  (0, _util.assert)((secretKey === null || secretKey === void 0 ? void 0 : secretKey.length) === 64, 'Expected valid secretKey, 64-bytes');
  const messageU8a = (0, _util.u8aToU8a)(message);
  return (0, _wasmCrypto.sr25519Sign)(publicKey, secretKey, messageU8a);
}