From af05a961a56c27bfc5cbcdb93efcf0b93e805e78 Mon Sep 17 00:00:00 2001 From: Sztergbaum Roman Date: Tue, 29 Aug 2023 09:54:15 +0200 Subject: [PATCH] feat(cosmos_signer): support pre-hash for evm cosmos chain(s) (#3399) --- src/Cosmos/Signer.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Cosmos/Signer.cpp b/src/Cosmos/Signer.cpp index c27bc984045..10ca459204f 100644 --- a/src/Cosmos/Signer.cpp +++ b/src/Cosmos/Signer.cpp @@ -26,13 +26,16 @@ Proto::SigningOutput Signer::sign(const Proto::SigningInput& input, TWCoinType c } std::string Signer::signaturePreimage(const Proto::SigningInput& input, const Data& publicKey, TWCoinType coin) const { + auto isEvmCosmosChain = [coin]() { + return coin == TWCoinTypeNativeInjective || coin == TWCoinTypeEvmos || coin == TWCoinTypeNativeCanto; + }; switch (input.signing_mode()) { case Proto::JSON: return Json::signaturePreimageJSON(input).dump(); case Proto::Protobuf: default: - auto pbk = PublicKey(publicKey, TWPublicKeyTypeSECP256k1); + auto pbk = isEvmCosmosChain() ? PublicKey(publicKey, TWPublicKeyTypeSECP256k1Extended) : PublicKey(publicKey, TWPublicKeyTypeSECP256k1); return Protobuf::signaturePreimageProto(input, pbk, coin); } }