Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADR036: Arbitrary signature #7727

Merged
merged 53 commits into from
Apr 19, 2021
Merged
Changes from 13 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
6c8406e
add: arbitrary signature adr draft
fdymylja Oct 28, 2020
f54988f
fix: adr number
fdymylja Oct 29, 2020
deb1d03
Merge branch 'master' into frojdi/signature-adr
Oct 29, 2020
971d0b6
Merge branch 'master' into frojdi/signature-adr
Oct 29, 2020
054f689
Merge branch 'master' into frojdi/signature-adr
fdymylja Oct 29, 2020
e012555
change: adjust scope, address feedback
fdymylja Oct 29, 2020
8481af3
fix: missing sentence
fdymylja Oct 29, 2020
6fb3681
Merge branch 'master' into frojdi/signature-adr
Oct 30, 2020
4cb2ee8
Merge branch 'master' into frojdi/signature-adr
Oct 30, 2020
8325dbf
Merge branch 'master' into frojdi/signature-adr
Nov 1, 2020
d92cf39
Merge branch 'master' into frojdi/signature-adr
Nov 2, 2020
252ca11
Merge branch 'master' into frojdi/signature-adr
Nov 5, 2020
3c6ee29
Merge branch 'master' into frojdi/signature-adr
Nov 5, 2020
2ff847d
Merge branch 'master' into frojdi/signature-adr
Nov 6, 2020
5f53530
Merge branch 'master' into frojdi/signature-adr
Nov 9, 2020
3faf219
Merge branch 'master' into frojdi/signature-adr
Nov 9, 2020
b8620d9
Merge branch 'master' into frojdi/signature-adr
fdymylja Nov 10, 2020
87ad64a
change: address wording
fdymylja Nov 10, 2020
f15c487
change: address wording and formatting
fdymylja Nov 10, 2020
1e33f9f
change: address formatting
fdymylja Nov 10, 2020
4ad1115
change: message name, address modal verbs changes
fdymylja Nov 10, 2020
8ddd4cb
change: document how MsgSignData should be used
fdymylja Nov 10, 2020
03d0804
Merge remote-tracking branch 'origin/frojdi/signature-adr' into frojd…
fdymylja Nov 10, 2020
af35dc4
change: address wording
fdymylja Nov 10, 2020
d11c2a4
Merge branch 'master' into frojdi/signature-adr
Nov 12, 2020
cbd42ac
add: how verification works
fdymylja Nov 12, 2020
ec0cee2
Merge branch 'frojdi/signature-adr' of https://github.com/cosmos/cosm…
fdymylja Nov 12, 2020
8418241
Merge branch 'master' into frojdi/signature-adr
Nov 13, 2020
4b11e74
Merge branch 'master' into frojdi/signature-adr
Nov 13, 2020
0fc3e61
Merge branch 'master' into frojdi/signature-adr
Nov 13, 2020
6967986
Update docs/architecture/adr-036-arbitrary-signature.md
Nov 13, 2020
10f4cd5
Update docs/architecture/adr-036-arbitrary-signature.md
Nov 13, 2020
bd83648
Apply suggestions from code review
Nov 13, 2020
181ba07
Update docs/architecture/adr-036-arbitrary-signature.md
Nov 13, 2020
6f65692
add: expand further discussion items
fdymylja Nov 13, 2020
2e5cea6
Merge branch 'frojdi/signature-adr' of https://github.com/cosmos/cosm…
fdymylja Nov 13, 2020
9a03583
fix: wording
fdymylja Nov 13, 2020
4847358
add: context references
fdymylja Nov 13, 2020
ab670d0
change: split offchain tx specific from MsgSignData
fdymylja Nov 13, 2020
d8523c1
Merge branch 'master' into frojdi/signature-adr
Nov 13, 2020
61dfc0b
Merge branch 'master' into frojdi/signature-adr
Nov 13, 2020
c35d50f
Merge branch 'master' into frojdi/signature-adr
Nov 13, 2020
3fe26de
Merge branch 'master' into frojdi/signature-adr
Nov 13, 2020
058906e
Merge branch 'master' into frojdi/signature-adr
Nov 13, 2020
483bcdd
Merge branch 'master' into frojdi/signature-adr
Nov 16, 2020
fcd92d7
Merge branch 'master' into frojdi/signature-adr
Jan 5, 2021
3a06356
Merge branch 'master' into frojdi/signature-adr
Jan 12, 2021
1a38d53
Merge branch 'master' into frojdi/signature-adr
Feb 24, 2021
6ba7d05
Merge branch 'master' into frojdi/signature-adr
Feb 24, 2021
6a1f9b6
Merge branch 'master' into frojdi/signature-adr
Apr 12, 2021
02aaeeb
Merge branch 'master' into frojdi/signature-adr
Apr 12, 2021
67a56d1
Merge branch 'master' into frojdi/signature-adr
tac0turtle Apr 19, 2021
cf0cb9b
Merge branch 'master' into frojdi/signature-adr
tac0turtle Apr 19, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 103 additions & 0 deletions docs/architecture/adr-036-arbitrary-signature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# ADR 036: Arbitrary Message Signature Specification

