diff options
author | Felix Lange <fjl@users.noreply.github.com> | 2017-02-18 16:24:12 +0800 |
---|---|---|
committer | Jeffrey Wilcke <jeffrey@ethereum.org> | 2017-02-18 16:24:12 +0800 |
commit | 9b0af513867fad4aeb3516e4711dd0ea4f5bc90c (patch) | |
tree | b37d808d57873c6aec550431534e26602dfd0475 /whisper/whisperv2/message.go | |
parent | bf21549faa7de6e2b920855468b14856c6f503c4 (diff) | |
download | dexon-9b0af513867fad4aeb3516e4711dd0ea4f5bc90c.tar dexon-9b0af513867fad4aeb3516e4711dd0ea4f5bc90c.tar.gz dexon-9b0af513867fad4aeb3516e4711dd0ea4f5bc90c.tar.bz2 dexon-9b0af513867fad4aeb3516e4711dd0ea4f5bc90c.tar.lz dexon-9b0af513867fad4aeb3516e4711dd0ea4f5bc90c.tar.xz dexon-9b0af513867fad4aeb3516e4711dd0ea4f5bc90c.tar.zst dexon-9b0af513867fad4aeb3516e4711dd0ea4f5bc90c.zip |
crypto: add btcec fallback for sign/recover without cgo (#3680)
* vendor: add github.com/btcsuite/btcd/btcec
* crypto: add btcec fallback for sign/recover without cgo
This commit adds a non-cgo fallback implementation of secp256k1
operations.
* crypto, core/vm: remove wrappers for sha256, ripemd160
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 } |