diff options
author | obscuren <geffobscura@gmail.com> | 2015-01-15 01:12:18 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-01-15 01:12:18 +0800 |
commit | 62e0e18030c84fa19f54373ebdf25f7adbc64793 (patch) | |
tree | 6113a4b0ad6c4bd1e847c4a8a5dabf4a11dbe28d /ui/qt/qwhisper/whisper.go | |
parent | bb55307a9d8fa73b0fbc0727f8b80925a87627b7 (diff) | |
download | go-tangerine-62e0e18030c84fa19f54373ebdf25f7adbc64793.tar go-tangerine-62e0e18030c84fa19f54373ebdf25f7adbc64793.tar.gz go-tangerine-62e0e18030c84fa19f54373ebdf25f7adbc64793.tar.bz2 go-tangerine-62e0e18030c84fa19f54373ebdf25f7adbc64793.tar.lz go-tangerine-62e0e18030c84fa19f54373ebdf25f7adbc64793.tar.xz go-tangerine-62e0e18030c84fa19f54373ebdf25f7adbc64793.tar.zst go-tangerine-62e0e18030c84fa19f54373ebdf25f7adbc64793.zip |
Changed public whisper api not to reveal temporary private keys
Diffstat (limited to 'ui/qt/qwhisper/whisper.go')
-rw-r--r-- | ui/qt/qwhisper/whisper.go | 45 |
1 files changed, 27 insertions, 18 deletions
diff --git a/ui/qt/qwhisper/whisper.go b/ui/qt/qwhisper/whisper.go index b904678f4..644c147b7 100644 --- a/ui/qt/qwhisper/whisper.go +++ b/ui/qt/qwhisper/whisper.go @@ -41,32 +41,41 @@ func (self *Whisper) Post(payload []string, to, from string, topics []string, pr data = append(data, fromHex(d)...) } - msg := whisper.NewMessage(data) - envelope, err := msg.Seal(time.Duration(priority*100000), whisper.Opts{ - Ttl: time.Duration(ttl) * time.Second, - To: crypto.ToECDSAPub(fromHex(to)), - From: crypto.ToECDSA(fromHex(from)), - Topics: whisper.TopicsFromString(topics...), - }) - if err != nil { - qlogger.Infoln(err) - // handle error - return - } + pk := crypto.ToECDSAPub(fromHex(from)) + if key := self.Whisper.GetIdentity(pk); key != nil { + msg := whisper.NewMessage(data) + envelope, err := msg.Seal(time.Duration(priority*100000), whisper.Opts{ + Ttl: time.Duration(ttl) * time.Second, + To: crypto.ToECDSAPub(fromHex(to)), + From: key, + Topics: whisper.TopicsFromString(topics...), + }) + + if err != nil { + qlogger.Infoln(err) + // handle error + return + } - if err := self.Whisper.Send(envelope); err != nil { - qlogger.Infoln(err) - // handle error - return + if err := self.Whisper.Send(envelope); err != nil { + qlogger.Infoln(err) + // handle error + return + } + } else { + qlogger.Infoln("unmatched pub / priv for seal") } + } func (self *Whisper) NewIdentity() string { - return toHex(self.Whisper.NewIdentity().D.Bytes()) + key := self.Whisper.NewIdentity() + + return toHex(crypto.FromECDSAPub(&key.PublicKey)) } func (self *Whisper) HasIdentity(key string) bool { - return self.Whisper.HasIdentity(crypto.ToECDSA(fromHex(key))) + return self.Whisper.HasIdentity(crypto.ToECDSAPub(fromHex(key))) } func (self *Whisper) Watch(opts map[string]interface{}, view *qml.Common) int { |