import { BinaryWriter } from "../../../binary"; import { isSet, bytesFromBase64, base64FromBytes } from "../../../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. */ export interface PubKey { key: Uint8Array; } export interface PubKeyProtoMsg { typeUrl: "/cosmos.crypto.secp256k1.PubKey"; value: Uint8Array; } /** * 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. */ export interface PubKeyAmino { key?: string; } export interface PubKeyAminoMsg { type: "cosmos-sdk/PubKey"; value: PubKeyAmino; } /** * 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. */ export interface PubKeySDKType { key: Uint8Array; } /** PrivKey defines a secp256k1 private key. */ export interface PrivKey { key: Uint8Array; } export interface PrivKeyProtoMsg { typeUrl: "/cosmos.crypto.secp256k1.PrivKey"; value: Uint8Array; } /** PrivKey defines a secp256k1 private key. */ export interface PrivKeyAmino { key?: string; } export interface PrivKeyAminoMsg { type: "cosmos-sdk/PrivKey"; value: PrivKeyAmino; } /** PrivKey defines a secp256k1 private key. */ export interface PrivKeySDKType { key: Uint8Array; } function createBasePubKey(): PubKey { return { key: new Uint8Array() }; } export const PubKey = { typeUrl: "/cosmos.crypto.secp256k1.PubKey", encode(message: PubKey, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { if (message.key.length !== 0) { writer.uint32(10).bytes(message.key); } return writer; }, fromJSON(object: any): PubKey { return { key: isSet(object.key) ? bytesFromBase64(object.key) : new Uint8Array() }; }, fromPartial(object: Partial): PubKey { const message = createBasePubKey(); message.key = object.key ?? new Uint8Array(); return message; }, fromAmino(object: PubKeyAmino): PubKey { const message = createBasePubKey(); if (object.key !== undefined && object.key !== null) { message.key = bytesFromBase64(object.key); } return message; }, toAmino(message: PubKey): PubKeyAmino { const obj: any = {}; obj.key = message.key ? base64FromBytes(message.key) : undefined; return obj; }, fromAminoMsg(object: PubKeyAminoMsg): PubKey { return PubKey.fromAmino(object.value); }, toAminoMsg(message: PubKey): PubKeyAminoMsg { return { type: "cosmos-sdk/PubKey", value: PubKey.toAmino(message) }; }, fromProtoMsg(message: PubKeyProtoMsg): PubKey { return PubKey.decode(message.value); }, toProto(message: PubKey): Uint8Array { return PubKey.encode(message).finish(); }, toProtoMsg(message: PubKey): PubKeyProtoMsg { return { typeUrl: "/cosmos.crypto.secp256k1.PubKey", value: PubKey.encode(message).finish() }; } }; function createBasePrivKey(): PrivKey { return { key: new Uint8Array() }; } export const PrivKey = { typeUrl: "/cosmos.crypto.secp256k1.PrivKey", encode(message: PrivKey, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { if (message.key.length !== 0) { writer.uint32(10).bytes(message.key); } return writer; }, fromJSON(object: any): PrivKey { return { key: isSet(object.key) ? bytesFromBase64(object.key) : new Uint8Array() }; }, fromPartial(object: Partial): PrivKey { const message = createBasePrivKey(); message.key = object.key ?? new Uint8Array(); return message; }, fromAmino(object: PrivKeyAmino): PrivKey { const message = createBasePrivKey(); if (object.key !== undefined && object.key !== null) { message.key = bytesFromBase64(object.key); } return message; }, toAmino(message: PrivKey): PrivKeyAmino { const obj: any = {}; obj.key = message.key ? base64FromBytes(message.key) : undefined; return obj; }, fromAminoMsg(object: PrivKeyAminoMsg): PrivKey { return PrivKey.fromAmino(object.value); }, toAminoMsg(message: PrivKey): PrivKeyAminoMsg { return { type: "cosmos-sdk/PrivKey", value: PrivKey.toAmino(message) }; }, fromProtoMsg(message: PrivKeyProtoMsg): PrivKey { return PrivKey.decode(message.value); }, toProto(message: PrivKey): Uint8Array { return PrivKey.encode(message).finish(); }, toProtoMsg(message: PrivKey): PrivKeyProtoMsg { return { typeUrl: "/cosmos.crypto.secp256k1.PrivKey", value: PrivKey.encode(message).finish() }; } };