Skip to content
This repository was archived by the owner on Nov 6, 2020. It is now read-only.

[EngineSigner]: don't sign message with only zeroes#11524

Merged
ordian merged 3 commits into
masterfrom
na-engine-signer-dont-use-msg-only-zeroes
Feb 27, 2020
Merged

[EngineSigner]: don't sign message with only zeroes#11524
ordian merged 3 commits into
masterfrom
na-engine-signer-dont-use-msg-only-zeroes

Conversation

@niklasad1
Copy link
Copy Markdown
Collaborator

@niklasad1 niklasad1 commented Feb 26, 2020

Fixes #11521

At startup the engine_signer(s) are tested that they can sign dummy data, previously only zeroes were signed to check this. After switching to upstream rust-secp256k1 signing only zeroes doesn't work which this PR fixes.

Fixes #11521, caused by switching to `upstream rust-secp256k1`
@niklasad1 niklasad1 requested a review from dvdplm February 26, 2020 16:20
@ordian ordian added A0-pleasereview 🤓 Pull request needs code review. B0-patch-stable 🕷 Pull request should also be back-ported to the stable branch. M4-core ⛓ Core client code / Rust. labels Feb 26, 2020
Comment thread parity/account_utils.rs Outdated
Comment thread parity/account_utils.rs
debug!(target: "account", "Signing test of `EngineSigner ({})` with password index: {} failed because of: {:?}", engine_signer, idx, e);
invalid_reasons.insert(e.to_string());
} else {
return Ok(Some(ethcore::miner::Author::Sealer(Box::new(signer))));
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

once we have found a valid password then return it directly, no need to iterate over the rest.

Comment thread parity/account_utils.rs
}

Ok(author)
Err(format!(
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will look like:

No valid password found for EngineSigner 0x5100…cae4, the following errors were found during testing: {"custom crypto error: invalid AES message", "custom crypto error: Invalid password"}. Make sure valid password is present in files passed using `--password` or in the configuration file.

Err(_) => Err(Error::InvalidSecretKey),
}
self.accounts.sign(self.address, Some(self.password.clone()), message).map_err(|e| {
Error::Custom(e.to_string())
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

propagate real error cause instead of making assumptions.


fn decrypt(&self, auth_data: &[u8], cipher: &[u8]) -> Result<Vec<u8>, Error> {
self.accounts.decrypt(self.address, None, auth_data, cipher).map_err(|e| {
warn!("Unable to decrypt message: {:?}", e);
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed this, because it is better that the caller handles this error accordingly. Thoughts?

Comment thread parity/account_utils.rs
author = Some(::ethcore::miner::Author::Sealer(Box::new(signer)));
if let Err(e) = signer.sign(SECP_TEST_MESSAGE) {
debug!(target: "account", "Signing test of `EngineSigner ({})` with password index: {} failed because of: {:?}", engine_signer, idx, e);
invalid_reasons.insert(e.to_string());
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parity_crypto::public::Error doesn't impl Eq, that's why it is converted to a String

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it should? :)

@ordian ordian merged commit 11abf3e into master Feb 27, 2020
@ordian ordian deleted the na-engine-signer-dont-use-msg-only-zeroes branch February 27, 2020 11:22
ordian added a commit that referenced this pull request Mar 6, 2020
* master: (27 commits)
  Faster kill_garbage (#11514)
  [EngineSigner]: don't sign message with only zeroes (#11524)
  fix compilation warnings (#11522)
  [ethcore cleanup]: various unrelated fixes from `#11493` (#11507)
  Add benchmark for transaction execution (#11509)
  Add Smart Contract License v1.0
  Misc fixes (#11510)
  [dependencies]: unify `rustc-hex` (#11506)
  Activate on-chain randomness in POA Sokol (#11505)
  Grab bag of cleanup (#11504)
  Implement eth/64 (EIP-2364) and drop support for eth/62 (#11472)
  [dependencies]: remove `util/macros` (#11501)
  OpenEthereum bootnodes are added (#11499)
  [ci benches]: use `all-features` (#11496)
  [verification]: make test-build compile standalone (#11495)
  complete null-signatures removal (#11491)
  Include the seal when populating the header for a new block (#11475)
  fix compilation warnings (#11492)
  cargo update -p cmake (#11490)
  update to published rlp-derive (#11489)
  ...
ordian added a commit that referenced this pull request Mar 10, 2020
* master:
  Code cleanup in the sync module (#11552)
  initial cleanup (#11542)
  Warn if genesis constructor revert (#11550)
  ethcore: cleanup after #11531 (#11546)
  license update (#11543)
  Less cloning when importing blocks (#11531)
  Github Actions (#11528)
  Fix Alpine Dockerfile (#11538)
  Remove AuxiliaryData/AuxiliaryRequest (#11533)
  [journaldb]: cleanup (#11534)
  Remove references to parity-ethereum (#11525)
  Drop IPFS support (#11532)
  chain-supplier: fix warning reporting for GetNodeData request (#11530)
  Faster kill_garbage (#11514)
  [EngineSigner]: don't sign message with only zeroes (#11524)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

A0-pleasereview 🤓 Pull request needs code review. B0-patch-stable 🕷 Pull request should also be back-ported to the stable branch. M4-core ⛓ Core client code / Rust.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

parity build from master branch not work when use POA,No valid password for the consensus signer!

3 participants