'use strict';

require('../utils/types/array.cjs');
var utils_types_bytes = require('../utils/types/bytes.cjs');
var utils_inheritance = require('../utils/inheritance.cjs');
require('bs58');
require('multiformats/bases/base58');
require('varint');
require('../utils/encoding/ss-58.cjs');
require('crypto');
require('../utils/interfaces.cjs');
require('../utils/assert.cjs');
require('../utils/error.cjs');
require('../utils/types/string.cjs');
require('../utils/types/iterable.cjs');
require('../utils/types/object.cjs');
require('../utils/types/set.cjs');
require('blake2b');

/**
 * Abstract keypair used to sign byte sequences of arbitrary size.
 */
let DockKeypair$1 = class DockKeypair {
  /**
   * Instantiates new `DockKeypair` with the provided underlying keypair.
   *
   * @param {*} keyPair
   */
  constructor(keyPair) {
    this.keyPair = keyPair;
  }

  /**
   * Generates `DockKeypair` from the supplied entropy.
   * @param {Uint8Array} entropy
   * @returns {DockKeypair}
   */
  static fromEntropy(entropy) {
    // eslint-disable-next-line no-underscore-dangle
    return new this(entropy, 'entropy');
  }

  /**
   * Generates `DockKeypair` from the supplied seed.
   * @param {Uint8Array} seed
   * @returns {DockKeypair}
   */
  static fromSeed(seed) {
    // eslint-disable-next-line no-underscore-dangle
    return new this(seed, 'seed');
  }

  /**
   * Generates `DockKeypair` from the supplied private key.
   * @param {Uint8Array} privateKey
   * @returns {DockKeypair}
   */
  static fromPrivateKey(privateKey) {
    // eslint-disable-next-line no-underscore-dangle
    return new this(privateKey, 'private');
  }

  /**
   * Generates random `DockKeypair`.
   * @returns {DockKeypair}
   */
  static random() {
    return new this(utils_types_bytes.randomAsHex(this.SeedSize));
  }

  /**
   * Returns underlying verification key type.
   */
  get verKeyType() {
    return this.constructor.VerKeyType;
  }

  /**
   * Returns underlying public key.
   */
  publicKey() {
    // eslint-disable-next-line no-underscore-dangle
    return new this.constructor.Signature.PublicKey(this._publicKey());
  }

  /**
   * Returns underlying private key.
   */
  privateKey() {
    throw new Error('Unimplemented');
  }

  /**
   * Signs supplied message using underlying keypair.
   * @param {*} message
   */
  sign(message) {
    // eslint-disable-next-line no-underscore-dangle
    return new this.constructor.Signature(this._sign(message));
  }

  /**
   * Returns raw bytes of the underlying public key.
   * @returns {Uint8Array}
   */
  _publicKey() {
    throw new Error('Unimplemented');
  }

  /**
   * Signs supplied message and returns raw signature bytes.
   * @returns {Uint8Array}
   */
  _sign(_message) {
    throw new Error('Unimplemented');
  }

  /**
   * Verifies signature produced over supplied message's using given public key.
   * @param {Uint8Array} _message
   * @param {Uint8Array | Signature} _signature
   * @param {Uint8Array | PublicKey} _publicKey
   * @returns {boolean}
   */
  static verify(_message, _signature, _publicKey) {
    throw new Error('Unimplemented');
  }
};

var DockKeypair = utils_inheritance.withExtendedPrototypeProperties(
  ['privateKey', '_publicKey', '_sign'],
  utils_inheritance.withExtendedStaticProperties(
    ['Signature', 'VerKeyType', 'SeedSize', 'verify', 'constructor'],
    DockKeypair$1,
  ),
);

module.exports = DockKeypair;
//# sourceMappingURL=dock-keypair.cjs.map
