or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Syncing
xxxxxxxxxx
Sign Mode Textual
This HackMD serves as a living document to specify SIGN_MODE_TEXTUAL.
Related conversations:
Specification (WIP)
We propose to have SIGN_MODE_TEXTUAL's signing payload
SignDocTextual
to be an array of strings. Each string would correspond to one "screen" on the Ledger device, with no (or little, TBD) additional formatting done by the Ledger app.The string array MUST follow the specifications below.
1. Bijectivity with Protobuf transactions
The encoding and decoding operations between a Protobuf transaction (whose definition can be found here) and the string array MUST be bijective.
We concede that bijectivity is not strictly needed. Avoiding transaction malleability only requires collision resistance on the encoding. Lossless encoding also does not require decodability. However, bijectivity assures both non-malleability and losslessness.
This also prevents users signing over hashed transaction metadata, which is a security concern for Ledger (the company).
We propose to maintain functional tests using bijectivity in the SDK to assure losslessness and the absence of malleability.
2. Only ASCII 32-127 characters allowed
Ledger devices have limited character display capabilities, so all strings MUST only contain ASCII characters in the 32-127 range.
In particular, the newline
"\n"
(ASCII: 10) character is forbidden.3. All strings have the
<key>: <value>
formatAll strings MUST match the following Regex:
TODO
.This is helpful for UIs displaying SignDocTextual to users. This MAY be used in the Ledger app to perform custom on-screen formatting, for example to break long lines into multiple screens.
The
<value>
itself can contain the": "
characters.4. Values are encoded using Value Renderers
5. Strings starting with
*
are only shown in Expert modeLedger devices have the an Expert mode for advanced users. Strings starting with the
*
character will only be shown in Expert mode.6. The string array format
Below is the general format of a TX with N msgs. Each new line corresponds to a new screen on the Ledger device.
//
denotes comments and are not shown on the Ledger device.How does the envelope get rendered?
How does each Msg get rendered?
Support LEGACY_AMINO_JSON for backwards-compatbility
Rejected ideas
N
(TBD) characters, to avoid string streaming on the screen.)Wire Format
This string array is encoded as a single
\n
-delimited string.Value Renderers
These describe how values of different types should be automatically rendered.
number
sdk.Dec
,sdk.Int
, and other numeric types (uint64
, etc.),
s for every three integral digits1000
->1,000
1000000.00
->1,000,000.00
TODO consider
'
as separator?coin
Coin
display
denoms usingMetadata
(if available)display
denom amounts and rendered asnumber
s abovecosmos:hub:atom
)1000000000uatom
->1,000 atom
type_url
SIGN_MODE_TEXTUAL
should have a short name associated with them that can be used in format strings whenever the type url is explicitly referenced (as in theMsgRevoke
examples below).cosmos.bank.v1beta1.MsgSend
->bank send coins
cosmos.gov.v1beta1.MsgVote
->governance vote
Arrays
TODO
Structs
TODO
Enums
enum VoteOption
VoteOption
) to snake_case (VOTE_OPTION
)_
from the enum name if it exists (VOTE_OPTION_
gets stripped fromVOTE_OPTION_YES
->YES
)YES
->Yes
VOTE_OPTION_YES
->Yes
google.protobuf.Timestamp
(TODO)Rendered as either ISO8601 (
2021-01-01T12:00:00Z
) or a more standard English-language date format (Jan. 1, 2021 12:00 UTC
)google.protobuf.Duration
(TODO)1483530 seconds
->2 weeks, 3 days, 4 hours, 5 minutes, 30 seconds (1483530 seconds total)
address bytes
We currently use
string
types in protobuf for addresses so this may not be needed, but if any address bytes are used in sign mode textual they should be rendered with bech32 formattingExamples
Example 1: Simple
MsgSend
JSON:
SIGN_MODE_TEXTUAL:
Example 2: Multi-Msg Transaction with 3 signers
Example 3: Legacy Multisig
Example 4: Fee Payer with Tips
SIGN_MODE_TEXTUAL for the feepayer:
Aaron's Original Proposal
Click here to see original version of this hackmd
I propose using the https://mustache.github.io syntax (with
{
and}
delimiters instead of{{
and}}
) and with values pre-rendered based on their type using the value renderers below.Value Renderers
These describe how values of different types should be automatically rendered.
number
sdk.Dec
,sdk.Int
, and other numeric types (uint64
, etc.),
s for every three integral digits1000
->1,000
1000000.00
->1,000,000.00
coin
Coin
display
denoms usingMetadata
(if available)display
denom amounts and rendered asnumber
s abovecosmos:hub:atom
)1000000000uatom
->1,000 atom
google.protobuf.Timestamp
Rendered as either ISO8601 (
2021-01-01T12:00:00Z
) or a more standard English-language date format (Jan. 1, 2021 12:00 UTC
)google.protobuf.Duration
1483530 seconds
->2 weeks, 3 days, 4 hours, 5 minutes, 30 seconds (1483530 seconds total)
type_url
SIGN_MODE_TEXTUAL
should have a short name associated with them that can be used in format strings whenever the type url is explicitly referenced (as in theMsgRevoke
examples below).cosmos.bank.v1beta1.MsgSend
->bank send
cosmos.gov.v1beta1.MsgVote
->governance vote
address bytes
We currently use
string
types in protobuf for addresses so this may not be needed, but if any address bytes are used in sign mode textual they should be rendered with bech32 formattingExamples
These examples all use the mustache syntax with simple
{
and}
delimiters.bank
MsgSend
MsgMultiSend
authz
MsgGrant
GenericAuthorization
SendAuthorization
StakeAuthorization
MsgExec
MsgRevoke
Revoke the authorization of {grantee} to perform {msg_type_url} operations on behalf of {granter}
Examples:
Crisis
MsgVerifyInvariant
Distribution
MsgWithdrawDelegatorReward
MsgSetWithdrawAddress
gov
MsgVote
MsgSubmitProposal
staking
MsgDelegate
Delegate {amount} from delegator {delegator_address} to {validator_address}
feegrant
MsgGrantAllowance
BasicAllowance
PeriodicAllowance
Ex: