From 7c1d4d9a5b63330d71884dc78fefcefaf8b384d5 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Sun, 18 Aug 2019 23:56:15 +0100 Subject: [PATCH] Log distinct error cases in Equihash verification --- Cargo.lock | 10 ++++++++++ zcash_primitives/Cargo.toml | 1 + zcash_primitives/src/block/equihash.rs | 7 ++++--- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d6f658a..623bcc0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -317,6 +317,14 @@ dependencies = [ "zcash_proofs 0.0.0", ] +[[package]] +name = "log" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "nodrop" version = "0.1.13" @@ -535,6 +543,7 @@ dependencies = [ "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "hex-literal 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "pairing 0.14.2", "rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -594,6 +603,7 @@ dependencies = [ "checksum hex-literal-impl 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "520870c3213943eb8d7803e80180d12a6c7ceb4ae74602544529d1643dc4ddda" "checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" "checksum libc 0.2.61 (registry+https://github.com/rust-lang/crates.io-index)" = "c665266eb592905e8503ba3403020f4b8794d26263f412ca33171600eca9a6fa" +"checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" "checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945" "checksum num-bigint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "57450397855d951f1a41305e54851b1a7b8f5d2e349543a02a2effe25459f718" "checksum num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "b85e541ef8255f6cf42bbfe4ef361305c6c135d10919ecc26126c4e5ae94bc09" diff --git a/zcash_primitives/Cargo.toml b/zcash_primitives/Cargo.toml index 5e1bf91..7019dec 100644 --- a/zcash_primitives/Cargo.toml +++ b/zcash_primitives/Cargo.toml @@ -16,6 +16,7 @@ ff = { path = "../ff" } fpe = "0.2" hex = "0.3" lazy_static = "1" +log = "0.4" pairing = { path = "../pairing" } rand = "0.7" rand_core = "0.5" diff --git a/zcash_primitives/src/block/equihash.rs b/zcash_primitives/src/block/equihash.rs index 9710dc9..2a3bb66 100644 --- a/zcash_primitives/src/block/equihash.rs +++ b/zcash_primitives/src/block/equihash.rs @@ -1,5 +1,6 @@ use blake2b_simd::{Hash as Blake2bHash, Params as Blake2bParams, State as Blake2bState}; use byteorder::{BigEndian, LittleEndian, ReadBytesExt, WriteBytesExt}; +use log::error; use std::io::Cursor; use std::mem::size_of; @@ -196,13 +197,13 @@ fn distinct_indices(a: &Node, b: &Node) -> bool { fn validate_subtrees(p: &Params, a: &Node, b: &Node) -> bool { if !has_collision(a, b, p.collision_byte_length()) { - // error!("Invalid solution: invalid collision length between StepRows"); + error!("Invalid solution: invalid collision length between StepRows"); false } else if b.indices_before(a) { - // error!("Invalid solution: Index tree incorrectly ordered"); + error!("Invalid solution: Index tree incorrectly ordered"); false } else if !distinct_indices(a, b) { - // error!("Invalid solution: duplicate indices"); + error!("Invalid solution: duplicate indices"); false } else { true