"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod2, isNodeMode, target) => (target = mod2 != null ? __create(__getProtoOf(mod2)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod2 || !mod2.__esModule ? __defProp(target, "default", { value: mod2, enumerable: true }) : target,
  mod2
));
var __toCommonJS = (mod2) => __copyProps(__defProp({}, "__esModule", { value: true }), mod2);
var Crypto_exports = {};
__export(Crypto_exports, {
  CRYPTO_AUTH_TAG_LENGTH: () => CRYPTO_AUTH_TAG_LENGTH,
  CRYPTO_EC_CURVE: () => CRYPTO_EC_CURVE,
  CRYPTO_EC_KEY_BYTES: () => CRYPTO_EC_KEY_BYTES,
  CRYPTO_ENCRYPT_ALGORITHM: () => CRYPTO_ENCRYPT_ALGORITHM,
  CRYPTO_HASH_ALGORITHM: () => CRYPTO_HASH_ALGORITHM,
  CRYPTO_SYMMETRIC_KEY_LENGTH: () => CRYPTO_SYMMETRIC_KEY_LENGTH,
  Crypto: () => Crypto,
  HASH_ALGORITHM_OUTPUT_LENGTHS: () => HASH_ALGORITHM_OUTPUT_LENGTHS,
  HashFipsAlgorithmId: () => HashFipsAlgorithmId,
  ec: () => ec
});
module.exports = __toCommonJS(Crypto_exports);
var import_Diagnostic = require("#log/Diagnostic.js");
var import_Logger = require("#log/Logger.js");
var import_Bytes = require("#util/Bytes.js");
var mod = __toESM(require("@noble/curves/abstract/modular.js"), 1);
var import_nist = require("@noble/curves/nist.js");
var utils = __toESM(require("@noble/curves/utils.js"), 1);
var import_Entropy = require("../util/Entropy.js");
/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
const ec = {
  p256: import_nist.p256,
  ...utils,
  ...mod
};
const CRYPTO_ENCRYPT_ALGORITHM = "aes-128-ccm";
const CRYPTO_HASH_ALGORITHM = "sha256";
const CRYPTO_EC_CURVE = "prime256v1";
const CRYPTO_EC_KEY_BYTES = 32;
const CRYPTO_AUTH_TAG_LENGTH = 16;
const CRYPTO_SYMMETRIC_KEY_LENGTH = 16;
const HASH_ALGORITHM_OUTPUT_LENGTHS = {
  "SHA-256": 32,
  "SHA-512": 64,
  "SHA-384": 48,
  "SHA-512/224": 28,
  "SHA-512/256": 32,
  "SHA3-256": 32
};
var HashFipsAlgorithmId = /* @__PURE__ */ ((HashFipsAlgorithmId2) => {
  HashFipsAlgorithmId2[HashFipsAlgorithmId2["SHA-256"] = 1] = "SHA-256";
  HashFipsAlgorithmId2[HashFipsAlgorithmId2["SHA-512"] = 7] = "SHA-512";
  HashFipsAlgorithmId2[HashFipsAlgorithmId2["SHA-384"] = 8] = "SHA-384";
  HashFipsAlgorithmId2[HashFipsAlgorithmId2["SHA-512/224"] = 10] = "SHA-512/224";
  HashFipsAlgorithmId2[HashFipsAlgorithmId2["SHA-512/256"] = 11] = "SHA-512/256";
  HashFipsAlgorithmId2[HashFipsAlgorithmId2["SHA3-256"] = 12] = "SHA3-256";
  return HashFipsAlgorithmId2;
})(HashFipsAlgorithmId || {});
const logger = import_Logger.Logger.get("Crypto");
class Crypto extends import_Entropy.Entropy {
  /**
   * Add two EC points on the P-256 curve.
   *
   * @param a - 65-byte uncompressed EC point (04 || x || y)
   * @param b - 65-byte uncompressed EC point (04 || x || y)
   * @returns 65-byte uncompressed EC point
   */
  ecAdd(a, b) {
    return ec.p256.Point.fromBytes(import_Bytes.Bytes.of(a)).add(ec.p256.Point.fromBytes(import_Bytes.Bytes.of(b))).toBytes(false);
  }
  /**
   * Negate an EC point on the P-256 curve.
   *
   * @param point - 65-byte uncompressed EC point (04 || x || y)
   * @returns 65-byte uncompressed EC point
   */
  ecNegate(point) {
    return ec.p256.Point.fromBytes(import_Bytes.Bytes.of(point)).negate().toBytes(false);
  }
  reportUsage(component) {
    const message = ["Using", import_Diagnostic.Diagnostic.strong(this.implementationName), "crypto implementation"];
    if (component) {
      message.push("for", component);
    }
    logger.debug(...message);
  }
}
//# sourceMappingURL=Crypto.js.map