## Changelog

- 28/10/2020 - Initial draft

## Authors
fdymylja marked this conversation as resolved.
Show resolved Hide resolved
- Antoine Herzog (@antoineherzog)
- Zaki Manian (@zmanian)
- Aleksandr Bezobchuk (alexanderbez) [1]
- Frojdi Dymylja (@fdymylja)
ethanfrey marked this conversation as resolved.
Show resolved Hide resolved

## Status

Draft
fdymylja marked this conversation as resolved.
Show resolved Hide resolved

## Abstract

Currently, in the SDK, there is no convention to sign arbitrary message like on Ethereum. We propose with this specification a way to sign arbitrary message for Cosmos SDK chains.
fdymylja marked this conversation as resolved.
Show resolved Hide resolved

## Context
fdymylja marked this conversation as resolved.
Show resolved Hide resolved

Having the ability to sign messages off-chain has proven to be a fundamental aspect of nearly any blockchain. The notion of signing messages off-chain has many added benefits such as saving on computational costs and reducing transaction throughput and overhead. Within the context of the Cosmos, some of the major applications of signing such data includes, but is not limited to, providing a cryptographic secure and verifiable means of proving validator identity and possibly associating it with some other framework or organization. In addition, having the ability to sign Cosmos messages with a Ledger or similar HSM device.


## Decision

The aim is being able to sign arbitrary messages, even using Ledger or similar HSM devices.

As a result signed messages should look roughly like Cosmos SDK messages. chain-id, account_number and sequence can all be assigned invalid values.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

fdymylja marked this conversation as resolved.
Show resolved Hide resolved
The CLI should set those to default values.

Cosmos SDK 0.40 also introduces a concept of “auth_info” this can specify SIGN_MODES.

A spec should include an auth info that supports SIGN_MODE_DIRECT and SIGN_MODE_LEGACY_AMINO.
fdymylja marked this conversation as resolved.
Show resolved Hide resolved

- the memo should be empty
- nonce, sequence number should be equal to 0
- chain-id should be equal to “signature”
- fee gas should be equal to 0
- fee amount should be an empty array
- Inside the message with the type MsgSignText, we put inside a *bytes* message and the address of the signer.
robert-zaremba marked this conversation as resolved.
Show resolved Hide resolved

Proto definition:
```proto
// MsgSignedMessage defines
message MsgSignedMessage {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this should be MsgSignText based on the previous text.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer MsgSignData. Msg is overloaded here (3 times in 2 "words")

// Signer is the sdk.AccAddress of the message signer
bytes Signer = 1 [(gogoproto.jsontag) = "signer", (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
// Message represents the raw bytes of the content that is signed (text, json, etc)
bytes Message = 2 [(gogoproto.jsontag) = "message"];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How will this be displayed on Ledgers and similar HSMs?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think at this we don't have an answer to that. Would you be OK with unblocking this on the promise that we'll continue doing work once this is approved?

Copy link
Collaborator

@robert-zaremba robert-zaremba Feb 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then we should add a further discussion secton in the ADR and create a tracking issue on Github

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then we should add a further discussion section in the ADR and create a tracking issue on Github

How could this reply of yours possibly answer my question?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Open an issue to facilitate further discussions. Let's get this merged. I would say the implementation is blocked until the issue on ledger and hsm is undersood and a solution has been agreed on. We can see if zondax can join a sdk call in the coming weeks.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, thanks @marbar3778 and @robert-zaremba

}
ethanfrey marked this conversation as resolved.
Show resolved Hide resolved
fdymylja marked this conversation as resolved.
Show resolved Hide resolved
```
Signed MsgSignedMessage json example:
```json
{
"type": "cosmos-sdk/StdTx",
"value": {
"msg": [
{
"type": "sign/MsgSignedMessage",
"value": {
"signer": "cosmos1hftz5ugqmpg9243xeegsqqav62f8hnywsjr4xr",
"message": "cmFuZG9t"
}
}
],
"fee": {
"amount": [],
"gas": "0"
},
"signatures": [
{
"pub_key": {
"type": "tendermint/PubKeySecp256k1",
"value": "AqnDSiRoFmTPfq97xxEb2VkQ/Hm28cPsqsZm9jEVsYK9"
},
"signature": "8y8i34qJakkjse9pOD2De+dnlc4KvFgh0wQpes4eydN66D9kv7cmCEouRrkka9tlW9cAkIL52ErB+6ye7X5aEg=="
}
],
"memo": ""
}
}
```

## Consequences

There is a specification on how messages, that are not meant to be broadcast to a live chain, should be formed.

### Backwards Compatibility

Backwards compatibility is maintained as this is a new message spec definition.

### Positive

- A common format that can be used by multiple applications to sign and verify offchain messages.

### Negative

alessio marked this conversation as resolved.
Show resolved Hide resolved

alessio marked this conversation as resolved.
Show resolved Hide resolved
## References

1. https://github.com/cosmos/ics/pull/33