import { WireType } from "@protobuf-ts/runtime";
import { UnknownFieldHandler } from "@protobuf-ts/runtime";
import { reflectionMergePartial } from "@protobuf-ts/runtime";
import { MessageType } from "@protobuf-ts/runtime";
var SigningKeySpec = /* @__PURE__ */ ((SigningKeySpec2) => {
  SigningKeySpec2[SigningKeySpec2["UNSPECIFIED"] = 0] = "UNSPECIFIED";
  SigningKeySpec2[SigningKeySpec2["EC_CURVE25519"] = 1] = "EC_CURVE25519";
  SigningKeySpec2[SigningKeySpec2["EC_P256"] = 2] = "EC_P256";
  SigningKeySpec2[SigningKeySpec2["EC_P384"] = 3] = "EC_P384";
  SigningKeySpec2[SigningKeySpec2["EC_SECP256K1"] = 4] = "EC_SECP256K1";
  return SigningKeySpec2;
})(SigningKeySpec || {});
var CryptoKeyFormat = /* @__PURE__ */ ((CryptoKeyFormat2) => {
  CryptoKeyFormat2[CryptoKeyFormat2["UNSPECIFIED"] = 0] = "UNSPECIFIED";
  CryptoKeyFormat2[CryptoKeyFormat2["DER"] = 1] = "DER";
  CryptoKeyFormat2[CryptoKeyFormat2["RAW"] = 2] = "RAW";
  CryptoKeyFormat2[CryptoKeyFormat2["DER_X509_SUBJECT_PUBLIC_KEY_INFO"] = 3] = "DER_X509_SUBJECT_PUBLIC_KEY_INFO";
  return CryptoKeyFormat2;
})(CryptoKeyFormat || {});
class SigningPublicKey$Type extends MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.SigningPublicKey", [
      {
        no: 1,
        name: "format",
        kind: "enum",
        T: () => [
          "com.daml.ledger.api.v2.CryptoKeyFormat",
          CryptoKeyFormat,
          "CRYPTO_KEY_FORMAT_"
        ]
      },
      {
        no: 2,
        name: "key_data",
        kind: "scalar",
        T: 12
      },
      {
        no: 3,
        name: "key_spec",
        kind: "enum",
        T: () => [
          "com.daml.ledger.api.v2.SigningKeySpec",
          SigningKeySpec,
          "SIGNING_KEY_SPEC_"
        ]
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.format = 0;
    message.keyData = new Uint8Array(0);
    message.keySpec = 0;
    if (value !== void 0)
      reflectionMergePartial(this, message, value);
    return message;
  }
  internalBinaryRead(reader, length, options, target) {
    let message = target ?? this.create(), end = reader.pos + length;
    while (reader.pos < end) {
      let [fieldNo, wireType] = reader.tag();
      switch (fieldNo) {
        case /* com.daml.ledger.api.v2.CryptoKeyFormat format */
        1:
          message.format = reader.int32();
          break;
        case /* bytes key_data */
        2:
          message.keyData = reader.bytes();
          break;
        case /* com.daml.ledger.api.v2.SigningKeySpec key_spec */
        3:
          message.keySpec = reader.int32();
          break;
        default:
          let u = options.readUnknownField;
          if (u === "throw")
            throw new globalThis.Error(
              `Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`
            );
          let d = reader.skip(wireType);
          if (u !== false)
            (u === true ? UnknownFieldHandler.onRead : u)(
              this.typeName,
              message,
              fieldNo,
              wireType,
              d
            );
      }
    }
    return message;
  }
  internalBinaryWrite(message, writer, options) {
    if (message.format !== 0)
      writer.tag(1, WireType.Varint).int32(message.format);
    if (message.keyData.length)
      writer.tag(2, WireType.LengthDelimited).bytes(message.keyData);
    if (message.keySpec !== 0)
      writer.tag(3, WireType.Varint).int32(message.keySpec);
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const SigningPublicKey = new SigningPublicKey$Type();
export {
  CryptoKeyFormat,
  SigningKeySpec,
  SigningPublicKey
};
//# sourceMappingURL=crypto.js.map