aboutsummaryrefslogtreecommitdiffstats
path: root/whisper
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-01-15 01:12:18 +0800
committerobscuren <geffobscura@gmail.com>2015-01-15 01:12:18 +0800
commit62e0e18030c84fa19f54373ebdf25f7adbc64793 (patch)
tree6113a4b0ad6c4bd1e847c4a8a5dabf4a11dbe28d /whisper
parentbb55307a9d8fa73b0fbc0727f8b80925a87627b7 (diff)
downloadgo-tangerine-62e0e18030c84fa19f54373ebdf25f7adbc64793.tar.gz
go-tangerine-62e0e18030c84fa19f54373ebdf25f7adbc64793.tar.zst
go-tangerine-62e0e18030c84fa19f54373ebdf25f7adbc64793.zip
Changed public whisper api not to reveal temporary private keys
Diffstat (limited to 'whisper')
-rw-r--r--whisper/whisper.go19
1 files changed, 10 insertions, 9 deletions
diff --git a/whisper/whisper.go b/whisper/whisper.go
index ece2dd6d4..76cfe34a4 100644
--- a/whisper/whisper.go
+++ b/whisper/whisper.go
@@ -60,7 +60,7 @@ type Whisper struct {
quit chan struct{}
- keys []*ecdsa.PrivateKey
+ keys map[string]*ecdsa.PrivateKey
}
func New() *Whisper {
@@ -69,6 +69,7 @@ func New() *Whisper {
filters: filter.New(),
expiry: make(map[uint32]*set.SetNonTS),
quit: make(chan struct{}),
+ keys: make(map[string]*ecdsa.PrivateKey),
}
whisper.filters.Start()
@@ -101,18 +102,18 @@ func (self *Whisper) NewIdentity() *ecdsa.PrivateKey {
if err != nil {
panic(err)
}
- self.keys = append(self.keys, key)
+
+ self.keys[string(crypto.FromECDSAPub(&key.PublicKey))] = key
return key
}
-func (self *Whisper) HasIdentity(key *ecdsa.PrivateKey) bool {
- for _, key := range self.keys {
- if key.D.Cmp(key.D) == 0 {
- return true
- }
- }
- return false
+func (self *Whisper) HasIdentity(key *ecdsa.PublicKey) bool {
+ return self.keys[string(crypto.FromECDSAPub(key))] != nil
+}
+
+func (self *Whisper) GetIdentity(key *ecdsa.PublicKey) *ecdsa.PrivateKey {
+ return self.keys[string(crypto.FromECDSAPub(key))]
}
func (self *Whisper) Watch(opts Filter) int {