"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.PubKey = exports.PrivKey = void 0;
var _binary = require("../../../binary");
var _helpers = require("../../../helpers");
/** PubKey defines a secp256r1 ECDSA public key. */

/** PubKey defines a secp256r1 ECDSA public key. */

/** PubKey defines a secp256r1 ECDSA public key. */

/** PrivKey defines a secp256r1 ECDSA private key. */

/** PrivKey defines a secp256r1 ECDSA private key. */

/** PrivKey defines a secp256r1 ECDSA private key. */

function createBasePubKey() {
  return {
    key: new Uint8Array()
  };
}
var PubKey = exports.PubKey = {
  typeUrl: "/cosmos.crypto.secp256r1.PubKey",
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _binary.BinaryWriter.create();
    if (message.key.length !== 0) {
      writer.uint32(10).bytes(message.key);
    }
    return writer;
  },
  fromJSON: function fromJSON(object) {
    return {
      key: (0, _helpers.isSet)(object.key) ? (0, _helpers.bytesFromBase64)(object.key) : new Uint8Array()
    };
  },
  fromPartial: function fromPartial(object) {
    var _object$key;
    var message = createBasePubKey();
    message.key = (_object$key = object.key) !== null && _object$key !== void 0 ? _object$key : new Uint8Array();
    return message;
  },
  fromAmino: function fromAmino(object) {
    var message = createBasePubKey();
    if (object.key !== undefined && object.key !== null) {
      message.key = (0, _helpers.bytesFromBase64)(object.key);
    }
    return message;
  },
  toAmino: function toAmino(message) {
    var obj = {};
    obj.key = message.key ? (0, _helpers.base64FromBytes)(message.key) : undefined;
    return obj;
  },
  fromAminoMsg: function fromAminoMsg(object) {
    return PubKey.fromAmino(object.value);
  },
  toAminoMsg: function toAminoMsg(message) {
    return {
      type: "cosmos-sdk/PubKey",
      value: PubKey.toAmino(message)
    };
  },
  fromProtoMsg: function fromProtoMsg(message) {
    return PubKey.decode(message.value);
  },
  toProto: function toProto(message) {
    return PubKey.encode(message).finish();
  },
  toProtoMsg: function toProtoMsg(message) {
    return {
      typeUrl: "/cosmos.crypto.secp256r1.PubKey",
      value: PubKey.encode(message).finish()
    };
  }
};
function createBasePrivKey() {
  return {
    secret: new Uint8Array()
  };
}
var PrivKey = exports.PrivKey = {
  typeUrl: "/cosmos.crypto.secp256r1.PrivKey",
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _binary.BinaryWriter.create();
    if (message.secret.length !== 0) {
      writer.uint32(10).bytes(message.secret);
    }
    return writer;
  },
  fromJSON: function fromJSON(object) {
    return {
      secret: (0, _helpers.isSet)(object.secret) ? (0, _helpers.bytesFromBase64)(object.secret) : new Uint8Array()
    };
  },
  fromPartial: function fromPartial(object) {
    var _object$secret;
    var message = createBasePrivKey();
    message.secret = (_object$secret = object.secret) !== null && _object$secret !== void 0 ? _object$secret : new Uint8Array();
    return message;
  },
  fromAmino: function fromAmino(object) {
    var message = createBasePrivKey();
    if (object.secret !== undefined && object.secret !== null) {
      message.secret = (0, _helpers.bytesFromBase64)(object.secret);
    }
    return message;
  },
  toAmino: function toAmino(message) {
    var obj = {};
    obj.secret = message.secret ? (0, _helpers.base64FromBytes)(message.secret) : undefined;
    return obj;
  },
  fromAminoMsg: function fromAminoMsg(object) {
    return PrivKey.fromAmino(object.value);
  },
  toAminoMsg: function toAminoMsg(message) {
    return {
      type: "cosmos-sdk/PrivKey",
      value: PrivKey.toAmino(message)
    };
  },
  fromProtoMsg: function fromProtoMsg(message) {
    return PrivKey.decode(message.value);
  },
  toProto: function toProto(message) {
    return PrivKey.encode(message).finish();
  },
  toProtoMsg: function toProtoMsg(message) {
    return {
      typeUrl: "/cosmos.crypto.secp256r1.PrivKey",
      value: PrivKey.encode(message).finish()
    };
  }
};