chainapsis / keplr-wallet

The most powerful wallet for the Cosmos ecosystem and the Interchain
https://www.keplr.app
Other
755 stars 451 forks source link

Request ADR-36 signatures #645

Open ghost opened 1 year ago

ghost commented 1 year ago

Describe the bug

I want to be able to use the signAmino method exposed by the Keplr extension to sign ADR36 objects. Ideally this code "just works",

const signer = await window.keplr.getOfflineSigner("cosmoshub-4");
await signer.signAmino(address, makeADR36AminoSignDoc(address, payload));

But it throws the error Unmatched chain id with the offline signer. Unfortunately, I have to do

await window.keplr.signArbitrary(
      "cosmoshub-4",
      address,
      payload
);

Device details (please complete the following information):

Thunnini commented 1 year ago

What did you use for "address" and "payload"?

ghost commented 1 year ago

address was my currently connected Keplr account address for CosmosHub. payload was "hello there". However, my point is that the SignDoc returned by makeADR36AminoSignDoc has no chainId, so afaict this will never work.

ThomasDEVio commented 1 year ago

I have also had the same issue with this.

LaurensKubat commented 5 months ago

An Adr-36 SignDoc has chain set to "" in it's internal payload, so you'd have to sign

await window.keplr.signArbitrary(
      "",
      address,
      payload
);

to prevent the mismatch

This will most likely still produce different signatures from the keplr signArbitrary function though, because the internal serialization of signArbitrary within serializeSignDoc also sorts the json by keys, something which you don't get/do when just calling makeADR36AminoSignDoc