github.com/ZihuaZhang/fabric-protos-go@v1.0.7/common/common.proto (about) 1 // Copyright the Hyperledger Fabric contributors. All rights reserved. 2 // 3 // SPDX-License-Identifier: Apache-2.0 4 5 syntax = "proto3"; 6 7 option go_package = "github.com/ZihuaZhang/fabric-protos-go/common"; 8 9 package common; 10 11 import "google/protobuf/timestamp.proto"; 12 13 // These status codes are intended to resemble selected HTTP status codes 14 enum Status { 15 UNKNOWN = 0; 16 SUCCESS = 200; 17 BAD_REQUEST = 400; 18 FORBIDDEN = 403; 19 NOT_FOUND = 404; 20 REQUEST_ENTITY_TOO_LARGE = 413; 21 INTERNAL_SERVER_ERROR = 500; 22 NOT_IMPLEMENTED = 501; 23 SERVICE_UNAVAILABLE = 503; 24 } 25 26 enum HeaderType { 27 reserved 7, 8, 9; 28 reserved "PEER_RESOURCE_UPDATE", "PEER_ADMIN_OPERATION", "TOKEN_TRANSACTION"; 29 30 MESSAGE = 0; // Used for messages which are signed but opaque 31 CONFIG = 1; // Used for messages which express the channel config 32 CONFIG_UPDATE = 2; // Used for transactions which update the channel config 33 ENDORSER_TRANSACTION = 3; // Used by the SDK to submit endorser based transactions 34 ORDERER_TRANSACTION = 4 [deprecated = true]; // Was used internally by the orderer for management, no longer used since system channel was removed 35 DELIVER_SEEK_INFO = 5; // Used as the type for Envelope messages submitted to instruct the Deliver API to seek 36 CHAINCODE_PACKAGE = 6; // Used for packaging chaincode artifacts for install 37 } 38 39 // This enum enlists indexes of the block metadata array 40 enum BlockMetadataIndex { 41 SIGNATURES = 0; // Block metadata array position for block signatures 42 LAST_CONFIG = 1 [deprecated=true]; // Block metadata array position to store last configuration block sequence number 43 TRANSACTIONS_FILTER = 2; // Block metadata array position to store serialized bit array filter of invalid transactions 44 ORDERER = 3 [deprecated=true]; // Block metadata array position to store operational metadata for orderers 45 COMMIT_HASH = 4; /* Block metadata array position to store the hash of TRANSACTIONS_FILTER, State Updates, 46 and the COMMIT_HASH of the previous block */ 47 } 48 49 // LastConfig is the encoded value for the Metadata message which is encoded in the LAST_CONFIGURATION block metadata index 50 message LastConfig { 51 uint64 index = 1; 52 } 53 54 // Metadata is a common structure to be used to encode block metadata 55 message Metadata { 56 bytes value = 1; 57 repeated MetadataSignature signatures = 2; 58 } 59 60 message MetadataSignature { 61 bytes signature_header = 1; // An encoded SignatureHeader 62 bytes signature = 2; // The signature over the concatenation of the Metadata value bytes, signatureHeader, and block header 63 bytes identifier_header = 3; // An encoded IdentifierHeader. If the signature header is empty, this is used to identify the creator by id 64 } 65 66 // IdentifierHeader is used as an alternative to a SignatureHeader when the creator can be referenced by id 67 message IdentifierHeader { 68 uint32 identifier = 1; // A unique identifier that represents the creator of the message 69 bytes nonce = 2; // Arbitrary number that may only be used once. Can be used to detect replay attacks. 70 } 71 72 message Header { 73 bytes channel_header = 1; 74 bytes signature_header = 2; 75 } 76 77 // Header is a generic replay prevention and identity message to include in a signed payload 78 message ChannelHeader { 79 int32 type = 1; // Header types 0-10000 are reserved and defined by HeaderType 80 81 // Version indicates message protocol version 82 int32 version = 2; 83 84 // Timestamp is the local time when the message was created 85 // by the sender 86 google.protobuf.Timestamp timestamp = 3; 87 88 // Identifier of the channel this message is bound for 89 string channel_id = 4; 90 91 // An unique identifier that is used end-to-end. 92 // - set by higher layers such as end user or SDK 93 // - passed to the endorser (which will check for uniqueness) 94 // - as the header is passed along unchanged, it will be 95 // be retrieved by the committer (uniqueness check here as well) 96 // - to be stored in the ledger 97 string tx_id = 5; 98 99 // The epoch in which this header was generated, where epoch is defined based on block height 100 // Epoch in which the response has been generated. This field identifies a 101 // logical window of time. A proposal response is accepted by a peer only if 102 // two conditions hold: 103 // 1. the epoch specified in the message is the current epoch 104 // 2. this message has been only seen once during this epoch (i.e. it hasn't 105 // been replayed) 106 uint64 epoch = 6; 107 108 // Extension that may be attached based on the header type 109 bytes extension = 7; 110 111 // If mutual TLS is employed, this represents 112 // the hash of the client's TLS certificate 113 bytes tls_cert_hash = 8; 114 } 115 116 message SignatureHeader { 117 // Creator of the message, a marshaled msp.SerializedIdentity 118 bytes creator = 1; 119 120 // Arbitrary number that may only be used once. Can be used to detect replay attacks. 121 bytes nonce = 2; 122 } 123 124 // Payload is the message contents (and header to allow for signing) 125 message Payload { 126 127 // Header is included to provide identity and prevent replay 128 Header header = 1; 129 130 // Data, the encoding of which is defined by the type in the header 131 bytes data = 2; 132 } 133 134 // Envelope wraps a Payload with a signature so that the message may be authenticated 135 message Envelope { 136 // A marshaled Payload 137 bytes payload = 1; 138 139 // A signature by the creator specified in the Payload header 140 bytes signature = 2; 141 142 bool redactable = 3; 143 144 bytes redactMessage = 4; 145 } 146 147 message RedactMsg { 148 bytes pk=1; 149 bytes msp=2; 150 bytes fameCipher=3; 151 } 152 153 // This is finalized block structure to be shared among the orderer and peer 154 // Note that the BlockHeader chains to the previous BlockHeader, and the BlockData hash is embedded 155 // in the BlockHeader. This makes it natural and obvious that the Data is included in the hash, but 156 // the Metadata is not. 157 message Block { 158 BlockHeader header = 1; 159 BlockData data = 2; 160 BlockMetadata metadata = 3; 161 } 162 163 // BlockHeader is the element of the block which forms the block chain 164 // The block header is hashed using the configured chain hashing algorithm 165 // over the ASN.1 encoding of the BlockHeader 166 message BlockHeader { 167 uint64 number = 1; // The position in the blockchain 168 bytes previous_hash = 2; // The hash of the previous block header 169 bytes data_hash = 3; // The hash of the BlockData, by MerkleTree 170 } 171 172 message BlockData { 173 repeated bytes data = 1; 174 } 175 176 message BlockMetadata { 177 repeated bytes metadata = 1; 178 } 179 180 // OrdererBlockMetadata defines metadata that is set by the ordering service. 181 message OrdererBlockMetadata { 182 LastConfig last_config = 1; 183 bytes consenter_metadata = 2; 184 }