Signatures
Signature is the evidence to prove the sender owns the transaction. It will be created from the actions outlined below:
-
Compose a data structure. please note
msgs,memo,source,dataare the same as in the abovepayload.chain_id: a string, unique ID for the Chain, it stays the same for most time, but may vary as 5DAX Chain evolves;account_number: a string for a 64-bit integer, an identifier number associated with the signing addresssequence: a string for a a 64-bit integer, please check accountsmemo: a string, a short sentence of remark for the transactionmsgs: a byte array, json encoded transaction messages, please check the encoding doc.source: a string for a 64 bits integer, which is an identifier for transaction incoming toolsdata: byte array, reserved for future use
Here is an example in go-sdk:
golang
// StdSignMsg def
type StdSignMsg struct {
ChainID string `json:"chain_id"`
AccountNumber int64 `json:"account_number"`
Sequence int64 `json:"sequence"`
Msgs []msg.Msg `json:"msgs"`
Memo string `json:"memo"`
Source int64 `json:"source"`
Data []byte `json:"data"`
}
-
Encode the above data structure in json, with ordered key, Specifically:
- Maps have their keys sorted lexicographically
- Structs keys are marshalled in the order defined in the struct
-
Sign SHA256 of the encoded byte array, to create an ECDSA signature on curve Secp256k1 and serialize the
RandSresult into a 64-byte array. (bothRandSare encoded into 32-byte big endian integers, and thenRis put into the first 32 bytes andSare put into the last 32 bytes of the byte array. In order to breakS's malleability,Sset tocurve.Order() - SifS > curnve.Order()/2.)
The signature will be encoded together with transaction message and sent as payload to 5DAX Chain node via RPC or http REST API, as described in the above section.