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
This commit is contained in:
committed by
Jeffrey Wilcke
parent
bf21549faa
commit
9b0af51386
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user