Crypto primitives removed from ethkey (#11174)
* Crypto utils removed from ethkey * Fix ethkey lib * Switch ethsore to new crypto * Accounts crate fixed * Secret store crate switched to new crypto * Ethcore builtin fixed * Accounts crate fixed * Ethcore crate fixed * Util network fixed * Util network-devp2p fixed * Private tx fixed * Ethcore sync fixed * Secret store fixed * Rpc fixed * Parity fixed * Ethkey cli fixed * Local store fixed * Ethcore blockchain fixed * Cargo.lock pushed; doc comment added for reversed nonce * Ethstore tests fixed * Ethstore cli fixed * Miner fixed * Snapshot tests are fixed * Single brackets removed * Machine fixed * Verification fixed * Executive state fixed * More single brackets removed * Update version of parity-crypto * Use published version 0.4.2 of parity-crypto * New test in tx_filter fixed
This commit is contained in:
@@ -37,7 +37,7 @@ use common_types::{
|
||||
use client_traits::EngineClient;
|
||||
|
||||
use ethereum_types::{H256, U256, Address};
|
||||
use ethkey::Signature;
|
||||
use parity_crypto::publickey::Signature;
|
||||
use machine::{
|
||||
Machine,
|
||||
executed_block::ExecutedBlock,
|
||||
|
||||
@@ -17,27 +17,27 @@
|
||||
//! A signer used by Engines which need to sign messages.
|
||||
|
||||
use ethereum_types::{H256, Address};
|
||||
use ethkey::{self, Signature};
|
||||
use parity_crypto::publickey::{Signature, KeyPair, Error};
|
||||
|
||||
/// Everything that an Engine needs to sign messages.
|
||||
pub trait EngineSigner: Send + Sync {
|
||||
/// Sign a consensus message hash.
|
||||
fn sign(&self, hash: H256) -> Result<Signature, ethkey::Error>;
|
||||
fn sign(&self, hash: H256) -> Result<Signature, Error>;
|
||||
|
||||
/// Signing address
|
||||
fn address(&self) -> Address;
|
||||
}
|
||||
|
||||
/// Creates a new `EngineSigner` from given key pair.
|
||||
pub fn from_keypair(keypair: ethkey::KeyPair) -> Box<dyn EngineSigner> {
|
||||
pub fn from_keypair(keypair: KeyPair) -> Box<dyn EngineSigner> {
|
||||
Box::new(Signer(keypair))
|
||||
}
|
||||
|
||||
struct Signer(ethkey::KeyPair);
|
||||
struct Signer(KeyPair);
|
||||
|
||||
impl EngineSigner for Signer {
|
||||
fn sign(&self, hash: H256) -> Result<Signature, ethkey::Error> {
|
||||
ethkey::sign(self.0.secret(), &hash)
|
||||
fn sign(&self, hash: H256) -> Result<Signature, Error> {
|
||||
parity_crypto::publickey::sign(self.0.secret(), &hash)
|
||||
}
|
||||
|
||||
fn address(&self) -> Address {
|
||||
|
||||
@@ -19,25 +19,26 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use ethereum_types::{Address, H256};
|
||||
use ethkey::{Password, Signature};
|
||||
use ethkey::Password;
|
||||
use parity_crypto::publickey::{Signature, Error};
|
||||
use log::warn;
|
||||
use accounts::{self, AccountProvider, SignError};
|
||||
|
||||
use crate::signer::EngineSigner;
|
||||
|
||||
impl EngineSigner for (Arc<AccountProvider>, Address, Password) {
|
||||
fn sign(&self, hash: H256) -> Result<Signature, ethkey::Error> {
|
||||
fn sign(&self, hash: H256) -> Result<Signature, Error> {
|
||||
match self.0.sign(self.1, Some(self.2.clone()), hash) {
|
||||
Err(SignError::NotUnlocked) => unreachable!(),
|
||||
Err(SignError::NotFound) => Err(ethkey::Error::InvalidAddress),
|
||||
Err(SignError::SStore(accounts::Error::EthKey(err))) => Err(err),
|
||||
Err(SignError::SStore(accounts::Error::EthKeyCrypto(err))) => {
|
||||
Err(SignError::NotFound) => Err(Error::InvalidAddress),
|
||||
Err(SignError::SStore(accounts::Error::EthCrypto(err))) => Err(Error::Custom(err.to_string())),
|
||||
Err(SignError::SStore(accounts::Error::EthPublicKeyCrypto(err))) => {
|
||||
warn!("Low level crypto error: {:?}", err);
|
||||
Err(ethkey::Error::InvalidSecret)
|
||||
Err(Error::InvalidSecretKey)
|
||||
},
|
||||
Err(SignError::SStore(err)) => {
|
||||
warn!("Error signing for engine: {:?}", err);
|
||||
Err(ethkey::Error::InvalidSignature)
|
||||
Err(Error::InvalidSignature)
|
||||
},
|
||||
Ok(ok) => Ok(ok),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user