"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 secp256k1 public key
 * Key is the compressed form of the pubkey. The first byte depends is a 0x02 byte
 * if the y-coordinate is the lexicographically largest of the two associated with
 * the x-coordinate. Otherwise the first byte is a 0x03.
 * This prefix is followed with the x-coordinate.
 */

/**
 * PubKey defines a secp256k1 public key
 * Key is the compressed form of the pubkey. The first byte depends is a 0x02 byte
 * if the y-coordinate is the lexicographically largest of the two associated with
 * the x-coordinate. Otherwise the first byte is a 0x03.
 * This prefix is followed with the x-coordinate.
 */

/**
 * PubKey defines a secp256k1 public key
 * Key is the compressed form of the pubkey. The first byte depends is a 0x02 byte
 * if the y-coordinate is the lexicographically largest of the two associated with
 * the x-coordinate. Otherwise the first byte is a 0x03.
 * This prefix is followed with the x-coordinate.
 */

/** PrivKey defines a secp256k1 private key. */

/** PrivKey defines a secp256k1 private key. */

/** PrivKey defines a secp256k1 private key. */

function createBasePubKey() {
  return {
    key: new Uint8Array()
  };
}
var PubKey = exports.PubKey = {
  typeUrl: "/cosmos.crypto.secp256k1.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.secp256k1.PubKey",
      value: PubKey.encode(message).finish()
    };
  }
};
function createBasePrivKey() {
  return {
    key: new Uint8Array()
  };
}
var PrivKey = exports.PrivKey = {
  typeUrl: "/cosmos.crypto.secp256k1.PrivKey",
  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$key2;
    var message = createBasePrivKey();
    message.key = (_object$key2 = object.key) !== null && _object$key2 !== void 0 ? _object$key2 : new Uint8Array();
    return message;
  },
  fromAmino: function fromAmino(object) {
    var message = createBasePrivKey();
    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 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.secp256k1.PrivKey",
      value: PrivKey.encode(message).finish()
    };
  }
};