-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathkeys.ts
207 lines (207 loc) · 6.36 KB
/
keys.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
import { BinaryReader, BinaryWriter } from "../../../binary";
import { bytesFromBase64, base64FromBytes } from "../../../helpers";
/**
* PubKey is an ed25519 public key for handling Tendermint keys in SDK.
* It's needed for Any serialization and SDK compatibility.
* It must not be used in a non Tendermint key context because it doesn't implement
* ADR-28. Nevertheless, you will like to use ed25519 in app user level
* then you must create a new proto message and follow ADR-28 for Address construction.
*/
export interface PubKey {
key: Uint8Array;
}
export interface PubKeyProtoMsg {
typeUrl: "/cosmos.crypto.ed25519.PubKey";
value: Uint8Array;
}
/**
* PubKey is an ed25519 public key for handling Tendermint keys in SDK.
* It's needed for Any serialization and SDK compatibility.
* It must not be used in a non Tendermint key context because it doesn't implement
* ADR-28. Nevertheless, you will like to use ed25519 in app user level
* then you must create a new proto message and follow ADR-28 for Address construction.
*/
export interface PubKeyAmino {
key?: string;
}
export interface PubKeyAminoMsg {
type: "cosmos-sdk/PubKey";
value: PubKeyAmino;
}
/**
* PubKey is an ed25519 public key for handling Tendermint keys in SDK.
* It's needed for Any serialization and SDK compatibility.
* It must not be used in a non Tendermint key context because it doesn't implement
* ADR-28. Nevertheless, you will like to use ed25519 in app user level
* then you must create a new proto message and follow ADR-28 for Address construction.
*/
export interface PubKeySDKType {
key: Uint8Array;
}
/**
* Deprecated: PrivKey defines a ed25519 private key.
* NOTE: ed25519 keys must not be used in SDK apps except in a tendermint validator context.
*/
export interface PrivKey {
key: Uint8Array;
}
export interface PrivKeyProtoMsg {
typeUrl: "/cosmos.crypto.ed25519.PrivKey";
value: Uint8Array;
}
/**
* Deprecated: PrivKey defines a ed25519 private key.
* NOTE: ed25519 keys must not be used in SDK apps except in a tendermint validator context.
*/
export interface PrivKeyAmino {
key?: string;
}
export interface PrivKeyAminoMsg {
type: "cosmos-sdk/PrivKey";
value: PrivKeyAmino;
}
/**
* Deprecated: PrivKey defines a ed25519 private key.
* NOTE: ed25519 keys must not be used in SDK apps except in a tendermint validator context.
*/
export interface PrivKeySDKType {
key: Uint8Array;
}
function createBasePubKey(): PubKey {
return {
key: new Uint8Array()
};
}
export const PubKey = {
typeUrl: "/cosmos.crypto.ed25519.PubKey",
encode(message: PubKey, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter {
if (message.key.length !== 0) {
writer.uint32(10).bytes(message.key);
}
return writer;
},
decode(input: BinaryReader | Uint8Array, length?: number): PubKey {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBasePubKey();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.key = reader.bytes();
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},
fromPartial(object: Partial<PubKey>): 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.ed25519.PubKey",
value: PubKey.encode(message).finish()
};
}
};
function createBasePrivKey(): PrivKey {
return {
key: new Uint8Array()
};
}
export const PrivKey = {
typeUrl: "/cosmos.crypto.ed25519.PrivKey",
encode(message: PrivKey, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter {
if (message.key.length !== 0) {
writer.uint32(10).bytes(message.key);
}
return writer;
},
decode(input: BinaryReader | Uint8Array, length?: number): PrivKey {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBasePrivKey();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.key = reader.bytes();
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},
fromPartial(object: Partial<PrivKey>): 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.ed25519.PrivKey",
value: PrivKey.encode(message).finish()
};
}
};