diff --git a/whisper/whisper.go b/whisper/whisper.go index 59a1a63c48..61999f07ad 100644 --- a/whisper/whisper.go +++ b/whisper/whisper.go @@ -260,9 +260,11 @@ func (self *Whisper) open(envelope *Envelope) *Message { // Iterate over the keys and try to decrypt the message for _, key := range self.keys { message, err := envelope.Open(key) - if err == nil || err == ecies.ErrInvalidPublicKey { + if err == nil { message.To = &key.PublicKey return message + } else if err == ecies.ErrInvalidPublicKey { + return message } } // Failed to decrypt, don't return anything