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 43 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
128 changes: 128 additions & 0 deletions docs/architecture/adr-036-arbitrary-signature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# 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, for Cosmos SDK ecosystem, a way to sign and validate off-chain arbitrary messages.

This specification serves the purpose of covering every use case, this means that cosmos-sdk applications developers decide how to serialize and represent `Data` to users.
## 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.

Further context and use cases can be found in the references links.

## 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 but **must not** be a valid on-chain transaction. `chain-id`, `account_number` and `sequence` can all be assigned invalid 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.

Create the `offchain` proto definitions, we extend the auth module with `offchain` package to offer functionalities to verify and sign offline messages.

An offchain transaction follows these rules:

- the memo must be empty
- nonce, sequence number must be equal to 0
fdymylja marked this conversation as resolved.
Show resolved Hide resolved
- chain-id must be equal to “”
- fee gas must be equal to 0
- fee amount must be an empty array

Verification of an offchain transaction follows the same rules as an onchain one, except for the spec differences highlighted above.

The first message added to the `offchain` package is `MsgSignData`.

`MsgSignData` allows developers to sign arbitrary bytes valid offchain only. Where `Signer` is the account address of the signer. `Data` is arbitrary bytes which can represent `text`, `files`, `object`s. It's applications developers decision how `Data` should be deserialized, serialized and the object it can represent in their context.

It's applications developers decision how `Data` should be treated, by treated we mean the serialization and deserialization process and the Object `Data` should represent.


Proto definition:
```proto
// MsgSignData defines an arbitrary, general-purpose, off-chain message
message MsgSignData {
// Signer is the sdk.AccAddress of the message signer
bytes Signer = 1 [(gogoproto.jsontag) = "signer", (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
// Data represents the raw bytes of the content that is signed (text, json, etc)
bytes Data = 2 [(gogoproto.jsontag) = "data"];
}
ethanfrey marked this conversation as resolved.
Show resolved Hide resolved
fdymylja marked this conversation as resolved.
Show resolved Hide resolved
```
Signed MsgSignData json example:
```json
{
"type": "cosmos-sdk/StdTx",
"value": {
"msg": [
{
"type": "sign/MsgSignData",
"value": {
"signer": "cosmos1hftz5ugqmpg9243xeegsqqav62f8hnywsjr4xr",
"data": "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 off-chain messages.
- The specification is primitive which means it can cover every use case without limiting what is possible to fit inside it.
- It gives room for other off-chain messages specifications that aim to target more specific and common use cases such as off-chain-based authN/authZ layers [2].

### Negative

alessio marked this conversation as resolved.
Show resolved Hide resolved
- Current proposal requires a fixed relationship between an account address and a public key.
- Doesn't work with multisig accounts.

## Further discussion

alessio marked this conversation as resolved.
Show resolved Hide resolved
- Regarding security in `MsgSignData`, the developer using `MsgSignData` is in charge of making the content laying in `Data` non-replayable when, and if, needed.
- the offchain package will be further extended with extra messages that target specific use cases such as, but not limited to, authentication in applications, payment channels, L2 solutions in general.

## References

1. https://github.com/cosmos/ics/pull/33
2. https://github.com/cosmos/cosmos-sdk/pull/7727#discussion_r515668204
3. https://github.com/cosmos/cosmos-sdk/pull/7727#issuecomment-722478477
4. https://github.com/cosmos/cosmos-sdk/pull/7727#issuecomment-721062923