From 4b5e9ddfa66e0e5082281034b148546278c2a315 Mon Sep 17 00:00:00 2001 From: David Date: Tue, 14 Apr 2020 10:12:40 +0200 Subject: [PATCH] Fix ecrecover builtin (#11623) * Upgrade parity-crypto to 0.6 * More fixes * Upgrade ethabi and ethabi-derive * Fix lockfile * Patch ethabi from master * quickfix for ethash * Update forkid * Add secret store back * Fetch ethabi from crates * fetch secret-store from the right place * update to keccak-hash 0.5.1 * ethash: upgrade keccak-hash * ethash: sneaky spaces * ethash: use overlapping bytes after all * revert submodule update * wip * Use new method to impl ecrecover builtin * Fetch patches from git * Sort out todo * Remove patches Co-authored-by: Andronik Ordian --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- accounts/Cargo.toml | 2 +- accounts/ethkey/Cargo.toml | 2 +- accounts/ethkey/cli/Cargo.toml | 2 +- accounts/ethstore/Cargo.toml | 2 +- accounts/ethstore/cli/Cargo.toml | 2 +- ethcore/Cargo.toml | 4 ++-- ethcore/blockchain/Cargo.toml | 2 +- ethcore/builtin/Cargo.toml | 2 +- ethcore/builtin/src/lib.rs | 10 ++++++++-- ethcore/engine/Cargo.toml | 2 +- ethcore/engines/authority-round/Cargo.toml | 2 +- ethcore/engines/basic-authority/Cargo.toml | 2 +- ethcore/engines/clique/Cargo.toml | 2 +- ethcore/engines/validator-set/Cargo.toml | 2 +- ethcore/executive-state/Cargo.toml | 2 +- ethcore/machine/Cargo.toml | 2 +- ethcore/private-tx/Cargo.toml | 2 +- ethcore/snapshot/snapshot-tests/Cargo.toml | 2 +- ethcore/sync/Cargo.toml | 2 +- ethcore/types/Cargo.toml | 2 +- ethcore/verification/Cargo.toml | 2 +- miner/Cargo.toml | 2 +- miner/local-store/Cargo.toml | 2 +- rpc/Cargo.toml | 2 +- util/network-devp2p/Cargo.toml | 2 +- util/network/Cargo.toml | 2 +- 28 files changed, 37 insertions(+), 31 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9581d89a1..3a64e1b14 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3241,9 +3241,9 @@ checksum = "16b56e3a2420138bdb970f84dfb9c774aea80fa0e7371549eedec0d80c209c67" [[package]] name = "parity-crypto" -version = "0.6.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97cb113593965e4ece813a49f8ff669728dfb4feb76af8208ea73d81d58aee42" +checksum = "2b7f19c1acc7fc6c5256a2f4f0c5af022044b9bdfdd0a218ff79f8cbb29779a5" dependencies = [ "aes", "aes-ctr", diff --git a/Cargo.toml b/Cargo.toml index 37a9724dc..ad37ec9b4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -52,7 +52,7 @@ num_cpus = "1.2" number_prefix = "0.2" panic_hook = { path = "util/panic-hook" } parity-bytes = "0.1" -parity-crypto = { version = "0.6.0", features = ["publickey"] } +parity-crypto = { version = "0.6.1", features = ["publickey"] } parity-daemonize = "0.3" parity-hash-fetch = { path = "updater/hash-fetch" } parity-local-store = { path = "miner/local-store" } diff --git a/accounts/Cargo.toml b/accounts/Cargo.toml index c4751ea61..3182f3937 100644 --- a/accounts/Cargo.toml +++ b/accounts/Cargo.toml @@ -10,7 +10,7 @@ edition = "2018" ethkey = { path = "ethkey" } ethstore = { path = "ethstore" } log = "0.4" -parity-crypto = { version = "0.6.0", features = ["publickey"] } +parity-crypto = { version = "0.6.1", features = ["publickey"] } parking_lot = "0.10.0" serde = "1.0" serde_derive = "1.0" diff --git a/accounts/ethkey/Cargo.toml b/accounts/ethkey/Cargo.toml index d27c6e3d9..65c62ba3f 100644 --- a/accounts/ethkey/Cargo.toml +++ b/accounts/ethkey/Cargo.toml @@ -9,5 +9,5 @@ edit-distance = "2.0" log = "0.4" serde = "1.0" serde_derive = "1.0" -parity-crypto = { version = "0.6.0", features = ["publickey"] } +parity-crypto = { version = "0.6.1", features = ["publickey"] } parity-wordlist = "1.3.1" diff --git a/accounts/ethkey/cli/Cargo.toml b/accounts/ethkey/cli/Cargo.toml index ef1f2435c..6111339a6 100644 --- a/accounts/ethkey/cli/Cargo.toml +++ b/accounts/ethkey/cli/Cargo.toml @@ -9,7 +9,7 @@ docopt = "1.0" env_logger = "0.5" ethkey = { path = "../" } panic_hook = { path = "../../../util/panic-hook" } -parity-crypto = { version = "0.6.0", features = ["publickey"] } +parity-crypto = { version = "0.6.1", features = ["publickey"] } parity-wordlist= "1.3.1" rustc-hex = "2.1.0" serde = "1.0" diff --git a/accounts/ethstore/Cargo.toml b/accounts/ethstore/Cargo.toml index 66cbc7fe5..33160c164 100644 --- a/accounts/ethstore/Cargo.toml +++ b/accounts/ethstore/Cargo.toml @@ -17,7 +17,7 @@ rustc-hex = "2.1.0" tiny-keccak = "2.0.2" time = "0.1.34" parking_lot = "0.10.0" -parity-crypto = { version = "0.6.0", features = ["publickey"] } +parity-crypto = { version = "0.6.1", features = ["publickey"] } ethereum-types = "0.9.0" dir = { path = "../../util/dir" } smallvec = "1.2.0" diff --git a/accounts/ethstore/cli/Cargo.toml b/accounts/ethstore/cli/Cargo.toml index 083c8a9ea..8062de629 100644 --- a/accounts/ethstore/cli/Cargo.toml +++ b/accounts/ethstore/cli/Cargo.toml @@ -14,7 +14,7 @@ serde_derive = "1.0" parking_lot = "0.10.0" ethstore = { path = "../" } ethkey = { path = "../../ethkey" } -parity-crypto = { version = "0.6.0", features = ["publickey"] } +parity-crypto = { version = "0.6.1", features = ["publickey"] } dir = { path = '../../../util/dir' } panic_hook = { path = "../../../util/panic-hook" } diff --git a/ethcore/Cargo.toml b/ethcore/Cargo.toml index c87176b61..a7133316a 100644 --- a/ethcore/Cargo.toml +++ b/ethcore/Cargo.toml @@ -42,7 +42,7 @@ parity-bytes = "0.1" parking_lot = "0.10.0" pod = { path = "pod", optional = true } trie-db = "0.20.0" -parity-crypto = { version = "0.6.0", features = ["publickey"], optional = true } +parity-crypto = { version = "0.6.1", features = ["publickey"], optional = true } patricia-trie-ethereum = { path = "../util/patricia-trie-ethereum" } rand = "0.7.3" rand_xorshift = "0.2.0" @@ -75,7 +75,7 @@ env_logger = "0.5" ethcore-accounts = { path = "../accounts" } ethcore-builtin = { path = "./builtin" } ethjson = { path = "../json", features = ["test-helpers"] } -parity-crypto = { version = "0.6.0", features = ["publickey"] } +parity-crypto = { version = "0.6.1", features = ["publickey"] } fetch = { path = "../util/fetch" } kvdb-memorydb = "0.5.0" kvdb-rocksdb = "0.7.0" diff --git a/ethcore/blockchain/Cargo.toml b/ethcore/blockchain/Cargo.toml index ef3c31a80..cf9e617e0 100644 --- a/ethcore/blockchain/Cargo.toml +++ b/ethcore/blockchain/Cargo.toml @@ -29,7 +29,7 @@ triehash-ethereum = { version = "0.2", path = "../../util/triehash-ethereum" } [dev-dependencies] env_logger = "0.5" -parity-crypto = { version = "0.6.0", features = ["publickey"] } +parity-crypto = { version = "0.6.1", features = ["publickey"] } rustc-hex = "2.1.0" tempfile = "3.1" kvdb-memorydb = "0.5.0" diff --git a/ethcore/builtin/Cargo.toml b/ethcore/builtin/Cargo.toml index dda7958b0..167802537 100644 --- a/ethcore/builtin/Cargo.toml +++ b/ethcore/builtin/Cargo.toml @@ -16,7 +16,7 @@ keccak-hash = "0.5.0" log = "0.4" num = { version = "0.1", default-features = false, features = ["bigint"] } parity-bytes = "0.1" -parity-crypto = { version = "0.6.0", features = ["publickey"] } +parity-crypto = { version = "0.6.1", features = ["publickey"] } [dev-dependencies] hex-literal = "0.2.1" diff --git a/ethcore/builtin/src/lib.rs b/ethcore/builtin/src/lib.rs index 1e2e83898..8f9dde5fc 100644 --- a/ethcore/builtin/src/lib.rs +++ b/ethcore/builtin/src/lib.rs @@ -30,7 +30,7 @@ use std::{ use byteorder::{BigEndian, LittleEndian, ReadBytesExt}; use common_types::errors::EthcoreError; use ethereum_types::{H256, U256}; -use parity_crypto::publickey::{Signature, recover as ec_recover}; +use parity_crypto::publickey::{recover_allowing_all_zero_message, Signature, ZeroesAllowedMessage}; use keccak_hash::keccak; use log::{warn, trace}; use num::{BigUint, Zero, One}; @@ -420,7 +420,13 @@ impl Implementation for EcRecover { let s = Signature::from_rsv(&r, &s, bit); if s.is_valid() { - if let Ok(p) = ec_recover(&s, &hash) { + // The builtin allows/requires all-zero messages to be valid to + // recover the public key. Use of such messages is disallowed in + // `rust-secp256k1` and this is a workaround for that. It is not an + // openethereum-level error to fail here; instead we return all + // zeroes and let the caller interpret that outcome. + let recovery_message = ZeroesAllowedMessage(hash); + if let Ok(p) = recover_allowing_all_zero_message(&s, recovery_message) { let r = keccak(p); output.write(0, &[0; 12]); output.write(12, &r.as_bytes()[12..]); diff --git a/ethcore/engine/Cargo.toml b/ethcore/engine/Cargo.toml index d5d69a1e1..c1a1e1482 100644 --- a/ethcore/engine/Cargo.toml +++ b/ethcore/engine/Cargo.toml @@ -13,7 +13,7 @@ bytes = { package = "parity-bytes", version = "0.1.0" } client-traits = { path = "../client-traits" } common-types = { path = "../types" } ethereum-types = "0.9.0" -parity-crypto = { version = "0.6.0", features = ["publickey"] } +parity-crypto = { version = "0.6.1", features = ["publickey"] } machine = { path = "../machine" } vm = { path = "../vm" } diff --git a/ethcore/engines/authority-round/Cargo.toml b/ethcore/engines/authority-round/Cargo.toml index cef7f19bd..6ea06abe3 100644 --- a/ethcore/engines/authority-round/Cargo.toml +++ b/ethcore/engines/authority-round/Cargo.toml @@ -17,7 +17,7 @@ ethabi-contract = "11.0" ethabi-derive = "12.0" ethereum-types = "0.9.0" ethjson = { path = "../../../json" } -parity-crypto = { version = "0.6.0", features = ["publickey"] } +parity-crypto = { version = "0.6.1", features = ["publickey"] } engine = { path = "../../engine" } io = { package = "ethcore-io", path = "../../../util/io" } itertools = "0.8.2" diff --git a/ethcore/engines/basic-authority/Cargo.toml b/ethcore/engines/basic-authority/Cargo.toml index 71c5b9149..db736b838 100644 --- a/ethcore/engines/basic-authority/Cargo.toml +++ b/ethcore/engines/basic-authority/Cargo.toml @@ -12,7 +12,7 @@ common-types = { path = "../../types" } engine = { path = "../../engine" } ethereum-types = "0.9.0" ethjson = { path = "../../../json" } -parity-crypto = { version = "0.6.0", features = ["publickey"] } +parity-crypto = { version = "0.6.1", features = ["publickey"] } log = "0.4.8" machine = { path = "../../machine" } parking_lot = "0.10.0" diff --git a/ethcore/engines/clique/Cargo.toml b/ethcore/engines/clique/Cargo.toml index e1e09bc58..7164e0380 100644 --- a/ethcore/engines/clique/Cargo.toml +++ b/ethcore/engines/clique/Cargo.toml @@ -11,7 +11,7 @@ client-traits = { path = "../../client-traits" } common-types = { path = "../../types" } ethereum-types = "0.9.0" ethjson = { path = "../../../json" } -parity-crypto = { version = "0.6.0", features = ["publickey"] } +parity-crypto = { version = "0.6.1", features = ["publickey"] } engine = { path = "../../engine" } keccak-hash = "0.5.0" lazy_static = "1.3.0" diff --git a/ethcore/engines/validator-set/Cargo.toml b/ethcore/engines/validator-set/Cargo.toml index 6f6cf5e32..ebeaff0dd 100644 --- a/ethcore/engines/validator-set/Cargo.toml +++ b/ethcore/engines/validator-set/Cargo.toml @@ -38,7 +38,7 @@ env_logger = "0.6.2" ethcore = { path = "../..", features = ["test-helpers"] } rustc-hex = "2.1.0" keccak-hash = "0.5.0" -parity-crypto = { version = "0.6.0", features = ["publickey"] } +parity-crypto = { version = "0.6.1", features = ["publickey"] } spec = { path = "../../spec" } [features] diff --git a/ethcore/executive-state/Cargo.toml b/ethcore/executive-state/Cargo.toml index d7df13ecd..cfb2ff226 100644 --- a/ethcore/executive-state/Cargo.toml +++ b/ethcore/executive-state/Cargo.toml @@ -28,7 +28,7 @@ vm = { path = "../vm" } [dev-dependencies] env_logger = "0.5" ethcore = { path = "..", features = ["test-helpers"] } -parity-crypto = { version = "0.6.0", features = ["publickey"] } +parity-crypto = { version = "0.6.1", features = ["publickey"] } evm = { path = "../evm" } keccak-hash = "0.5.0" pod = { path = "../pod" } diff --git a/ethcore/machine/Cargo.toml b/ethcore/machine/Cargo.toml index cd31a08f5..ccd6653e7 100644 --- a/ethcore/machine/Cargo.toml +++ b/ethcore/machine/Cargo.toml @@ -43,7 +43,7 @@ criterion = "0.3" ethcore = { path = "../", features = ["test-helpers"] } ethcore-io = { path = "../../util/io" } ethjson = { path = "../../json" } -parity-crypto = { version = "0.6.0", features = ["publickey"] } +parity-crypto = { version = "0.6.1", features = ["publickey"] } hex-literal = "0.2.1" spec = { path = "../spec" } tempfile = "3.1" diff --git a/ethcore/private-tx/Cargo.toml b/ethcore/private-tx/Cargo.toml index abd9298d5..f9aa578ab 100644 --- a/ethcore/private-tx/Cargo.toml +++ b/ethcore/private-tx/Cargo.toml @@ -31,7 +31,7 @@ log = "0.4" machine = { path = "../machine" } journaldb = { path = "../../util/journaldb" } parity-bytes = "0.1" -parity-crypto = { version = "0.6.0", features = ["publickey"] } +parity-crypto = { version = "0.6.1", features = ["publickey"] } parking_lot = "0.10.0" trie-db = "0.20.0" patricia-trie-ethereum = { path = "../../util/patricia-trie-ethereum" } diff --git a/ethcore/snapshot/snapshot-tests/Cargo.toml b/ethcore/snapshot/snapshot-tests/Cargo.toml index e19f8c096..8c6f91ffa 100644 --- a/ethcore/snapshot/snapshot-tests/Cargo.toml +++ b/ethcore/snapshot/snapshot-tests/Cargo.toml @@ -27,7 +27,7 @@ kvdb = "0.5.0" kvdb-rocksdb = "0.7.0" log = "0.4.8" parking_lot = "0.10.0" -parity-crypto = { version = "0.6.0", features = ["publickey"] } +parity-crypto = { version = "0.6.1", features = ["publickey"] } rand = "0.7.3" rand_xorshift = "0.2.0" rlp = "0.4.5" diff --git a/ethcore/sync/Cargo.toml b/ethcore/sync/Cargo.toml index 6fb55c90b..89c98a741 100644 --- a/ethcore/sync/Cargo.toml +++ b/ethcore/sync/Cargo.toml @@ -26,7 +26,7 @@ light = { package = "ethcore-light", path = "../light" } log = "0.4" network = { package = "ethcore-network", path = "../../util/network" } parity-runtime = "0.1.1" -parity-crypto = { version = "0.6.0", features = ["publickey"] } +parity-crypto = { version = "0.6.1", features = ["publickey"] } parity-util-mem = "0.6.0" rand = "0.7.3" parking_lot = "0.10.0" diff --git a/ethcore/types/Cargo.toml b/ethcore/types/Cargo.toml index 84194bf35..56e95d08a 100644 --- a/ethcore/types/Cargo.toml +++ b/ethcore/types/Cargo.toml @@ -12,7 +12,7 @@ ethereum-types = "0.9.0" ethjson = { path = "../../json" } keccak-hash = "0.5.0" parity-bytes = "0.1" -parity-crypto = { version = "0.6.0", features = ["publickey"] } +parity-crypto = { version = "0.6.1", features = ["publickey"] } parity-util-mem = "0.6.0" parity-snappy = "0.1" patricia-trie-ethereum = { path = "../../util/patricia-trie-ethereum" } diff --git a/ethcore/verification/Cargo.toml b/ethcore/verification/Cargo.toml index 608708483..2663e155b 100644 --- a/ethcore/verification/Cargo.toml +++ b/ethcore/verification/Cargo.toml @@ -35,7 +35,7 @@ unexpected = { path = "../../util/unexpected" } common-types = { path = "../types", features = ["test-helpers"] } criterion = "0.3" ethcore = { path = "../", features = ["test-helpers"] } -parity-crypto = { version = "0.6.0", features = ["publickey"] } +parity-crypto = { version = "0.6.1", features = ["publickey"] } machine = { path = "../machine" } null-engine = { path = "../engines/null-engine" } spec = { path = "../spec" } diff --git a/miner/Cargo.toml b/miner/Cargo.toml index c20bdd9df..8c1442ebe 100644 --- a/miner/Cargo.toml +++ b/miner/Cargo.toml @@ -39,7 +39,7 @@ transaction-pool = "2.0.1" [dev-dependencies] env_logger = "0.5" -parity-crypto = { version = "0.6.0", features = ["publickey"] } +parity-crypto = { version = "0.6.1", features = ["publickey"] } rustc-hex = "2.1.0" [features] diff --git a/miner/local-store/Cargo.toml b/miner/local-store/Cargo.toml index d2b3ccbf3..1c82f549f 100644 --- a/miner/local-store/Cargo.toml +++ b/miner/local-store/Cargo.toml @@ -17,5 +17,5 @@ serde_json = "1.0" [dev-dependencies] ethkey = { path = "../../accounts/ethkey" } -parity-crypto = { version = "0.6.0", features = ["publickey"] } +parity-crypto = { version = "0.6.1", features = ["publickey"] } kvdb-memorydb = "0.5.0" diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index 0e569ae9e..19208fa83 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -49,7 +49,7 @@ ethereum-types = "0.9.0" fastmap = { path = "../util/fastmap" } machine = { path = "../ethcore/machine" } parity-bytes = "0.1" -parity-crypto = { version = "0.6.0", features = ["publickey"] } +parity-crypto = { version = "0.6.1", features = ["publickey"] } eip-712 = { path = "../util/EIP-712" } ethjson = { path = "../json" } diff --git a/util/network-devp2p/Cargo.toml b/util/network-devp2p/Cargo.toml index 8611d3d50..09695031a 100644 --- a/util/network-devp2p/Cargo.toml +++ b/util/network-devp2p/Cargo.toml @@ -24,7 +24,7 @@ mio = "0.6.8" natpmp = "0.2" network = { package = "ethcore-network", path = "../network" } parity-bytes = "0.1" -parity-crypto = { version = "0.6.0", features = ["publickey"] } +parity-crypto = { version = "0.6.1", features = ["publickey"] } parity-path = "0.1" parity-snappy = "0.1" parking_lot = "0.10.0" diff --git a/util/network/Cargo.toml b/util/network/Cargo.toml index 2d1f27408..deaeecac3 100644 --- a/util/network/Cargo.toml +++ b/util/network/Cargo.toml @@ -8,7 +8,7 @@ authors = ["Parity Technologies "] [dependencies] derive_more = "0.99" -parity-crypto = { version = "0.6.0", features = ["publickey"] } +parity-crypto = { version = "0.6.1", features = ["publickey"] } ethcore-io = { path = "../io" } ethereum-types = "0.9.0" ipnetwork = "0.12.6"