'use strict';

var cryptoWasmTs = require('@docknetwork/crypto-wasm-ts');
var vc_crypto_constants = require('./constants.cjs');
var vc_crypto_common_DockCryptoKeyPair = require('./common/DockCryptoKeyPair.cjs');
require('bs58');
require('../../utils/types/bytes.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/inheritance.cjs');
require('../../utils/types/set.cjs');

class Bls12381PSKeyPairDock2023 extends vc_crypto_common_DockCryptoKeyPair {
  constructor(options) {
    super(options, vc_crypto_constants.Bls12381PSDockVerKeyName);
  }

  /**
   * Attempts to adapt supplied key for the `msgCount` messages.
   * Throws an error if `msgCount` is greater than the supported message count.
   * @param {*} key
   * @param {*} msgCount
   */
  static adaptKey(key, msgCount) {
    const supportedMessageCount = key.supportedMessageCount();

    if (supportedMessageCount === msgCount) {
      return key;
    } else if (supportedMessageCount > msgCount) {
      return key.adaptForLess(msgCount);
    } else {
      throw new Error(
        `Failed to adapt provided key ${key} supporting ${supportedMessageCount} for ${msgCount} messages - can only adapt for less amount of messages`,
      );
    }
  }
}

Bls12381PSKeyPairDock2023.SecretKey = cryptoWasmTs.PSSecretKey;
Bls12381PSKeyPairDock2023.PublicKey = cryptoWasmTs.PSPublicKey;
Bls12381PSKeyPairDock2023.SignatureParams = cryptoWasmTs.PSSignatureParams;
Bls12381PSKeyPairDock2023.Signature = cryptoWasmTs.PSSignature;
Bls12381PSKeyPairDock2023.KeyPair = cryptoWasmTs.PSKeypair;
Bls12381PSKeyPairDock2023.defaultLabelBytes = cryptoWasmTs.PS_SIGNATURE_PARAMS_LABEL_BYTES;

module.exports = Bls12381PSKeyPairDock2023;
//# sourceMappingURL=Bls12381PSKeyPairDock2023.cjs.map
