Skip to content

Commit

Permalink
Add extra logs REMOVE ME
Browse files Browse the repository at this point in the history
  • Loading branch information
cammellos committed May 20, 2019
1 parent 021215a commit 2be840c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions services/shhext/chat/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,10 @@ func (p *ProtocolService) HandleMessage(myIdentityKey *ecdsa.PrivateKey, theirPu
return nil, err
}

p.log.Info("Checking version")
// Handle protocol negotiation for compatible clients
if protocolMessage.Version >= topicNegotiationVersion {
p.log.Info("Version greater than 1 negotianting")
topic, err := p.topic.Receive(myIdentityKey, theirPublicKey, protocolMessage.GetInstallationId())
if err != nil {
return nil, err
Expand Down
2 changes: 2 additions & 0 deletions services/shhext/chat/topic/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"crypto/ecdsa"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/crypto/ecies"
"github.com/ethereum/go-ethereum/log"
)

const sskLen = 16
Expand All @@ -18,6 +19,7 @@ func NewService(persistence PersistenceService) *Service {

// Receive will generate a shared secret for a given identity, and return it
func (s *Service) Receive(myPrivateKey *ecdsa.PrivateKey, theirPublicKey *ecdsa.PublicKey, installationID string) ([]byte, error) {
log.Info("Receive called for", "installationID", installationID)
sharedKey, err := ecies.ImportECDSA(myPrivateKey).GenerateShared(
ecies.ImportECDSAPublic(theirPublicKey),
sskLen,
Expand Down
5 changes: 5 additions & 0 deletions services/shhext/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/node"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/p2p/enode"
Expand Down Expand Up @@ -322,6 +323,7 @@ func (s *Service) GetSymKeyID(sharedSecret []byte) string {

func (s *Service) onNewTopicHandler(sharedSecrets [][]byte) {
var filterIDs []string
log.Info("NEW TOPIC HANDLER", "secrets", sharedSecrets)
for _, sharedSecret := range sharedSecrets {
secretID := fmt.Sprintf("%x", crypto.Keccak256(sharedSecret))
if _, ok := s.filtersAdded[secretID]; ok {
Expand All @@ -335,6 +337,7 @@ func (s *Service) onNewTopicHandler(sharedSecrets [][]byte) {
}
symKeyID, err := api.AddSymKey(context.TODO(), sharedSecret)
if err != nil {
log.Error("SYM KEYN FAILED", "err", err)
return
}

Expand All @@ -345,13 +348,15 @@ func (s *Service) onNewTopicHandler(sharedSecrets [][]byte) {
}
filterID, err := api.NewMessageFilter(criteria)
if err != nil {
log.Error("FILTER FAILED", "err", err)
return
}

filterIDs = append(filterIDs, filterID)
s.filtersAdded[secretID] = symKeyID

}
log.Info("FILTER IDS", "filter", filterIDs)
if len(filterIDs) != 0 {
handler := EnvelopeSignalHandler{}
handler.WhisperFilterAdded(filterIDs)
Expand Down

0 comments on commit 2be840c

Please sign in to comment.