"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.generateKeyPair = void 0;
var crypto = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("node:crypto"));
var WireguardKey = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("../WireguardKey.js"));
function _getRequireWildcardCache(e) {
  if ("function" != typeof WeakMap) return null;
  var r = new WeakMap(),
    t = new WeakMap();
  return (_getRequireWildcardCache = function (e) {
    return e ? t : r;
  })(e);
}
function _interopRequireWildcard(e, r) {
  if (!r && e && e.__esModule) return e;
  if (null === e || "object" != typeof e && "function" != typeof e) return {
    default: e
  };
  var t = _getRequireWildcardCache(r);
  if (t && t.has(e)) return t.get(e);
  var n = {
      __proto__: null
    },
    a = Object.defineProperty && Object.getOwnPropertyDescriptor;
  for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) {
    var i = a ? Object.getOwnPropertyDescriptor(e, u) : null;
    i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u];
  }
  return n.default = e, t && t.set(e, n), n;
}
/** @internal */
const generateKeyPair = () => {
  const keys = crypto.generateKeyPairSync("x25519", {
    publicKeyEncoding: {
      format: "der",
      type: "spki"
    },
    privateKeyEncoding: {
      format: "der",
      type: "pkcs8"
    }
  });
  return {
    publicKey: WireguardKey.WireguardKey(keys.publicKey.subarray(12).toString("base64")),
    privateKey: WireguardKey.WireguardKey(keys.privateKey.subarray(16).toString("base64"))
  };
};
exports.generateKeyPair = generateKeyPair;
//# sourceMappingURL=wireguardKey.js.map