diff options
author | obscuren <geffobscura@gmail.com> | 2014-12-13 05:23:42 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-12-13 05:23:42 +0800 |
commit | a17a1f9208f858601f6660dbd7f1b77dd9a3f3d9 (patch) | |
tree | 6f6f61cfd2dd41cc20d1bcae9604c1f09e07e42d /whisper/message.go | |
parent | ed1538248f2e7a44680d22a052a234a31b736624 (diff) | |
download | go-tangerine-a17a1f9208f858601f6660dbd7f1b77dd9a3f3d9.tar.gz go-tangerine-a17a1f9208f858601f6660dbd7f1b77dd9a3f3d9.tar.zst go-tangerine-a17a1f9208f858601f6660dbd7f1b77dd9a3f3d9.zip |
Implemented watching using filter package
* Added filters / watches
* Removed event dep
Diffstat (limited to 'whisper/message.go')
-rw-r--r-- | whisper/message.go | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/whisper/message.go b/whisper/message.go index 8ce5d880b..db0110b4a 100644 --- a/whisper/message.go +++ b/whisper/message.go @@ -28,15 +28,11 @@ func (self *Message) sign(key *ecdsa.PrivateKey) (err error) { } func (self *Message) Recover() *ecdsa.PublicKey { + defer func() { recover() }() // in case of invalid sig return crypto.SigToPub(self.hash(), self.Signature) } -func (self *Message) Encrypt(from *ecdsa.PrivateKey, to *ecdsa.PublicKey) (err error) { - err = self.sign(from) - if err != nil { - return err - } - +func (self *Message) Encrypt(to *ecdsa.PublicKey) (err error) { self.Payload, err = crypto.Encrypt(to, self.Payload) if err != nil { return err @@ -57,8 +53,16 @@ type Opts struct { } func (self *Message) Seal(pow time.Duration, opts Opts) (*Envelope, error) { - if opts.To != nil && opts.From != nil { - if err := self.Encrypt(opts.From, opts.To); err != nil { + if opts.From != nil { + err := self.sign(opts.From) + if err != nil { + return nil, err + } + } + + if opts.To != nil { + err := self.Encrypt(opts.To) + if err != nil { return nil, err } } |