-
Notifications
You must be signed in to change notification settings - Fork 395
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
ICS 15: Cosmos Signed Messages #33
Changes from 14 commits
a085d33
07adec0
f28e124
ec6ae4d
3db9b31
46a127c
1b8e940
57e58c2
1a1972c
303c7f3
9250029
0f93415
4ddafcc
d38b494
0aa214e
64181a4
8f19f74
650f8cd
0b7e041
1184199
b3e3429
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
--- | ||
ics: 15 | ||
title: Cosmos Signed Messages | ||
stage: draft | ||
category: misc | ||
author: Aleksandr Bezobchuk <[email protected]> | ||
created: 2019-03-07 | ||
modified: 2019-03-07 | ||
--- | ||
|
||
# Synopsis | ||
|
||
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Many added benefits compared to sending transactions? We should make that explicit (signing messages allows for cheaper authentication where ordering or provable state is not necessary) |
||
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 | ||
alexanderbez marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sentence fragment, what do you mean? |
||
|
||
A standardized protocol for hashing, signing, and verifying messages that can be | ||
implemented by the Cosmos SDK and other third-party organizations is needed. | ||
|
||
# Specification | ||
|
||
## Desired Properties | ||
|
||
The Cosmos message signing standardized protocol subscribes to the following: | ||
alexanderbez marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
* Use of a secure cryptographic hash function (e.g. resistance to collision and second | ||
pre-image attacks) | ||
* Hash and sign over human-readable and machine-parsable messages | ||
* Is invulnerable to chosen ciphertext attacks | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does this mean in the context of a hash function? |
||
* Allow for signing over structured data | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ... why (so that UIs can parse the data and display it in a user-friendly format, presumably) |
||
* Contains a framework for deterministic and injective encoding of structured data | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. injective to the bytes signed? It will only be injective modulo hash function collisions. |
||
* Have builtin framework and support for domain separation and replay protection | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose either "Have" or "Has" consistently throughout these bullet points |
||
* Has protection against potentially signing transactions a user did not intend to | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interesting - what do you mean here? |
||
|
||
## Technical Specification | ||
|
||
The Cosmos message signing protocol will be parameterized over a secure | ||
cryptographic hash function `y ← H(x)` and a public key DSA `(sk,pk) ← S`, where | ||
`H` satisfies the desired properties such as having resistance to collision and | ||
second pre-image attacks, as well as being | ||
[deterministic](https://en.wikipedia.org/wiki/Hash_function#Determinism) and | ||
[uniform](https://en.wikipedia.org/wiki/Hash_function#Uniformity) and where | ||
`S` contains the operations <code>sign<sub>sk</sub>(x) → z</code> and | ||
<code>verify<sub>pk</sub>(x,z,H) → true|false</code> which provide digital | ||
signatures over a set of bytes and verification of signatures respectively. | ||
|
||
Tendermint has a well established protocol for signing messages using a canonical | ||
JSON representation as defined [here](https://github.com/tendermint/tendermint/blob/master/types/canonical.go). With the given canonical JSON structure, the specification requires | ||
that they include the meta fields `@chain_id` and `@type`, both of which are strings. | ||
These meta fields are **reserved** and **must** be included. In addition, the fields | ||
must be ordered in lexicographically ascending order. | ||
|
||
For the purposes of signing Cosmos messages, the `@chain_id` field must correspond | ||
to the Cosmos chain identifier. The user-agent should **refuse** signing if the | ||
alexanderbez marked this conversation as resolved.
Show resolved
Hide resolved
|
||
`@chain_id` field does not match the currently active chain! The `@type` field | ||
corresponds to the type of structure the user will be signing in an application. | ||
The protocol allows for signing valid ASCII text and application-specific objects. | ||
In the former case, the `@type` must be `"message"` and the latter case `@type` | ||
must be `"object"`. | ||
|
||
Having the ability to support domain separation of messages is also be vital as | ||
just simply encoding messages is not sufficient. For example, some applications | ||
may produce identical messages or structures and when signed can be valid on | ||
both applications. Thus an optional field `domain_separator` may be provided which | ||
is intended to include data that is specific to the application. In addition, | ||
client may provide optional replay protection data via the fields `nonce`, | ||
`block_height`, and `timestamp`. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How should the user agent validate these fields? |
||
|
||
Finally, the JSON representation must also include a `data` field which is the | ||
application-specific user supplied message and where the type corresponds to the | ||
value defined by the `@type` field. This must be valid ASCII text or | ||
an application-specific object. | ||
|
||
Thus, we can have a canonical JSON structure for signing Cosmos messages using | ||
the [JSON schema](http://json-schema.org/) specification: | ||
|
||
```json | ||
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$id": "cosmos/signing/typeData/schema", | ||
"title": "The Cosmos signed message typed data schema.", | ||
"type": "object", | ||
"properties": { | ||
"@chain_id": { | ||
"type": "string", | ||
"description": "The corresponding Cosmos chain identifier.", | ||
"minLength": 1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it possible to specify |
||
}, | ||
"@type": { | ||
"type": "string", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can this "type" be a JSON schema itself, for signing structured data? |
||
"description": "The message type.", | ||
"enum": [ | ||
"message", | ||
"object" | ||
] | ||
}, | ||
"data": { | ||
"type": ["string", "object"], | ||
"description": "The application message.", | ||
"pattern": "^[\\x20-\\x7E]+$", | ||
"minLength": 1 | ||
}, | ||
"domain_separator": { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What are example domain separators? |
||
"type": "string", | ||
"description": "The application unique domain separator.", | ||
"pattern": "^[\\x20-\\x7E]+$", | ||
"minLength": 1 | ||
}, | ||
"nonce": { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could this be a part of the domain separator? |
||
"type": "integer", | ||
"description": "The account nonce.", | ||
"minimum": 0 | ||
}, | ||
"block_height": { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could this be a part of the domain separator? |
||
"type": "integer", | ||
"description": "The chain block height.", | ||
"minimum": 0 | ||
}, | ||
"timestamp": { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could this be a part of the domain separator? How should it be validated? |
||
"type": "integer", | ||
"minimum": 0 | ||
} | ||
}, | ||
"required": [ | ||
"@chain_id", | ||
"@type", | ||
"data" | ||
] | ||
} | ||
``` | ||
|
||
We can formally specify the Cosmos message signing protocol as follows. | ||
Given a message `m` that adheres to the JSON schema defined and `M`, the set of | ||
all possible valid messages: <code>∀m ∈ M, z ← sign<sub>sk</sub>(H(m))</code>. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need a separate |
||
|
||
# History | ||
|
||
2019-03-07: Initial ICS 1 draft finished and submitted as a PR | ||
|
||
# Copyright | ||
|
||
Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can omit this sentence.
See http://kemthemerciless.blogspot.com/2007/08/since-dawn-of-time-students-have-sucked.html