Skip to content

Commit eefbf7c

Browse files
committed
Gossip Crypto-related API update
This commit: 1) Helps connect between the existing fabric message verification API to the gossip implementation by using the same signature methods as the crypto/crypto.go Peer interface 2) Adds a PKI_id to the discovery infrasturcture and to the communication layer in order for peers to assert: 2)a) Single connection to each peer 2)b) Identity of connecting peer Change-Id: Ie18ccbb6135d65b1c508f3e0a3d1dc911df0bd7b Signed-off-by: Yacov Manevich <[email protected]>
1 parent 6167142 commit eefbf7c

File tree

5 files changed

+178
-53
lines changed

5 files changed

+178
-53
lines changed

gossip/api/api.go

+8-29
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,6 @@ limitations under the License.
1616

1717
package api
1818

19-
import (
20-
"github.com/hyperledger/fabric/gossip/discovery"
21-
"google.golang.org/grpc"
22-
)
23-
24-
type GossipEmitterFactory interface {
25-
NewGossipEmitter(id string, discSvc discovery.DiscoveryService) GossipService
26-
}
2719

2820
// GossipService is used to publish new blocks to the gossip network
2921
type GossipService interface {
@@ -43,12 +35,6 @@ type Payload struct {
4335
SeqNum uint64 // The message sequence number
4436
}
4537

46-
type GossipMemberFactory interface {
47-
NewGossipMember(discovery.DiscoveryService, ReplicationProvider, MessageCryptoService, MessagePolicyVerifier, *grpc.Server) GossipMember
48-
49-
NewGossipMemberWithRPCServer(discovery.DiscoveryService, ReplicationProvider, MessageCryptoService, MessagePolicyVerifier, BindAddress) (GossipMember, error)
50-
}
51-
5238
// GossipMember is used to obtain new blocks from the gossip network
5339
type GossipMember interface {
5440
// RegisterCallback registers a callback that is invoked on messages
@@ -73,21 +59,14 @@ type ReplicationProvider interface {
7359
type MessageCryptoService interface {
7460
// Verify returns nil whether the message and its identifier are authentic,
7561
// otherwise returns an error
76-
Verify(seqNum uint64, sender string, payload Payload) error
77-
78-
// Sign signs the payload
79-
Sign(sender string, Payload Payload) Payload
62+
VerifyBlock(seqNum uint64, pkiId []byte, payload Payload) error
8063

81-
// SignBlob signs a blob
82-
SignBlob([]byte) []byte
83-
84-
// VerifyBlob verifies a blob, returns error on failure
85-
// and nil if the blob is correctly signed
86-
VerifyBlob(sender string, blob []byte) error
87-
}
64+
// Sign signs msg with this peer's signing key and outputs
65+
// the signature if no error occurred.
66+
Sign(msg []byte) ([]byte, error)
8867

89-
// MessagePolicyVerifier verifies whether the message conforms to all required policies,
90-
// and can be safely delivered to the user.
91-
type MessagePolicyVerifier interface {
92-
Verify(seqNum uint64, sender string, payload Payload) error
68+
// Verify checks that signature is a valid signature of message under vkID's verification key.
69+
// If the verification succeeded, Verify returns nil meaning no error occurred.
70+
// If vkID is nil, then the signature is verified against this validator's verification key.
71+
Verify(vkID, signature, message []byte) error
9372
}

gossip/comm/comm.go

+18
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ type CommModule interface {
2525
// Send sends a message to endpoints
2626
Send(msg *proto.GossipMessage, endpoints ...string)
2727

28+
// SetPKIid asserts that pkiId is the PKI_id of endpoint
29+
SetPKIid(endpoint, pkiId []byte)
30+
2831
// Probe probes a remote node and returns nil if its responsive
2932
Probe(endpoint string) error
3033

@@ -42,6 +45,21 @@ type CommModule interface {
4245
Stop()
4346
}
4447

48+
type SecurityProvider interface {
49+
50+
// isEnabled returns whether this
51+
isEnabled() bool
52+
53+
// Sign signs msg with this peers signing key and outputs
54+
// the signature if no error occurred.
55+
Sign(msg []byte) ([]byte, error)
56+
57+
// Verify checks that signature if a valid signature of message under vkID's verification key.
58+
// If the verification succeeded, Verify returns nil meaning no error occurred.
59+
// If vkID is nil, then the signature is verified against this validator's verification key.
60+
Verify(vkID, signature, message []byte) error
61+
}
62+
4563

4664
type MessageAcceptor func(*proto.GossipMessage) bool
4765

gossip/discovery/discovery.go

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ type NetworkMember struct {
5757
Id string
5858
Endpoint string
5959
Metadata []byte
60+
PKIid []byte
6061
}
6162

6263
type DiscoveryService interface {

gossip/proto/message.pb.go

+126-20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)