From 4e8efd0ceca273056cdb381b8bd341f252aacae6 Mon Sep 17 00:00:00 2001 From: Deirdre Connolly Date: Tue, 1 Jun 2021 01:59:34 -0400 Subject: [PATCH] Split out parsing & validation of test VerificationKey from checking of the signature (#2228) Now that we always generate an extra proper VerificationKey for each Tweak::ChangePubkey case, this /should/ never fail: it also helps split out the actual verification of the signature from the parsing and validation of the key itself. --- .../primitives/redpallas/tests/prop.txt | 3 +++ zebra-chain/src/primitives/redpallas/tests/prop.rs | 9 +++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/zebra-chain/proptest-regressions/primitives/redpallas/tests/prop.txt b/zebra-chain/proptest-regressions/primitives/redpallas/tests/prop.txt index 5dfb0d58..20fdb204 100644 --- a/zebra-chain/proptest-regressions/primitives/redpallas/tests/prop.txt +++ b/zebra-chain/proptest-regressions/primitives/redpallas/tests/prop.txt @@ -12,3 +12,6 @@ cc 68e194dd66b253f8e9ce1719d48859faee091b599b0eaa28f5565a0cb8dda0d7 # shrinks to # It is recommended to check this file in to source control so that # everyone who runs the test benefits from these saved cases. cc e31ba1ed4703731bee9d445f19eef0b9b3a4b83cf996bfe8f7c31ef199c7a7f5 # shrinks to tweaks = [ChangePubkey, ChangePubkey, ChangePubkey, ChangePubkey], rng_seed = [47, 76, 188, 189, 167, 109, 189, 126, 164, 51, 0, 11, 240, 53, 145, 194, 104, 117, 4, 96, 28, 48, 122, 25, 230, 14, 102, 21, 172, 162, 206, 139] +cc e4b0768f257afe1caf51520a4b145966ef17e734056a5de6fe03c8bd70d46a96 # shrinks to tweaks = [ChangePubkey, ChangePubkey, ChangePubkey, ChangePubkey], rng_seed = [176, 120, 84, 2, 89, 31, 155, 163, 124, 202, 49, 170, 157, 29, 1, 222, 252, 153, 37, 168, 22, 39, 188, 49, 32, 3, 37, 140, 37, 49, 122, 216] +cc 3343d535df2fd11dd8aaf647fd23a447ccfd3edc78997c119d3a33b703192908 # shrinks to tweaks = [ChangePubkey, ChangePubkey, ChangePubkey, ChangePubkey], rng_seed = [76, 239, 61, 73, 170, 200, 44, 2, 142, 88, 103, 213, 46, 44, 16, 122, 147, 213, 128, 119, 26, 104, 235, 218, 54, 50, 230, 45, 29, 191, 84, 87] +cc 5e6016829c630c3bff1805dc39110275755741d473f7b90e4d1f2ae4d2896c08 # shrinks to tweaks = [ChangePubkey, ChangePubkey, ChangePubkey, ChangePubkey], rng_seed = [77, 71, 192, 111, 106, 185, 167, 104, 120, 245, 108, 6, 39, 147, 183, 164, 187, 117, 31, 227, 54, 34, 197, 118, 54, 10, 171, 122, 62, 47, 75, 47] diff --git a/zebra-chain/src/primitives/redpallas/tests/prop.rs b/zebra-chain/src/primitives/redpallas/tests/prop.rs index c9f4901c..aff82ea7 100644 --- a/zebra-chain/src/primitives/redpallas/tests/prop.rs +++ b/zebra-chain/src/primitives/redpallas/tests/prop.rs @@ -67,11 +67,12 @@ impl SignatureCase { VerificationKeyBytes::::from(bytes) }; + // Check that the verification key is a valid RedPallas verification key. + let pub_key = VerificationKey::try_from(pk_bytes) + .expect("The test verification key to be well-formed."); + // Check that signature validation has the expected result. - self.is_valid - == VerificationKey::try_from(pk_bytes) - .and_then(|pk| pk.verify(&self.msg, &sig)) - .is_ok() + self.is_valid == pub_key.verify(&self.msg, &sig).is_ok() } fn apply_tweak(&mut self, tweak: &Tweak) {