You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// This list defines the signing modes for the required signers. The number
94
+
// and order of elements must match the required signers from TxBody's messages.
95
+
// The first element is the primary signer and the one which pays the fee.
70
96
repeated SignerInfo signer_infos = 1;
71
-
// The first signer is the primary signer and the one which pays the fee
97
+
// The fee can be calculated based on the cost of evaluating the body and doing signature verification of the signers. This can be estimated via simulation.
72
98
Fee fee = 2;
73
99
}
74
100
75
101
message SignerInfo {
76
-
// PublicKey key is optional for accounts that already exist in state
102
+
// The public key is optional for accounts that already exist in state. If unset, the
103
+
// verifier can use the required signer address for this position and lookup the public key.
77
104
PublicKey public_key = 1;
78
105
// ModeInfo describes the signing mode of the signer and is a nested
79
106
// structure to support nested multisig pubkey's
@@ -149,14 +176,16 @@ buffers implementation
149
176
subtle differences between the signing and encoding formats which could
150
177
potentially be exploited by an attacker)
151
178
152
-
Signatures are structured using the `SignDoc` below which reuses `TxBody` and
153
-
`AuthInfo` and only adds the fields which are needed for signatures:
179
+
Signatures are structured using the `SignDoc` below which reuses the serialization of
180
+
`TxBody` and `AuthInfo` and only adds the fields which are needed for signatures:
154
181
155
182
```proto
156
183
// types/types.proto
157
184
message SignDoc {
158
-
TxBody body = 1;
159
-
AuthInfo auth_info = 2;
185
+
// A protobuf serialization of a TxBody that matches the representation in TxRaw.
186
+
bytes body = 1;
187
+
// A protobuf serialization of an AuthInfo that matches the representation in TxRaw.
188
+
bytes auth_info = 2;
160
189
string chain_id = 3;
161
190
uint64 account_number = 4;
162
191
// account_sequence starts at 1 rather than 0 to avoid the case where
@@ -167,36 +196,27 @@ message SignDoc {
167
196
168
197
In order to sign in the default mode, clients take the following steps:
169
198
170
-
1. Encode `SignDoc`. (The only requirement of the underlying protobuf
171
-
implementation is that fields are serialized in order).
172
-
2. Sign the encoded `SignDoc` bytes
173
-
3. Build and broadcast `Tx`. (The underlying protobuf implementation must encode
174
-
`TxBody` and `AuthInfo` with the same binary representation as encoded in
175
-
`SignDoc`. If this is a problem for clients, the "raw" types described under
176
-
verification can be used for signing as well.)
199
+
1. Serialize `TxBody` and `AuthInfo` using any valid protobuf implementation.
200
+
2. Create a `SignDoc` and encode it. (The only requirement of the underlying
201
+
protobuf implementation is that fields are serialized in order).
202
+
3. Sign the encoded `SignDoc` bytes.
203
+
4. Build a `TxRaw` and serialize it for broadcasting.
177
204
178
205
Signature verification is based on comparing the raw `TxBody` and `AuthInfo`
179
-
bytes encoded in `Tx` not based on any ["canonicalization"](https://github.com/regen-network/canonical-proto3)
206
+
bytes encoded in `TxRaw` not based on any ["canonicalization"](https://github.com/regen-network/canonical-proto3)
180
207
algorithm which creates added complexity for clients in addition to preventing
181
208
some forms of upgradeability (to be addressed later in this document).
182
209
183
-
Signature verifiers should use a special set of "raw" types to perform this
184
-
binary signature verification rather than attempting to re-encode protobuf
185
-
documents which could result in a different binary encoding:
210
+
Signature verifiers do:
186
211
187
-
```proto
188
-
message TxRaw {
189
-
bytes body_bytes = 1;
190
-
repeated bytes signatures = 2;
191
-
}
192
-
193
-
message SignDocRaw {
194
-
bytes body_bytes = 1;
195
-
string chain_id = 2;
196
-
uint64 account_number = 3;
197
-
uint64 account_sequence = 4;
198
-
}
199
-
```
212
+
1. Deserialize a `TxRaw` and pull out `body` and `auth_info`.
213
+
2. Create a list of required signer addresses from the messages.
214
+
3. For each required signer:
215
+
- Pull account number and sequence from the state.
216
+
- Obtain the public key either from state or `AuthInfo`'s `signer_infos`.
217
+
- Create a `SignDoc` and serialize it. Due to the simplicity of the type it
218
+
is expected that this matches the serialization used by the signer.
219
+
- Verify the signature at the the same list position against the serialized `SignDoc`.
0 commit comments