Skip to content

Instantly share code, notes, and snippets.

@o-az
Created February 22, 2024 08:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save o-az/02d18a020ebee176c1960f5709a8fa6f to your computer and use it in GitHub Desktop.
Save o-az/02d18a020ebee176c1960f5709a8fa6f to your computer and use it in GitHub Desktop.
cosmjs patch in order to support bn254 key type
diff --git a/node_modules/@cosmjs/amino/build/pubkeys.js b/node_modules/@cosmjs/amino/build/pubkeys.js
index e9844ef..86101f8 100644
--- a/node_modules/@cosmjs/amino/build/pubkeys.js
+++ b/node_modules/@cosmjs/amino/build/pubkeys.js
@@ -9,6 +9,10 @@ function isSecp256k1Pubkey(pubkey) {
return pubkey.type === "tendermint/PubKeySecp256k1";
}
exports.isSecp256k1Pubkey = isSecp256k1Pubkey;
+function isBn254Pubkey(pubkey) {
+ return pubkey.type === "tendermint/PubKeyBn254";
+}
+exports.isBn254Pubkey = isBn254Pubkey;
exports.pubkeyType = {
/** @see https://github.com/tendermint/tendermint/blob/v0.33.0/crypto/ed25519/ed25519.go#L22 */
secp256k1: "tendermint/PubKeySecp256k1",
@@ -16,6 +20,7 @@ exports.pubkeyType = {
ed25519: "tendermint/PubKeyEd25519",
/** @see https://github.com/tendermint/tendermint/blob/v0.33.0/crypto/sr25519/codec.go#L12 */
sr25519: "tendermint/PubKeySr25519",
+ bn254: "tendermint/PubKeyBn254",
multisigThreshold: "tendermint/PubKeyMultisigThreshold",
};
function isSinglePubkey(pubkey) {
diff --git a/node_modules/@cosmjs/tendermint-rpc/build/tendermint37/adaptor/responses.js b/node_modules/@cosmjs/tendermint-rpc/build/tendermint37/adaptor/responses.js
index 961f32d..ced45eb 100644
--- a/node_modules/@cosmjs/tendermint-rpc/build/tendermint37/adaptor/responses.js
+++ b/node_modules/@cosmjs/tendermint-rpc/build/tendermint37/adaptor/responses.js
@@ -72,7 +72,7 @@ function decodePubkey(data) {
if ("Sum" in data) {
// we don't need to check type because we're checking algorithm
const [[algorithm, value]] = Object.entries(data.Sum.value);
- (0, utils_1.assert)(algorithm === "ed25519" || algorithm === "secp256k1", `unknown pubkey type: ${algorithm}`);
+ (0, utils_1.assert)(algorithm === "ed25519" || algorithm === "secp256k1" || algorithm === "bn254", `unknown pubkey type: ${algorithm}`);
return {
algorithm,
data: (0, encoding_1.fromBase64)((0, encodings_1.assertNotEmpty)(value)),
@@ -91,6 +91,11 @@ function decodePubkey(data) {
algorithm: "secp256k1",
data: (0, encoding_1.fromBase64)((0, encodings_1.assertNotEmpty)(data.value)),
};
+ case "tendermint/PubKeyBn254":
+ return {
+ algorithm: "bn254",
+ data: (0, encoding_1.fromBase64)((0, encodings_1.assertNotEmpty)(data.value)),
+ };
default:
throw new Error(`unknown pubkey type: ${data.type}`);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment