mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 09:23:48 +00:00
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.
This commit is contained in:
parent
2640164304
commit
a0abb7dcfc
1 changed files with 2 additions and 2 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue