From 736847d3de174e59c65b25f4d8aeb82df23eea8b Mon Sep 17 00:00:00 2001 From: Aaron Craelius Date: Fri, 29 Jan 2021 12:08:04 -0500 Subject: [PATCH 1/3] Add SignDocTextual for proto JSON signing --- proto/cosmos/tx/v1beta1/tx.proto | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/proto/cosmos/tx/v1beta1/tx.proto b/proto/cosmos/tx/v1beta1/tx.proto index 2b02874cc183..80e799881048 100644 --- a/proto/cosmos/tx/v1beta1/tx.proto +++ b/proto/cosmos/tx/v1beta1/tx.proto @@ -63,6 +63,33 @@ message SignDoc { uint64 account_number = 4; } +// SignDocTextual is the type used for generating sign bytes for SIGN_MODE_TEXTUAL. It is designed to be serialized +// as proto3 JSON following the rules defined Here: https://github.com/regen-network/canonical-proto3/blob/master/README.md#json. +message SignDocTextual { + // body is the processable content of the transaction + TxBody body = 1; + + // auth_info is the authorization related content of the transaction, + // specifically signers, signer modes and fee + AuthInfo auth_info = 2; + + // chain_id is the unique identifier of the chain this transaction targets. + // It prevents signed transactions from being used on another chain by an + // attacker + string chain_id = 3; + + // account_number is the account number of the account in state + uint64 account_number = 4; + + // sign_doc_sha256_hash is the SHA-256 hash of SignDoc. It is included here to reduce the malleability attack + // surface of SIGN_MODE_TEXTUAL vs SIGN_MODE_DIRECT to zero. Basically this means that any discrepancy between + // protobuf bytes over the wire and protobuf bytes that are signed cannot be exploited. This information is obviously + // redundant with information already in SignDocTextual, but is included as a security check for scenarios where this + // information may have inadvertently been excluded. We include the hash of SignDoc rather than the full SignDoc bytes + // to reduce the size of SignDocTextual for scenarios where large payloads could cause problems for hardware wallets. + bytes sign_doc_sha256_hash = 5; +} + // TxBody is the body of a transaction that all signers sign over. message TxBody { // messages is a list of messages to be executed. The required signers of From ba0e9cc0d38a4890dae18c08c1ac034145ba61fb Mon Sep 17 00:00:00 2001 From: Federico Kunze <31522760+fedekunze@users.noreply.github.com> Date: Sun, 2 May 2021 10:00:14 -0400 Subject: [PATCH 2/3] Apply suggestions from code review Co-authored-by: Simon Warta <2603011+webmaster128@users.noreply.github.com> --- proto/cosmos/tx/v1beta1/tx.proto | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/proto/cosmos/tx/v1beta1/tx.proto b/proto/cosmos/tx/v1beta1/tx.proto index 80e799881048..8f8564d39efe 100644 --- a/proto/cosmos/tx/v1beta1/tx.proto +++ b/proto/cosmos/tx/v1beta1/tx.proto @@ -64,7 +64,7 @@ message SignDoc { } // SignDocTextual is the type used for generating sign bytes for SIGN_MODE_TEXTUAL. It is designed to be serialized -// as proto3 JSON following the rules defined Here: https://github.com/regen-network/canonical-proto3/blob/master/README.md#json. +// as proto3 JSON following the rules defined here: https://github.com/regen-network/canonical-proto3/blob/master/README.md#json. message SignDocTextual { // body is the processable content of the transaction TxBody body = 1; @@ -73,12 +73,12 @@ message SignDocTextual { // specifically signers, signer modes and fee AuthInfo auth_info = 2; - // chain_id is the unique identifier of the chain this transaction targets. + // chain_id is the identifier of the chain this transaction targets. // It prevents signed transactions from being used on another chain by an // attacker string chain_id = 3; - // account_number is the account number of the account in state + // account_number is the account number of the signing account in state uint64 account_number = 4; // sign_doc_sha256_hash is the SHA-256 hash of SignDoc. It is included here to reduce the malleability attack From 0dd1ac2d53a0645632483059131c4c228223f5ce Mon Sep 17 00:00:00 2001 From: Ru Horlick Date: Tue, 20 Jul 2021 14:25:42 +0100 Subject: [PATCH 3/3] Add SIGN_MODE_DIRECT_JSON --- docs/core/proto-docs.md | 32 +- proto/cosmos/tx/signing/v1beta1/signing.proto | 13 +- proto/cosmos/tx/v1beta1/tx.proto | 24 +- types/tx/signing/signing.pb.go | 81 +-- types/tx/tx.pb.go | 524 ++++++++++++++++-- x/auth/tx/direct_test.go | 1 + 6 files changed, 560 insertions(+), 115 deletions(-) diff --git a/docs/core/proto-docs.md b/docs/core/proto-docs.md index 92887dc08130..da5dfe526997 100644 --- a/docs/core/proto-docs.md +++ b/docs/core/proto-docs.md @@ -534,6 +534,7 @@ - [ModeInfo.Multi](#cosmos.tx.v1beta1.ModeInfo.Multi) - [ModeInfo.Single](#cosmos.tx.v1beta1.ModeInfo.Single) - [SignDoc](#cosmos.tx.v1beta1.SignDoc) + - [SignDocJSON](#cosmos.tx.v1beta1.SignDocJSON) - [SignerInfo](#cosmos.tx.v1beta1.SignerInfo) - [Tx](#cosmos.tx.v1beta1.Tx) - [TxBody](#cosmos.tx.v1beta1.TxBody) @@ -7456,10 +7457,11 @@ SignMode represents a signing mode with its own security guarantees. | Name | Number | Description | | ---- | ------ | ----------- | -| SIGN_MODE_UNSPECIFIED | 0 | SIGN_MODE_UNSPECIFIED specifies an unknown signing mode and will be rejected | -| SIGN_MODE_DIRECT | 1 | SIGN_MODE_DIRECT specifies a signing mode which uses SignDoc and is verified with raw bytes from Tx | -| SIGN_MODE_TEXTUAL | 2 | SIGN_MODE_TEXTUAL is a future signing mode that will verify some human-readable textual representation on top of the binary representation from SIGN_MODE_DIRECT | -| SIGN_MODE_LEGACY_AMINO_JSON | 127 | SIGN_MODE_LEGACY_AMINO_JSON is a backwards compatibility mode which uses Amino JSON and will be removed in the future | +| SIGN_MODE_UNSPECIFIED | 0 | SIGN_MODE_UNSPECIFIED specifies an unknown signing mode and will be rejected. | +| SIGN_MODE_DIRECT | 1 | SIGN_MODE_DIRECT specifies a signing mode which uses SignDoc and is verified with raw bytes from Tx. | +| SIGN_MODE_TEXTUAL | 2 | SIGN_MODE_TEXTUAL is a future signing mode that will verify some human-readable textual representation on top of the binary representation from SIGN_MODE_DIRECT. It is currently not supported. | +| SIGN_MODE_DIRECT_JSON | 3 | SIGN_MODE_DIRECT_JSON specifies a signing mode which uses SignDocJSON. It is verified using a canonical JSON representation of the bytes used in SIGN_MODE_DIRECT. | +| SIGN_MODE_LEGACY_AMINO_JSON | 127 | SIGN_MODE_LEGACY_AMINO_JSON is a backwards compatibility mode which uses Amino JSON and will be removed in the future. | @@ -7581,6 +7583,28 @@ SignDoc is the type used for generating sign bytes for SIGN_MODE_DIRECT. + + +### SignDocJSON +SignDocJSON is the type used for generating sign bytes for +SIGN_MODE_DIRECT_JSON. It is designed to be serialized as proto3 JSON +following the rules defined here: +https://github.com/regen-network/canonical-proto3/blob/master/README.md#json. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `body` | [TxBody](#cosmos.tx.v1beta1.TxBody) | | body is the processable content of the transaction | +| `auth_info` | [AuthInfo](#cosmos.tx.v1beta1.AuthInfo) | | auth_info is the authorization related content of the transaction, specifically signers, signer modes and fee | +| `chain_id` | [string](#string) | | chain_id is the identifier of the chain this transaction targets. It prevents signed transactions from being used on another chain by an attacker | +| `account_number` | [uint64](#uint64) | | account_number is the account number of the signing account in state | +| `sign_doc_sha256_hash` | [bytes](#bytes) | | sign_doc_sha256_hash is the SHA-256 hash of SignDoc. It is included here to reduce the malleability attack surface of SIGN_MODE_DIRECT_JSON vs SIGN_MODE_DIRECT to zero. Basically this means that any discrepancy between protobuf bytes over the wire and protobuf bytes that are signed cannot be exploited. This information is obviously redundant with information already in SignDocJSON, but is included as a security check for scenarios where this information may have inadvertently been excluded. We include the hash of SignDoc rather than the full SignDoc bytes to reduce the size of SignDocJSON for scenarios where large payloads could cause problems for hardware wallets. | + + + + + + ### SignerInfo diff --git a/proto/cosmos/tx/signing/v1beta1/signing.proto b/proto/cosmos/tx/signing/v1beta1/signing.proto index 4c1be40594d1..58d33e709d60 100644 --- a/proto/cosmos/tx/signing/v1beta1/signing.proto +++ b/proto/cosmos/tx/signing/v1beta1/signing.proto @@ -9,20 +9,25 @@ option go_package = "github.com/cosmos/cosmos-sdk/types/tx/signing"; // SignMode represents a signing mode with its own security guarantees. enum SignMode { // SIGN_MODE_UNSPECIFIED specifies an unknown signing mode and will be - // rejected + // rejected. SIGN_MODE_UNSPECIFIED = 0; // SIGN_MODE_DIRECT specifies a signing mode which uses SignDoc and is - // verified with raw bytes from Tx + // verified with raw bytes from Tx. SIGN_MODE_DIRECT = 1; // SIGN_MODE_TEXTUAL is a future signing mode that will verify some // human-readable textual representation on top of the binary representation - // from SIGN_MODE_DIRECT + // from SIGN_MODE_DIRECT. It is currently not supported. SIGN_MODE_TEXTUAL = 2; + // SIGN_MODE_DIRECT_JSON specifies a signing mode which uses SignDocJSON. It + // is verified using a canonical JSON representation of the bytes used in + // SIGN_MODE_DIRECT. + SIGN_MODE_DIRECT_JSON = 3; + // SIGN_MODE_LEGACY_AMINO_JSON is a backwards compatibility mode which uses - // Amino JSON and will be removed in the future + // Amino JSON and will be removed in the future. SIGN_MODE_LEGACY_AMINO_JSON = 127; } diff --git a/proto/cosmos/tx/v1beta1/tx.proto b/proto/cosmos/tx/v1beta1/tx.proto index 8f8564d39efe..7f52f940d18a 100644 --- a/proto/cosmos/tx/v1beta1/tx.proto +++ b/proto/cosmos/tx/v1beta1/tx.proto @@ -63,9 +63,11 @@ message SignDoc { uint64 account_number = 4; } -// SignDocTextual is the type used for generating sign bytes for SIGN_MODE_TEXTUAL. It is designed to be serialized -// as proto3 JSON following the rules defined here: https://github.com/regen-network/canonical-proto3/blob/master/README.md#json. -message SignDocTextual { +// SignDocJSON is the type used for generating sign bytes for +// SIGN_MODE_DIRECT_JSON. It is designed to be serialized as proto3 JSON +// following the rules defined here: +// https://github.com/regen-network/canonical-proto3/blob/master/README.md#json. +message SignDocJSON { // body is the processable content of the transaction TxBody body = 1; @@ -81,12 +83,16 @@ message SignDocTextual { // account_number is the account number of the signing account in state uint64 account_number = 4; - // sign_doc_sha256_hash is the SHA-256 hash of SignDoc. It is included here to reduce the malleability attack - // surface of SIGN_MODE_TEXTUAL vs SIGN_MODE_DIRECT to zero. Basically this means that any discrepancy between - // protobuf bytes over the wire and protobuf bytes that are signed cannot be exploited. This information is obviously - // redundant with information already in SignDocTextual, but is included as a security check for scenarios where this - // information may have inadvertently been excluded. We include the hash of SignDoc rather than the full SignDoc bytes - // to reduce the size of SignDocTextual for scenarios where large payloads could cause problems for hardware wallets. + // sign_doc_sha256_hash is the SHA-256 hash of SignDoc. It is included here to + // reduce the malleability attack surface of SIGN_MODE_DIRECT_JSON vs + // SIGN_MODE_DIRECT to zero. Basically this means that any discrepancy between + // protobuf bytes over the wire and protobuf bytes that are signed cannot be + // exploited. This information is obviously redundant with information already + // in SignDocJSON, but is included as a security check for scenarios where + // this information may have inadvertently been excluded. We include the hash + // of SignDoc rather than the full SignDoc bytes to reduce the size of + // SignDocJSON for scenarios where large payloads could cause problems for + // hardware wallets. bytes sign_doc_sha256_hash = 5; } diff --git a/types/tx/signing/signing.pb.go b/types/tx/signing/signing.pb.go index f06a270c7cbd..10d8e96cfa32 100644 --- a/types/tx/signing/signing.pb.go +++ b/types/tx/signing/signing.pb.go @@ -29,17 +29,21 @@ type SignMode int32 const ( // SIGN_MODE_UNSPECIFIED specifies an unknown signing mode and will be - // rejected + // rejected. SignMode_SIGN_MODE_UNSPECIFIED SignMode = 0 // SIGN_MODE_DIRECT specifies a signing mode which uses SignDoc and is - // verified with raw bytes from Tx + // verified with raw bytes from Tx. SignMode_SIGN_MODE_DIRECT SignMode = 1 // SIGN_MODE_TEXTUAL is a future signing mode that will verify some // human-readable textual representation on top of the binary representation - // from SIGN_MODE_DIRECT + // from SIGN_MODE_DIRECT. It is currently not supported. SignMode_SIGN_MODE_TEXTUAL SignMode = 2 + // SIGN_MODE_DIRECT_JSON specifies a signing mode which uses SignDocJSON. It + // is verified using a canonical JSON representation of the bytes used in + // SIGN_MODE_DIRECT. + SignMode_SIGN_MODE_DIRECT_JSON SignMode = 3 // SIGN_MODE_LEGACY_AMINO_JSON is a backwards compatibility mode which uses - // Amino JSON and will be removed in the future + // Amino JSON and will be removed in the future. SignMode_SIGN_MODE_LEGACY_AMINO_JSON SignMode = 127 ) @@ -47,6 +51,7 @@ var SignMode_name = map[int32]string{ 0: "SIGN_MODE_UNSPECIFIED", 1: "SIGN_MODE_DIRECT", 2: "SIGN_MODE_TEXTUAL", + 3: "SIGN_MODE_DIRECT_JSON", 127: "SIGN_MODE_LEGACY_AMINO_JSON", } @@ -54,6 +59,7 @@ var SignMode_value = map[string]int32{ "SIGN_MODE_UNSPECIFIED": 0, "SIGN_MODE_DIRECT": 1, "SIGN_MODE_TEXTUAL": 2, + "SIGN_MODE_DIRECT_JSON": 3, "SIGN_MODE_LEGACY_AMINO_JSON": 127, } @@ -391,41 +397,42 @@ func init() { } var fileDescriptor_9a54958ff3d0b1b9 = []byte{ - // 544 bytes of a gzipped FileDescriptorProto + // 552 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x94, 0xcf, 0x6e, 0xd3, 0x40, - 0x10, 0xc6, 0xed, 0x26, 0x8d, 0xd2, 0x29, 0x42, 0x61, 0x49, 0xa5, 0xc4, 0x20, 0x13, 0x95, 0x03, + 0x10, 0xc6, 0xed, 0x26, 0xad, 0xd2, 0x29, 0x42, 0x61, 0x49, 0xa5, 0xc4, 0x20, 0x13, 0x95, 0x03, 0x11, 0x52, 0xd6, 0x6a, 0x72, 0x40, 0x70, 0xcb, 0x1f, 0x93, 0x86, 0x36, 0x09, 0xd8, 0xa9, 0x04, - 0x5c, 0x2c, 0xdb, 0xd9, 0x1a, 0xab, 0xb1, 0xd7, 0x78, 0xd7, 0xa8, 0x3e, 0xf1, 0x0a, 0xbc, 0x06, - 0xcf, 0xc1, 0x85, 0x63, 0x8f, 0x1c, 0x51, 0xf2, 0x0c, 0xdc, 0x51, 0xec, 0x38, 0x09, 0x52, 0x11, - 0x22, 0x27, 0x6b, 0x66, 0xbe, 0xfd, 0xcd, 0xb7, 0x9a, 0x59, 0xc3, 0x13, 0x9b, 0x32, 0x8f, 0x32, - 0x85, 0x5f, 0x2b, 0xcc, 0x75, 0x7c, 0xd7, 0x77, 0x94, 0x4f, 0x27, 0x16, 0xe1, 0xe6, 0x49, 0x16, - 0xe3, 0x20, 0xa4, 0x9c, 0xa2, 0x6a, 0x2a, 0xc4, 0xfc, 0x1a, 0x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, 0xfe, 0x09, 0x00, 0x00, 0xff, 0xff, + 0x93, 0x71, 0x12, 0x94, 0x50, 0x04, 0x00, 0x00, } func (m *SignatureDescriptors) Marshal() (dAtA []byte, err error) { diff --git a/types/tx/tx.pb.go b/types/tx/tx.pb.go index a552c7a083e1..4104a0122bf8 100644 --- a/types/tx/tx.pb.go +++ b/types/tx/tx.pb.go @@ -244,6 +244,103 @@ func (m *SignDoc) GetAccountNumber() uint64 { return 0 } +// SignDocJSON is the type used for generating sign bytes for +// SIGN_MODE_DIRECT_JSON. It is designed to be serialized as proto3 JSON +// following the rules defined here: +// https://github.com/regen-network/canonical-proto3/blob/master/README.md#json. +type SignDocJSON struct { + // body is the processable content of the transaction + Body *TxBody `protobuf:"bytes,1,opt,name=body,proto3" json:"body,omitempty"` + // auth_info is the authorization related content of the transaction, + // specifically signers, signer modes and fee + AuthInfo *AuthInfo `protobuf:"bytes,2,opt,name=auth_info,json=authInfo,proto3" json:"auth_info,omitempty"` + // chain_id is the identifier of the chain this transaction targets. + // It prevents signed transactions from being used on another chain by an + // attacker + ChainId string `protobuf:"bytes,3,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` + // account_number is the account number of the signing account in state + AccountNumber uint64 `protobuf:"varint,4,opt,name=account_number,json=accountNumber,proto3" json:"account_number,omitempty"` + // sign_doc_sha256_hash is the SHA-256 hash of SignDoc. It is included here to + // reduce the malleability attack surface of SIGN_MODE_DIRECT_JSON vs + // SIGN_MODE_DIRECT to zero. Basically this means that any discrepancy between + // protobuf bytes over the wire and protobuf bytes that are signed cannot be + // exploited. This information is obviously redundant with information already + // in SignDocJSON, but is included as a security check for scenarios where + // this information may have inadvertently been excluded. We include the hash + // of SignDoc rather than the full SignDoc bytes to reduce the size of + // SignDocJSON for scenarios where large payloads could cause problems for + // hardware wallets. + SignDocSha256Hash []byte `protobuf:"bytes,5,opt,name=sign_doc_sha256_hash,json=signDocSha256Hash,proto3" json:"sign_doc_sha256_hash,omitempty"` +} + +func (m *SignDocJSON) Reset() { *m = SignDocJSON{} } +func (m *SignDocJSON) String() string { return proto.CompactTextString(m) } +func (*SignDocJSON) ProtoMessage() {} +func (*SignDocJSON) Descriptor() ([]byte, []int) { + return fileDescriptor_96d1575ffde80842, []int{3} +} +func (m *SignDocJSON) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SignDocJSON) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SignDocJSON.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *SignDocJSON) XXX_Merge(src proto.Message) { + xxx_messageInfo_SignDocJSON.Merge(m, src) +} +func (m *SignDocJSON) XXX_Size() int { + return m.Size() +} +func (m *SignDocJSON) XXX_DiscardUnknown() { + xxx_messageInfo_SignDocJSON.DiscardUnknown(m) +} + +var xxx_messageInfo_SignDocJSON proto.InternalMessageInfo + +func (m *SignDocJSON) GetBody() *TxBody { + if m != nil { + return m.Body + } + return nil +} + +func (m *SignDocJSON) GetAuthInfo() *AuthInfo { + if m != nil { + return m.AuthInfo + } + return nil +} + +func (m *SignDocJSON) GetChainId() string { + if m != nil { + return m.ChainId + } + return "" +} + +func (m *SignDocJSON) GetAccountNumber() uint64 { + if m != nil { + return m.AccountNumber + } + return 0 +} + +func (m *SignDocJSON) GetSignDocSha256Hash() []byte { + if m != nil { + return m.SignDocSha256Hash + } + return nil +} + // TxBody is the body of a transaction that all signers sign over. type TxBody struct { // messages is a list of messages to be executed. The required signers of @@ -273,7 +370,7 @@ func (m *TxBody) Reset() { *m = TxBody{} } func (m *TxBody) String() string { return proto.CompactTextString(m) } func (*TxBody) ProtoMessage() {} func (*TxBody) Descriptor() ([]byte, []int) { - return fileDescriptor_96d1575ffde80842, []int{3} + return fileDescriptor_96d1575ffde80842, []int{4} } func (m *TxBody) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -356,7 +453,7 @@ func (m *AuthInfo) Reset() { *m = AuthInfo{} } func (m *AuthInfo) String() string { return proto.CompactTextString(m) } func (*AuthInfo) ProtoMessage() {} func (*AuthInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_96d1575ffde80842, []int{4} + return fileDescriptor_96d1575ffde80842, []int{5} } func (m *AuthInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -419,7 +516,7 @@ func (m *SignerInfo) Reset() { *m = SignerInfo{} } func (m *SignerInfo) String() string { return proto.CompactTextString(m) } func (*SignerInfo) ProtoMessage() {} func (*SignerInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_96d1575ffde80842, []int{5} + return fileDescriptor_96d1575ffde80842, []int{6} } func (m *SignerInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -484,7 +581,7 @@ func (m *ModeInfo) Reset() { *m = ModeInfo{} } func (m *ModeInfo) String() string { return proto.CompactTextString(m) } func (*ModeInfo) ProtoMessage() {} func (*ModeInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_96d1575ffde80842, []int{6} + return fileDescriptor_96d1575ffde80842, []int{7} } func (m *ModeInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -570,7 +667,7 @@ func (m *ModeInfo_Single) Reset() { *m = ModeInfo_Single{} } func (m *ModeInfo_Single) String() string { return proto.CompactTextString(m) } func (*ModeInfo_Single) ProtoMessage() {} func (*ModeInfo_Single) Descriptor() ([]byte, []int) { - return fileDescriptor_96d1575ffde80842, []int{6, 0} + return fileDescriptor_96d1575ffde80842, []int{7, 0} } func (m *ModeInfo_Single) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -619,7 +716,7 @@ func (m *ModeInfo_Multi) Reset() { *m = ModeInfo_Multi{} } func (m *ModeInfo_Multi) String() string { return proto.CompactTextString(m) } func (*ModeInfo_Multi) ProtoMessage() {} func (*ModeInfo_Multi) Descriptor() ([]byte, []int) { - return fileDescriptor_96d1575ffde80842, []int{6, 1} + return fileDescriptor_96d1575ffde80842, []int{7, 1} } func (m *ModeInfo_Multi) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -685,7 +782,7 @@ func (m *Fee) Reset() { *m = Fee{} } func (m *Fee) String() string { return proto.CompactTextString(m) } func (*Fee) ProtoMessage() {} func (*Fee) Descriptor() ([]byte, []int) { - return fileDescriptor_96d1575ffde80842, []int{7} + return fileDescriptor_96d1575ffde80842, []int{8} } func (m *Fee) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -746,6 +843,7 @@ func init() { proto.RegisterType((*Tx)(nil), "cosmos.tx.v1beta1.Tx") proto.RegisterType((*TxRaw)(nil), "cosmos.tx.v1beta1.TxRaw") proto.RegisterType((*SignDoc)(nil), "cosmos.tx.v1beta1.SignDoc") + proto.RegisterType((*SignDocJSON)(nil), "cosmos.tx.v1beta1.SignDocJSON") proto.RegisterType((*TxBody)(nil), "cosmos.tx.v1beta1.TxBody") proto.RegisterType((*AuthInfo)(nil), "cosmos.tx.v1beta1.AuthInfo") proto.RegisterType((*SignerInfo)(nil), "cosmos.tx.v1beta1.SignerInfo") @@ -758,60 +856,63 @@ func init() { func init() { proto.RegisterFile("cosmos/tx/v1beta1/tx.proto", fileDescriptor_96d1575ffde80842) } var fileDescriptor_96d1575ffde80842 = []byte{ - // 843 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0xdd, 0x6e, 0xdc, 0x44, - 0x14, 0x5e, 0xef, 0x5f, 0xd6, 0x27, 0x49, 0x4b, 0x47, 0x11, 0xda, 0x6c, 0x54, 0x37, 0x18, 0x15, - 0xf6, 0x26, 0x76, 0x9b, 0x5e, 0xf0, 0x23, 0x24, 0xc8, 0x16, 0xaa, 0x54, 0xa5, 0x20, 0x4d, 0x72, - 0xd5, 0x1b, 0x6b, 0xec, 0x9d, 0x78, 0x47, 0x5d, 0xcf, 0x2c, 0x9e, 0x71, 0xb1, 0x1f, 0x02, 0xa9, - 0x42, 0x42, 0xbc, 0x03, 0x2f, 0xc0, 0x2b, 0xf4, 0xb2, 0x97, 0x5c, 0x41, 0x95, 0x3c, 0x08, 0x68, - 0xc6, 0x63, 0x27, 0x82, 0x55, 0x72, 0xc3, 0x95, 0xe7, 0x9c, 0xf9, 0xce, 0x37, 0x9f, 0xcf, 0x1f, - 0x4c, 0x12, 0x21, 0x33, 0x21, 0x43, 0x55, 0x86, 0xaf, 0x1e, 0xc6, 0x54, 0x91, 0x87, 0xa1, 0x2a, - 0x83, 0x55, 0x2e, 0x94, 0x40, 0x77, 0xea, 0xbb, 0x40, 0x95, 0x81, 0xbd, 0x9b, 0xec, 0xa4, 0x22, - 0x15, 0xe6, 0x36, 0xd4, 0xa7, 0x1a, 0x38, 0x39, 0xb0, 0x24, 0x49, 0x5e, 0xad, 0x94, 0x08, 0xb3, - 0x62, 0xa9, 0x98, 0x64, 0x69, 0xcb, 0xd8, 0x38, 0x2c, 0xdc, 0xb3, 0xf0, 0x98, 0x48, 0xda, 0x62, - 0x12, 0xc1, 0xb8, 0xbd, 0xff, 0xf8, 0x52, 0x93, 0x64, 0x29, 0x67, 0xfc, 0x92, 0xc9, 0xda, 0x16, - 0xb8, 0x9b, 0x0a, 0x91, 0x2e, 0x69, 0x68, 0xac, 0xb8, 0x38, 0x0b, 0x09, 0xaf, 0xea, 0x2b, 0xff, - 0x27, 0x07, 0xba, 0xa7, 0x25, 0x3a, 0x80, 0x7e, 0x2c, 0xe6, 0xd5, 0xd8, 0xd9, 0x77, 0xa6, 0x9b, - 0x87, 0xbb, 0xc1, 0x7f, 0xfe, 0x28, 0x38, 0x2d, 0x67, 0x62, 0x5e, 0x61, 0x03, 0x43, 0x9f, 0x82, - 0x4b, 0x0a, 0xb5, 0x88, 0x18, 0x3f, 0x13, 0xe3, 0xae, 0x89, 0xd9, 0x5b, 0x13, 0x73, 0x54, 0xa8, - 0xc5, 0x53, 0x7e, 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0xb8, 0xb2, 0xcb, 0xc4, 0xc5, 0x8d, 0x39, 0xfb, 0xf2, 0xcd, 0xb9, 0xe7, 0xbc, 0x3d, - 0xf7, 0x9c, 0x77, 0xe7, 0x9e, 0xf3, 0xfa, 0xc2, 0xeb, 0xbc, 0xbd, 0xf0, 0x3a, 0x7f, 0x5c, 0x78, - 0x9d, 0x17, 0xf7, 0x6f, 0x16, 0x16, 0xaa, 0x32, 0x1e, 0x9a, 0x66, 0x7e, 0xf4, 0x4f, 0x00, 0x00, - 0x00, 0xff, 0xff, 0xd4, 0xb7, 0x75, 0x7d, 0xfd, 0x06, 0x00, 0x00, + // 895 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x55, 0xcd, 0x6e, 0xdb, 0x46, + 0x10, 0x16, 0xf5, 0x67, 0x69, 0x6c, 0x27, 0xf5, 0xc2, 0x28, 0x64, 0x19, 0x61, 0x5c, 0x16, 0x69, + 0x75, 0x31, 0x99, 0x38, 0xe8, 0x2f, 0x0a, 0xb4, 0x56, 0xda, 0xc0, 0x69, 0x9a, 0x04, 0x58, 0xf9, + 0x94, 0x0b, 0xb1, 0xa4, 0xd6, 0xe4, 0x22, 0xe2, 0xae, 0xca, 0x5d, 0xa6, 0xd2, 0x43, 0x14, 0x08, + 0x0a, 0x14, 0x7d, 0x87, 0xbe, 0x40, 0x5f, 0x21, 0xc7, 0x1c, 0x7b, 0x6a, 0x0d, 0xfb, 0xd4, 0xa7, + 0x68, 0xb1, 0xcb, 0x25, 0x6d, 0xb4, 0x82, 0x7d, 0x68, 0xd1, 0x93, 0x76, 0x66, 0xbe, 0xf9, 0xf6, + 0xdb, 0x99, 0xd1, 0x10, 0x86, 0xb1, 0x90, 0x99, 0x90, 0x81, 0x5a, 0x04, 0x2f, 0xef, 0x45, 0x54, + 0x91, 0x7b, 0x81, 0x5a, 0xf8, 0xf3, 0x5c, 0x28, 0x81, 0xb6, 0xca, 0x98, 0xaf, 0x16, 0xbe, 0x8d, + 0x0d, 0xb7, 0x13, 0x91, 0x08, 0x13, 0x0d, 0xf4, 0xa9, 0x04, 0x0e, 0xf7, 0x2d, 0x49, 0x9c, 0x2f, + 0xe7, 0x4a, 0x04, 0x59, 0x31, 0x53, 0x4c, 0xb2, 0xa4, 0x66, 0xac, 0x1c, 0x16, 0xee, 0x5a, 0x78, + 0x44, 0x24, 0xad, 0x31, 0xb1, 0x60, 0xdc, 0xc6, 0xdf, 0xbf, 0xd0, 0x24, 0x59, 0xc2, 0x19, 0xbf, + 0x60, 0xb2, 0xb6, 0x05, 0xee, 0x24, 0x42, 0x24, 0x33, 0x1a, 0x18, 0x2b, 0x2a, 0x4e, 0x02, 0xc2, + 0x97, 0x65, 0xc8, 0xfb, 0xde, 0x81, 0xe6, 0xf1, 0x02, 0xed, 0x43, 0x3b, 0x12, 0xd3, 0xe5, 0xc0, + 0xd9, 0x73, 0x46, 0xeb, 0x07, 0x3b, 0xfe, 0x3f, 0x5e, 0xe4, 0x1f, 0x2f, 0xc6, 0x62, 0xba, 0xc4, + 0x06, 0x86, 0x3e, 0x86, 0x3e, 0x29, 0x54, 0x1a, 0x32, 0x7e, 0x22, 0x06, 0x4d, 0x93, 0xb3, 0xbb, + 0x22, 0xe7, 0xb0, 0x50, 0xe9, 0x23, 0x7e, 0x22, 0x70, 0x8f, 0xd8, 0x13, 0x72, 0x01, 0xb4, 0x36, + 0xa2, 0x8a, 0x9c, 0xca, 0x41, 0x6b, 0xaf, 0x35, 0xda, 0xc0, 0x97, 0x3c, 0x1e, 0x87, 0xce, 0xf1, + 0x02, 0x93, 0xef, 0xd0, 0x2d, 0x00, 0x7d, 0x55, 0x18, 0x2d, 0x15, 0x95, 0x46, 0xd7, 0x06, 0xee, + 0x6b, 0xcf, 0x58, 0x3b, 0xd0, 0x7b, 0x70, 0xb3, 0x56, 0x60, 0x31, 0x4d, 0x83, 0xd9, 0xac, 0xae, + 0x2a, 0x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b, 0x33, 0xd7, 0x39, 0x3d, 0x73, 0x9d, 0x57, 0xe7, 0x6e, 0xe3, 0xcd, 0xb9, + 0xdb, 0xf8, 0xf5, 0xdc, 0x6d, 0x3c, 0xbf, 0x73, 0xbd, 0xb0, 0x40, 0x2d, 0xa2, 0xae, 0x19, 0xe6, + 0xfb, 0x7f, 0x05, 0x00, 0x00, 0xff, 0xff, 0x34, 0xab, 0x74, 0x31, 0xe9, 0x07, 0x00, 0x00, } func (m *Tx) Marshal() (dAtA []byte, err error) { @@ -965,6 +1066,72 @@ func (m *SignDoc) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *SignDocJSON) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *SignDocJSON) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SignDocJSON) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.SignDocSha256Hash) > 0 { + i -= len(m.SignDocSha256Hash) + copy(dAtA[i:], m.SignDocSha256Hash) + i = encodeVarintTx(dAtA, i, uint64(len(m.SignDocSha256Hash))) + i-- + dAtA[i] = 0x2a + } + if m.AccountNumber != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.AccountNumber)) + i-- + dAtA[i] = 0x20 + } + if len(m.ChainId) > 0 { + i -= len(m.ChainId) + copy(dAtA[i:], m.ChainId) + i = encodeVarintTx(dAtA, i, uint64(len(m.ChainId))) + i-- + dAtA[i] = 0x1a + } + if m.AuthInfo != nil { + { + size, err := m.AuthInfo.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if m.Body != nil { + { + size, err := m.Body.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *TxBody) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1435,6 +1602,34 @@ func (m *SignDoc) Size() (n int) { return n } +func (m *SignDocJSON) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Body != nil { + l = m.Body.Size() + n += 1 + l + sovTx(uint64(l)) + } + if m.AuthInfo != nil { + l = m.AuthInfo.Size() + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.ChainId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.AccountNumber != 0 { + n += 1 + sovTx(uint64(m.AccountNumber)) + } + l = len(m.SignDocSha256Hash) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + func (m *TxBody) Size() (n int) { if m == nil { return 0 @@ -2080,6 +2275,213 @@ func (m *SignDoc) Unmarshal(dAtA []byte) error { } return nil } +func (m *SignDocJSON) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: SignDocJSON: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SignDocJSON: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Body", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Body == nil { + m.Body = &TxBody{} + } + if err := m.Body.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AuthInfo", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.AuthInfo == nil { + m.AuthInfo = &AuthInfo{} + } + if err := m.AuthInfo.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChainId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChainId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field AccountNumber", wireType) + } + m.AccountNumber = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.AccountNumber |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SignDocSha256Hash", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SignDocSha256Hash = append(m.SignDocSha256Hash[:0], dAtA[iNdEx:postIndex]...) + if m.SignDocSha256Hash == nil { + m.SignDocSha256Hash = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *TxBody) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/auth/tx/direct_test.go b/x/auth/tx/direct_test.go index bef1e81ed974..fd1e343229b6 100644 --- a/x/auth/tx/direct_test.go +++ b/x/auth/tx/direct_test.go @@ -131,6 +131,7 @@ func TestDirectModeHandler(t *testing.T) { func TestDirectModeHandler_nonDIRECT_MODE(t *testing.T) { invalidModes := []signingtypes.SignMode{ + signingtypes.SignMode_SIGN_MODE_DIRECT_JSON, signingtypes.SignMode_SIGN_MODE_TEXTUAL, signingtypes.SignMode_SIGN_MODE_LEGACY_AMINO_JSON, signingtypes.SignMode_SIGN_MODE_UNSPECIFIED,