From a0abb7dcfc17a525027b5daca872f555cbf6d38b Mon Sep 17 00:00:00 2001 From: Guillaume Ballet Date: Thu, 30 Nov 2017 21:47:12 +0100 Subject: [PATCH] whisper: filter with sym & asym keys must try both methods There is an ongoing discussion whether this is the proper way to go, as filters implementing both sym and asym keys will see an unsuccessful attempt at an asymmetric decryption be followed by an attempt at a symmetric decription. This is inefficient in that case, which should not happen too often. The alternative is to forbid using filters with both options enabled, and will require updating unit tests. --- whisper/whisperv6/envelope.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/whisper/whisperv6/envelope.go b/whisper/whisperv6/envelope.go index 23cf879fd3..e7d0f1f858 100644 --- a/whisper/whisperv6/envelope.go +++ b/whisper/whisperv6/envelope.go @@ -211,14 +211,14 @@ func (e *Envelope) Open(watcher *Filter) (msg *ReceivedMessage) { // if the filter has some asymmetric key provided, it will // attempt to open it asymmetrically. If this fails, then // attempt to open it symmetrically. - if watcher.KeyAsym != nil { + if watcher.expectsAsymmetricEncryption() { msg, _ = e.OpenAsymmetric(watcher.KeyAsym) if msg != nil { msg.Dst = &watcher.KeyAsym.PublicKey } } - if msg == nil { + if msg == nil && watcher.expectsSymmetricEncryption() { msg, _ = e.OpenSymmetric(watcher.KeySym) if msg != nil { msg.SymKeyHash = crypto.Keccak256Hash(watcher.KeySym)