tendermint-rpc: Add support for secp256k1 validator keys
This commit is contained in:
parent
a4e4915d7a
commit
11e88bb91e
@ -85,6 +85,12 @@ export {
|
||||
toSeconds,
|
||||
} from "./dates";
|
||||
export { HttpClient, WebsocketClient } from "./rpcclients"; // TODO: Why do we export those outside of this package?
|
||||
export { BlockIdFlag, CommitSignature, ValidatorEd25519Pubkey, ValidatorPubkey } from "./types";
|
||||
export {
|
||||
BlockIdFlag,
|
||||
CommitSignature,
|
||||
ValidatorEd25519Pubkey,
|
||||
ValidatorSecp256k1Pubkey,
|
||||
ValidatorPubkey,
|
||||
} from "./types";
|
||||
export * as tendermint34 from "./tendermint34";
|
||||
export { Tendermint34Client } from "./tendermint34";
|
||||
|
||||
@ -150,14 +150,21 @@ interface RpcPubkey {
|
||||
}
|
||||
|
||||
function decodePubkey(data: RpcPubkey): ValidatorPubkey {
|
||||
if (data.type === "tendermint/PubKeyEd25519") {
|
||||
switch (data.type) {
|
||||
// go-amino special code
|
||||
return {
|
||||
algorithm: "ed25519",
|
||||
data: fromBase64(assertNotEmpty(data.value)),
|
||||
};
|
||||
case "tendermint/PubKeyEd25519":
|
||||
return {
|
||||
algorithm: "ed25519",
|
||||
data: fromBase64(assertNotEmpty(data.value)),
|
||||
};
|
||||
case "tendermint/PubKeySecp256k1":
|
||||
return {
|
||||
algorithm: "secp256k1",
|
||||
data: fromBase64(assertNotEmpty(data.value)),
|
||||
};
|
||||
default:
|
||||
throw new Error(`unknown pubkey type: ${data.type}`);
|
||||
}
|
||||
throw new Error(`unknown pubkey type: ${data.type}`);
|
||||
}
|
||||
|
||||
// for evidence, block results, etc.
|
||||
|
||||
@ -156,14 +156,21 @@ interface RpcPubkey {
|
||||
}
|
||||
|
||||
function decodePubkey(data: RpcPubkey): ValidatorPubkey {
|
||||
if (data.type === "tendermint/PubKeyEd25519") {
|
||||
switch (data.type) {
|
||||
// go-amino special code
|
||||
return {
|
||||
algorithm: "ed25519",
|
||||
data: fromBase64(assertNotEmpty(data.value)),
|
||||
};
|
||||
case "tendermint/PubKeyEd25519":
|
||||
return {
|
||||
algorithm: "ed25519",
|
||||
data: fromBase64(assertNotEmpty(data.value)),
|
||||
};
|
||||
case "tendermint/PubKeySecp256k1":
|
||||
return {
|
||||
algorithm: "secp256k1",
|
||||
data: fromBase64(assertNotEmpty(data.value)),
|
||||
};
|
||||
default:
|
||||
throw new Error(`unknown pubkey type: ${data.type}`);
|
||||
}
|
||||
throw new Error(`unknown pubkey type: ${data.type}`);
|
||||
}
|
||||
|
||||
// for evidence, block results, etc.
|
||||
|
||||
@ -8,11 +8,15 @@ export interface ValidatorEd25519Pubkey {
|
||||
readonly data: Uint8Array;
|
||||
}
|
||||
|
||||
export interface ValidatorSecp256k1Pubkey {
|
||||
readonly algorithm: "secp256k1";
|
||||
readonly data: Uint8Array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Union type for different possible pubkeys.
|
||||
* Currently only Ed25519 supported.
|
||||
*/
|
||||
export type ValidatorPubkey = ValidatorEd25519Pubkey;
|
||||
export type ValidatorPubkey = ValidatorEd25519Pubkey | ValidatorSecp256k1Pubkey;
|
||||
|
||||
export enum BlockIdFlag {
|
||||
Unknown = 0,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user