cosmos / cosmjs

The Swiss Army knife to power JavaScript based client solutions ranging from Web apps/explorers over browser extensions to server-side clients like faucets/scrapers.
https://cosmos.github.io/cosmjs/
Apache License 2.0
645 stars 330 forks source link

Implement ADR-036 #844

Open webmaster128 opened 3 years ago

webmaster128 commented 3 years ago

ADR-036 was merged as a draft spec for signing arbitrary data using a Cosmos SDK keypair. We should try to implement it.

webmaster128 commented 3 years ago

There is a draft implementation in #847 but looking at https://github.com/cosmos/cosmos-sdk/pull/7727#issuecomment-884261972 the spec seems to be work in progress. So not much more we can do here at this point.

ethanfrey commented 3 years ago

It would be cool feature for dApps when it is stabilised, but yeah... seems like we are waiting for a spec here. Since wintertime I believe.

JGJP commented 2 years ago

Hey guys, how are we looking on this? Possible to implement something now?

blake-regalia commented 2 years ago

🤔

ethanfrey commented 2 years ago

This would be a nice addition. I don't think a standard will be ratified, but if there is a library that is compatible with ledger and Keplr and gets adopted, it will become the standard.

Such a library could easily be built on top of CosmJS, but I think it doesn't really belong as a part of that. Maybe in some sort of tooling library.

Does anyone commenting here want to implement it with support from Confio? Or rather requesting that we implement it?

If you wish us to implement it, a few concrete use cases would be great to ensure it covers them all.

JGJP commented 2 years ago

It's a while since I implemented arbitrary message signing with Keplr, but I was able to use keplr.signAmino. The thinking regarding adding it to cosmjs is that SigningStargateClient is already in the business of requesting signatures, and also has a signAmino but for some reason was not able to request the signature in this instance. Showing my working example with Keplr here for reference, as I think it shows something that's already very close to what Stargate offers (AFAICR):

await window.keplr!.signAmino(chainId, account.address, {
    chain_id: "",
    account_number: "0",
    sequence: "0",
    fee: {
        gas: "0",
        amount: [],
    },
    msgs: [
        {
            type: "sign/MsgSignData",
            value: {
                signer: account.address,
                data: btoa(message.toLowerCase()),
            },
        },
    ],
    memo: "",
})

MsgSignData is also already mentioned in cosmjs-types. If its presence there is warranted then maybe implementation in cosmjs is warranted.

ThomasDEVio commented 1 year ago

Currently freezes the Keplr mobile app currently when using .signAmino with sign/MsgSignData type

williamchong commented 1 year ago

This would be a nice addition. I don't think a standard will be ratified, but if there is a library that is compatible with ledger and Keplr and gets adopted, it will become the standard.

Such a library could easily be built on top of CosmJS, but I think it doesn't really belong as a part of that. Maybe in some sort of tooling library.

Does anyone commenting here want to implement it with support from Confio? Or rather requesting that we implement it?

If you wish us to implement it, a few concrete use cases would be great to ensure it covers them all.

A very simple and useful use case would be to authenticate/sign-in with cosmos wallets by signing a challenge, or proving account ownership

JGJP commented 1 year ago

A very simple and useful use case would be to authenticate/sign-in with cosmos wallets by signing a challenge, or proving account ownership

Yes, that's exactly what I was using it for

ThomasDEVio commented 1 year ago

How can I do this on keplr mobile?Authentication/signing a messageOn 15 Mar 2023, at 13:51, J Garcia @.***> wrote:

A very simple and useful use case would be to authenticate/sign-in with cosmos wallets by signing a challenge, or proving account ownership

Yes, that's exactly what I was using it for

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>

JGJP commented 1 year ago

@ThomasDEVio I'm not familiar with the Keplr mobile interface. If my above code snippet doesn't work for you then it may not be doable