|
| 1 | +/* |
| 2 | +Copyright IBM Corp. 2016 All Rights Reserved. |
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +Unless required by applicable law or agreed to in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and |
| 14 | +limitations under the License. |
| 15 | +*/ |
| 16 | + |
| 17 | +package api |
| 18 | + |
| 19 | +import "github.com/hyperledger/fabric/gossip/common" |
| 20 | + |
| 21 | +// MessageCryptoService is the contract between the gossip component and the |
| 22 | +// peer's cryptographic layer and is used by the gossip component to verify, |
| 23 | +// and authenticate remote peers and data they send, as well as to verify |
| 24 | +// received blocks from the ordering service. |
| 25 | +type MessageCryptoService interface { |
| 26 | + |
| 27 | + // GetPKIidOfCert returns the PKI-ID of a peer's identity |
| 28 | + GetPKIidOfCert(peerIdentity PeerIdentityType) common.PKIidType |
| 29 | + |
| 30 | + // VerifyBlock returns nil if the block is properly signed, |
| 31 | + // else returns error |
| 32 | + VerifyBlock(signedBlock SignedBlock) error |
| 33 | + |
| 34 | + // Sign signs msg with this peer's signing key and outputs |
| 35 | + // the signature if no error occurred. |
| 36 | + Sign(msg []byte) ([]byte, error) |
| 37 | + |
| 38 | + // Verify checks that signature is a valid signature of message under a peer's verification key. |
| 39 | + // If the verification succeeded, Verify returns nil meaning no error occurred. |
| 40 | + // If peerCert is nil, then the signature is verified against this peer's verification key. |
| 41 | + Verify(peerIdentity PeerIdentityType, signature, message []byte) error |
| 42 | +} |
| 43 | + |
| 44 | +// PeerIdentityType is the peer's certificate |
| 45 | +type PeerIdentityType []byte |
| 46 | + |
| 47 | +// SignedBlock represents a fabric block that is signed according |
| 48 | +// to the latest block verification policy known to the peer |
| 49 | +type SignedBlock interface { |
| 50 | +} |
0 commit comments