diff options
Diffstat (limited to 'whisper/whisperv2/message.go')
-rw-r--r-- | whisper/whisperv2/message.go | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/whisper/whisperv2/message.go b/whisper/whisperv2/message.go index 7ef9d0912..e55544ffc 100644 --- a/whisper/whisperv2/message.go +++ b/whisper/whisperv2/message.go @@ -21,11 +21,13 @@ package whisperv2 import ( "crypto/ecdsa" + crand "crypto/rand" "math/rand" "time" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/crypto/ecies" "github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/logger/glog" ) @@ -131,13 +133,13 @@ func (self *Message) Recover() *ecdsa.PublicKey { // encrypt encrypts a message payload with a public key. func (self *Message) encrypt(key *ecdsa.PublicKey) (err error) { - self.Payload, err = crypto.Encrypt(key, self.Payload) + self.Payload, err = ecies.Encrypt(crand.Reader, ecies.ImportECDSAPublic(key), self.Payload, nil, nil) return } // decrypt decrypts an encrypted payload with a private key. func (self *Message) decrypt(key *ecdsa.PrivateKey) error { - cleartext, err := crypto.Decrypt(key, self.Payload) + cleartext, err := ecies.ImportECDSA(key).Decrypt(crand.Reader, self.Payload, nil, nil) if err == nil { self.Payload = cleartext } |