Skip to content

Commit eb57157

Browse files
committed
[FAB-1394] gossip MessageCryptoService-Add Channel
This commit adds a method VerifyByChannel that is channel-contexted and does the same thing as Verify, just that it causes the MSP layer to use a specific MSP manager. Change-Id: I6b7401935f7751b434be893769810a3ba4fad76f Signed-off-by: Yacov Manevich <[email protected]>
1 parent cb39a14 commit eb57157

File tree

7 files changed

+43
-1
lines changed

7 files changed

+43
-1
lines changed

gossip/api/crypto.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,15 @@ type MessageCryptoService interface {
3737

3838
// Verify checks that signature is a valid signature of message under a peer's verification key.
3939
// 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.
40+
// If peerIdentity is nil, then the signature is verified against this peer's verification key.
4141
Verify(peerIdentity PeerIdentityType, signature, message []byte) error
4242

43+
// VerifyByChannel checks that signature is a valid signature of message
44+
// under a peer's verification key, but also in the context of a specific channel.
45+
// If the verification succeeded, Verify returns nil meaning no error occurred.
46+
// If peerIdentity is nil, then the signature is verified against this peer's verification key.
47+
VerifyByChannel(chainID common.ChainID, peerIdentity PeerIdentityType, signature, message []byte) error
48+
4349
// ValidateIdentity validates the identity of a remote peer.
4450
// If the identity is invalid, revoked, expired it returns an error.
4551
// Else, returns nil

gossip/comm/comm_test.go

+6
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@ func (*naiveSecProvider) Verify(peerIdentity api.PeerIdentityType, signature, me
8282
return nil
8383
}
8484

85+
// VerifyByChannel verifies a peer's signature on a message in the context
86+
// of a specific channel
87+
func (*naiveSecProvider) VerifyByChannel(_ common.ChainID, _ api.PeerIdentityType, _, _ []byte) error {
88+
return nil
89+
}
90+
8591
func newCommInstance(port int, sec api.MessageCryptoService) (Comm, error) {
8692
endpoint := fmt.Sprintf("localhost:%d", port)
8793
inst, err := NewCommInstanceWithServer(port, identity.NewIdentityMapper(sec), []byte(endpoint))

gossip/gossip/channel/channel_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ func (cs *cryptoService) GetPKIidOfCert(peerIdentity api.PeerIdentityType) commo
9494
panic("Should not be called in this test")
9595
}
9696

97+
func (cs *cryptoService) VerifyByChannel(_ common.ChainID, _ api.PeerIdentityType, _, _ []byte) error {
98+
panic("Should not be called in this test")
99+
}
100+
97101
func (cs *cryptoService) VerifyBlock(signedBlock api.SignedBlock) error {
98102
args := cs.Called(signedBlock)
99103
if args.Get(0) == nil {

gossip/gossip/gossip_test.go

+6
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ func (*orgCryptoService) Verify(joinChanMsg api.JoinChannelMessage) error {
9494
return nil
9595
}
9696

97+
// VerifyByChannel verifies a peer's signature on a message in the context
98+
// of a specific channel
99+
func (*naiveCryptoService) VerifyByChannel(_ common.ChainID, _ api.PeerIdentityType, _, _ []byte) error {
100+
return nil
101+
}
102+
97103
func (*naiveCryptoService) ValidateIdentity(peerIdentity api.PeerIdentityType) error {
98104
return nil
99105
}

gossip/identity/identity_test.go

+6
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ func (*naiveCryptoService) VerifyBlock(signedBlock api.SignedBlock) error {
4646
return nil
4747
}
4848

49+
// VerifyByChannel verifies a peer's signature on a message in the context
50+
// of a specific channel
51+
func (*naiveCryptoService) VerifyByChannel(_ common.ChainID, _ api.PeerIdentityType, _, _ []byte) error {
52+
return nil
53+
}
54+
4955
// Sign signs msg with this peer's signing key and outputs
5056
// the signature if no error occurred.
5157
func (*naiveCryptoService) Sign(msg []byte) ([]byte, error) {

gossip/integration/integration.go

+6
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@ func (*naiveCryptoService) Sign(msg []byte) ([]byte, error) {
9292
return msg, nil
9393
}
9494

95+
// VerifyByChannel verifies a peer's signature on a message in the context
96+
// of a specific channel
97+
func (*naiveCryptoService) VerifyByChannel(_ common.ChainID, _ api.PeerIdentityType, _, _ []byte) error {
98+
return nil
99+
}
100+
95101
// Verify verifies a signature on a message that came from a peer with a certain vkID
96102
func (cs *naiveCryptoService) Verify(vkID api.PeerIdentityType, signature, message []byte) error {
97103
if !bytes.Equal(signature, message) {

gossip/state/state_test.go

+8
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,14 @@ func (*naiveCryptoService) Verify(peerIdentity api.PeerIdentityType, signature,
108108
return nil
109109
}
110110

111+
// VerifyByChannel checks that signature is a valid signature of message
112+
// under a peer's verification key, but also in the context of a specific channel.
113+
// If the verification succeeded, Verify returns nil meaning no error occurred.
114+
// If peerIdentity is nil, then the signature is verified against this peer's verification key.
115+
func (*naiveCryptoService) VerifyByChannel(chainID common.ChainID, peerIdentity api.PeerIdentityType, signature, message []byte) error {
116+
return nil
117+
}
118+
111119
func (*naiveCryptoService) ValidateIdentity(peerIdentity api.PeerIdentityType) error {
112120
return nil
113121
}

0 commit comments

Comments
 (0)