From 603882ff01b5bdf0cac37f79373979f86969ee92 Mon Sep 17 00:00:00 2001 From: Noah Vesely Date: Thu, 15 Mar 2018 16:15:04 -0600 Subject: [PATCH 01/35] Small Rustfmt formatting fix to build.rs --- build.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.rs b/build.rs index f1488f4..b47873e 100644 --- a/build.rs +++ b/build.rs @@ -78,8 +78,8 @@ fn main() { write!( f, "pub struct Tables {{ \ - pub exp: [u8; 256], \ - pub log: [u8; 256] \ + pub exp: [u8; 256], \ + pub log: [u8; 256] \ }} \ \ pub static TABLES: Tables = " From 5263953050c54581e27477fd868eee9a0d3127aa Mon Sep 17 00:00:00 2001 From: Noah Vesely Date: Thu, 15 Mar 2018 21:21:53 -0600 Subject: [PATCH 02/35] Initial barycentric Langrange interpolation Implements barycentric Lagrange interpolation. Uses algorithm (3.1) from the paper "Polynomial Interpolation: Langrange vs Newton" by Wilhelm Werner to find the barycentric weights, and then evaluates at `Gf256::zero()` using the second or "true" form of the barycentric interpolation formula. I also earlier implemented a variant of this algorithm, Algorithm 2, from "A new efficient algorithm for polynomial interpolation," which uses less total operations than Werner's version, however, because it uses a lot more multiplications or divisions (depending on how you choose to write it), it runs slower given the running time of subtraction/ addition (equal) vs multiplication, and especially division in the Gf256 module. The new algorithm takes n^2 / 2 divisions and n^2 subtractions to calculate the barycentric weights, and another n divisions, n multiplications, and 2n additions to evaluate the polynomial*. The old algorithm runs in n^2 - n divisions, n^2 multiplications, and n^2 subtractions. Without knowing the exact running time of each of these operations, we can't say for sure, but I think a good guess would be the new algorithm trends toward about 1/3 running time as n -> infinity. It's also easy to see theoretically that for small n the original lagrange algorithm is faster. This is backed up by benchmarks, which showed for n >= 5, the new algorithm is faster. We can see that this is more or less what we should expect given the running times in n of these algorithms. To ensure we always run the faster algorithm, I've kept both versions and only use the new one when 5 or more points are given. Previously the tests in the lagrange module were allowed to pass nodes to the interpolation algorithms with x = 0. Genuine shares will not be evaluated at x = 0, since then they would just be the secret, so: 1. Now nodes in tests start at x = 1 like `scheme::secret_share` deals them out. 2. I have added assert statements to reinforce this fact and guard against division by 0 panics. This meant getting rid of the `evaluate_at_works` test, but `interpolate_evaluate_at_0_eq_evaluate_at` provides a similar test. Further work will include the use of barycentric weights in the `interpolate` function. A couple more interesting things to note about barycentric weights: * Barycentric weights can be partially computed if less than threshold shares are present. When additional shares come in, computation can resume with no penalty to the total runtime. * They can be determined totally independently from the y values of our points, and the x value we want to evaluate for. We only need to know the x values of our interpolation points. --- src/lagrange.rs | 78 ++++++++++++++++++++++++++++++++++++----------- src/sss/scheme.rs | 2 +- 2 files changed, 61 insertions(+), 19 deletions(-) diff --git a/src/lagrange.rs b/src/lagrange.rs index 50baf8b..2161e01 100644 --- a/src/lagrange.rs +++ b/src/lagrange.rs @@ -1,12 +1,28 @@ use gf256::Gf256; use poly::Poly; +// Minimum number of points where it becomes faster to use barycentric +// Lagrange interpolation. Determined by benchmarking. +const BARYCENTRIC_THRESHOLD: u8 = 5; + /// Evaluates an interpolated polynomial at `Gf256::zero()` where -/// the polynomial is determined using Lagrangian interpolation -/// based on the given `points` in the G(2^8) Galois field. -pub(crate) fn interpolate_at(points: &[(u8, u8)]) -> u8 { +/// the polynomial is determined using either standard or barycentric +/// Lagrange interpolation (depending on number of points, `k`) based +/// on the given `points` in the G(2^8) Galois field. +pub(crate) fn interpolate_at(k: u8, points: &[(u8, u8)]) -> u8 { + if k < BARYCENTRIC_THRESHOLD { + lagrange_interpolate_at(points) + } else { + barycentric_interpolate_at(k as usize, points) + } +} + +/// Evaluates the polynomial at `Gf256::zero()` using standard Langrange +/// interpolation. +fn lagrange_interpolate_at(points: &[(u8, u8)]) -> u8 { let mut sum = Gf256::zero(); for (i, &(raw_xi, raw_yi)) in points.iter().enumerate() { + assert_ne!(raw_xi, 0, "Invalid share x = 0"); let xi = Gf256::from_byte(raw_xi); let yi = Gf256::from_byte(raw_yi); let mut prod = Gf256::one(); @@ -23,6 +39,36 @@ pub(crate) fn interpolate_at(points: &[(u8, u8)]) -> u8 { sum.to_byte() } +/// Barycentric Lagrange interpolation algorithm from "Polynomial +/// Interpolation: Langrange vs Newton" by Wilhelm Werner. Evaluates +/// the polynomial at `Gf256::zero()`. +fn barycentric_interpolate_at(k: usize, points: &[(u8, u8)]) -> u8 { + // Compute the barycentric weights `w`. + let mut w = vec![Gf256::zero(); k]; + w[0] = Gf256::one(); + let mut x = Vec::with_capacity(k); + x.push(Gf256::from_byte(points[0].0)); + for i in 1..k { + x.push(Gf256::from_byte(points[i].0)); + for j in 0..i { + let delta = x[j] - x[i]; + assert_ne!(delta.poly, 0, "Duplicate shares"); + w[j] /= delta; + w[i] -= w[j]; + } + } + // Evaluate the second or "true" form of the barycentric + // interpolation formula at `Gf256::zero()`. + let (mut num, mut denom) = (Gf256::zero(), Gf256::zero()); + for i in 0..k { + assert_ne!(x[i].poly, 0, "Invalid share x = 0"); + let diff = w[i] / x[i]; + num += diff * Gf256::from_byte(points[i].1); + denom += diff; + } + (num / denom).to_byte() +} + /// Computeds the coefficient of the Lagrange polynomial interpolated /// from the given `points`, in the G(2^8) Galois field. pub(crate) fn interpolate(points: &[(Gf256, Gf256)]) -> Poly { @@ -31,6 +77,7 @@ pub(crate) fn interpolate(points: &[(Gf256, Gf256)]) -> Poly { let mut poly = vec![Gf256::zero(); len]; for &(x, y) in points { + assert_ne!(x.poly, 0, "Invalid share x = 0"); let mut coeffs = vec![Gf256::zero(); len]; coeffs[0] = y; @@ -71,24 +118,15 @@ mod tests { quickcheck! { - fn evaluate_at_works(ys: Vec) -> TestResult { - if ys.is_empty() || ys.len() > std::u8::MAX as usize { - return TestResult::discard(); - } - - let points = ys.iter().enumerate().map(|(x, y)| (x as u8, *y)).collect::>(); - let equals = interpolate_at(points.as_slice()) == ys[0]; - - TestResult::from_bool(equals) - } - - fn interpolate_evaluate_at_works(ys: Vec) -> TestResult { if ys.is_empty() || ys.len() > std::u8::MAX as usize { return TestResult::discard(); } - let points = ys.into_iter().enumerate().map(|(x, y)| (gf256!(x as u8), y)).collect::>(); + let points = ys.into_iter() + .zip(1..std::u8::MAX) + .map(|(y, x)| (gf256!(x), y)) + .collect::>(); let poly = interpolate(&points); for (x, y) in points { @@ -105,7 +143,10 @@ mod tests { return TestResult::discard(); } - let points = ys.into_iter().enumerate().map(|(x, y)| (x as u8, y)).collect::>(); + let points = ys.into_iter() + .zip(1..std::u8::MAX) + .map(|(y, x)| (x, y)) + .collect::>(); let elems = points .iter() @@ -114,7 +155,8 @@ mod tests { let poly = interpolate(&elems); - let equals = poly.evaluate_at(Gf256::zero()).to_byte() == interpolate_at(points.as_slice()); + let equals = poly.evaluate_at(Gf256::zero()).to_byte() + == interpolate_at(points.len() as u8, points.as_slice()); TestResult::from_bool(equals) } diff --git a/src/sss/scheme.rs b/src/sss/scheme.rs index acb3723..8e28874 100644 --- a/src/sss/scheme.rs +++ b/src/sss/scheme.rs @@ -101,7 +101,7 @@ impl SSS { for s in shares.iter().take(threshold as usize) { col_in.push((s.id, s.data[byteindex])); } - secret.push(interpolate_at(&*col_in)); + secret.push(interpolate_at(threshold, &*col_in)); } Ok(secret) From be20e7749f2d7850a5db3e2ae7bbe3b9bba8a4d8 Mon Sep 17 00:00:00 2001 From: Romain Ruetschi Date: Mon, 19 Mar 2018 21:39:30 +0100 Subject: [PATCH 03/35] Use barycentric Lagrange interpolation in all cases. While this is a slight regression in performance in the case where k < 5, in absolute terms it is small enough to be neglible. --- src/lagrange.rs | 43 +++++++++---------------------------------- 1 file changed, 9 insertions(+), 34 deletions(-) diff --git a/src/lagrange.rs b/src/lagrange.rs index 2161e01..ebf84e8 100644 --- a/src/lagrange.rs +++ b/src/lagrange.rs @@ -1,53 +1,26 @@ use gf256::Gf256; use poly::Poly; -// Minimum number of points where it becomes faster to use barycentric -// Lagrange interpolation. Determined by benchmarking. -const BARYCENTRIC_THRESHOLD: u8 = 5; - /// Evaluates an interpolated polynomial at `Gf256::zero()` where -/// the polynomial is determined using either standard or barycentric -/// Lagrange interpolation (depending on number of points, `k`) based -/// on the given `points` in the G(2^8) Galois field. +/// the polynomial is determined using barycentric Lagrange +/// interpolation based on the given `points` in +/// the G(2^8) Galois field. pub(crate) fn interpolate_at(k: u8, points: &[(u8, u8)]) -> u8 { - if k < BARYCENTRIC_THRESHOLD { - lagrange_interpolate_at(points) - } else { - barycentric_interpolate_at(k as usize, points) - } -} - -/// Evaluates the polynomial at `Gf256::zero()` using standard Langrange -/// interpolation. -fn lagrange_interpolate_at(points: &[(u8, u8)]) -> u8 { - let mut sum = Gf256::zero(); - for (i, &(raw_xi, raw_yi)) in points.iter().enumerate() { - assert_ne!(raw_xi, 0, "Invalid share x = 0"); - let xi = Gf256::from_byte(raw_xi); - let yi = Gf256::from_byte(raw_yi); - let mut prod = Gf256::one(); - for (j, &(raw_xj, _)) in points.iter().enumerate() { - if i != j { - let xj = Gf256::from_byte(raw_xj); - let delta = xi - xj; - assert_ne!(delta.poly, 0, "Duplicate shares"); - prod *= xj / delta; - } - } - sum += prod * yi; - } - sum.to_byte() + barycentric_interpolate_at(k as usize, points) } /// Barycentric Lagrange interpolation algorithm from "Polynomial /// Interpolation: Langrange vs Newton" by Wilhelm Werner. Evaluates /// the polynomial at `Gf256::zero()`. +#[inline] fn barycentric_interpolate_at(k: usize, points: &[(u8, u8)]) -> u8 { // Compute the barycentric weights `w`. let mut w = vec![Gf256::zero(); k]; w[0] = Gf256::one(); + let mut x = Vec::with_capacity(k); x.push(Gf256::from_byte(points[0].0)); + for i in 1..k { x.push(Gf256::from_byte(points[i].0)); for j in 0..i { @@ -57,6 +30,7 @@ fn barycentric_interpolate_at(k: usize, points: &[(u8, u8)]) -> u8 { w[i] -= w[j]; } } + // Evaluate the second or "true" form of the barycentric // interpolation formula at `Gf256::zero()`. let (mut num, mut denom) = (Gf256::zero(), Gf256::zero()); @@ -66,6 +40,7 @@ fn barycentric_interpolate_at(k: usize, points: &[(u8, u8)]) -> u8 { num += diff * Gf256::from_byte(points[i].1); denom += diff; } + (num / denom).to_byte() } From e39bdaf0d18c3f3c87044bf50de3ca43f775f0f2 Mon Sep 17 00:00:00 2001 From: Romain Ruetschi Date: Mon, 19 Mar 2018 21:40:55 +0100 Subject: [PATCH 04/35] Ensure there is at least one point in QuickCheck tests --- src/lagrange.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lagrange.rs b/src/lagrange.rs index ebf84e8..4118818 100644 --- a/src/lagrange.rs +++ b/src/lagrange.rs @@ -114,7 +114,7 @@ mod tests { } fn interpolate_evaluate_at_0_eq_evaluate_at(ys: Vec) -> TestResult { - if ys.len() > std::u8::MAX as usize { + if ys.is_empty() || ys.len() > std::u8::MAX as usize { return TestResult::discard(); } From a2dafcf72548817c4e8f607536212ae17c48626f Mon Sep 17 00:00:00 2001 From: Noah Vesely Date: Thu, 15 Mar 2018 15:47:22 -0600 Subject: [PATCH 05/35] Use Horner's method for evaluating polynomials Horner's method is an algorithm for calculating polynomials, which consists of transforming the monomial form into a computationally efficient form. It is pretty easy to understand: https://en.wikipedia.org/wiki/Horner%27s_method#Description_of_the_algorithm This implementation has resulted in a noticeable secret share generation speedup as the RustySecrets benchmarks show, especially when calculating larger polynomials: Before: test sss::generate_1kb_10_25 ... bench: 3,104,391 ns/iter (+/- 113,824) test sss::generate_1kb_3_5 ... bench: 951,807 ns/iter (+/- 41,067) After: test sss::generate_1kb_10_25 ... bench: 2,071,655 ns/iter (+/- 46,445) test sss::generate_1kb_3_5 ... bench: 869,875 ns/iter (+/- 40,246) --- src/sss/encode.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/sss/encode.rs b/src/sss/encode.rs index d2729fb..dfb8302 100644 --- a/src/sss/encode.rs +++ b/src/sss/encode.rs @@ -6,13 +6,10 @@ use std::io::prelude::*; pub(crate) fn encode_secret_byte(src: &[u8], n: u8, w: &mut W) -> io::Result<()> { for raw_x in 1..(u16::from(n) + 1) { let x = Gf256::from_byte(raw_x as u8); - let mut fac = Gf256::one(); - let mut acc = Gf256::zero(); - for &coeff in src.iter() { - acc += fac * Gf256::from_byte(coeff); - fac *= x; - } - w.write_all(&[acc.to_byte()])?; + let sum = src.iter().rev().fold(Gf256::zero(), |acc, &coeff| { + Gf256::from_byte(coeff) + acc * x + }); + w.write_all(&[sum.to_byte()])?; } Ok(()) } From 0b42b6b9cc6ceba183d03a2fa8258fcbf62a15b2 Mon Sep 17 00:00:00 2001 From: Noah Vesely Date: Thu, 15 Mar 2018 15:57:02 -0600 Subject: [PATCH 06/35] Note algorithm in encode_secret_byte docstring --- src/sss/encode.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sss/encode.rs b/src/sss/encode.rs index dfb8302..abfe549 100644 --- a/src/sss/encode.rs +++ b/src/sss/encode.rs @@ -2,7 +2,8 @@ use gf256::Gf256; use std::io; use std::io::prelude::*; -/// evaluates a polynomial at x=1, 2, 3, ... n (inclusive) +/// Evaluates a polynomial at x=1, 2, 3, ... n (inclusive) using +/// Horner's method. pub(crate) fn encode_secret_byte(src: &[u8], n: u8, w: &mut W) -> io::Result<()> { for raw_x in 1..(u16::from(n) + 1) { let x = Gf256::from_byte(raw_x as u8); From 5a9bfb913ad73898a9cd1fa62a72f540f8361325 Mon Sep 17 00:00:00 2001 From: Noah Vesely Date: Fri, 16 Mar 2018 15:32:58 -0600 Subject: [PATCH 07/35] Update rand to ^0.4.2 RustySecrets makes minimal use of the rand library. It only initializes the `ChaChaRng` with a seed, and `OsRng` in the standard way, and then calls their `fill_bytes` methods, provided by the same Trait, and whose function signature has not changed. I have confirmed by looking at the code changes, that there have been no changes to the relevant interfaces this library uses. --- Cargo.toml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9baeef1..4da5b1a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ dss = [] [dependencies] base64 = "0.9.0" -rand = "^0.3" +rand = "^0.4.2" ring = "^0.12" merkle_sigs = "^1.4" protobuf = "^1.4" @@ -63,4 +63,3 @@ tag-prefix = "v" tag-message = "Release version {{version}}." doc-commit-message = "Update documentation." dev-version-ext = "pre" - From b34a2094bc51a2453e1d2eeaabd6af52469ee846 Mon Sep 17 00:00:00 2001 From: Noah Vesely Date: Wed, 21 Mar 2018 12:47:33 -0600 Subject: [PATCH 08/35] Add TODO note on unreleased Rng::try_fill_bytes --- src/sss/scheme.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/sss/scheme.rs b/src/sss/scheme.rs index 8e28874..d5021ba 100644 --- a/src/sss/scheme.rs +++ b/src/sss/scheme.rs @@ -77,6 +77,8 @@ impl SSS { let mut osrng = OsRng::new()?; for (c, &s) in src.iter().enumerate() { col_in[0] = s; + // NOTE: switch to `try_fill_bytes` when it lands in a stable release: + // https://github.com/rust-lang-nursery/rand/commit/230b2258dbd99ff8bd991008c972d923d4b5d10c osrng.fill_bytes(&mut col_in[1..]); col_out.clear(); encode_secret_byte(&*col_in, shares_count, &mut col_out)?; From ecb22aa6435cde08c7f7105f4dbbb52957ad7877 Mon Sep 17 00:00:00 2001 From: Noah Vesely Date: Mon, 26 Mar 2018 17:10:38 -0600 Subject: [PATCH 09/35] Remove `ShareIdentifierTooBig` error and validation Since id is a `u8` it will never be greater than 255. --- src/errors.rs | 5 ----- src/share/validation.rs | 4 ---- 2 files changed, 9 deletions(-) diff --git a/src/errors.rs b/src/errors.rs index c2b7496..6940357 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -59,11 +59,6 @@ error_chain! { display("The shares are incompatible with each other.") } - ShareIdentifierTooBig(id: u8, n: u8) { - description("Share identifier too big") - display("Found share identifier ({}) bigger than the maximum number of shares ({}).", id, n) - } - MissingShares(provided: usize, required: usize) { description("The number of shares provided is insufficient to recover the secret.") display("{} shares are required to recover the secret, found only {}.", required, provided) diff --git a/src/share/validation.rs b/src/share/validation.rs index f8f94ad..139f3f7 100644 --- a/src/share/validation.rs +++ b/src/share/validation.rs @@ -37,10 +37,6 @@ pub(crate) fn validate_shares(shares: Vec) -> Result<(u8, Vec) for share in shares { let (id, threshold) = (share.get_id(), share.get_threshold()); - if id > MAX_SHARES { - bail!(ErrorKind::ShareIdentifierTooBig(id, MAX_SHARES)) - } - if id < 1 { bail!(ErrorKind::ShareParsingInvalidShareId(id)) } From 2baa8ab3e7ff1983616a6641f976363c24144d92 Mon Sep 17 00:00:00 2001 From: Noah Vesely Date: Mon, 26 Mar 2018 17:12:58 -0600 Subject: [PATCH 10/35] Remove `DuplicateShareData` error and validation It's possible that two different points have the same data. To give a concrete example consider the secret polynomial `x^2 + x + s`, where `s` is the secret byte. Plugging in 214 and 215 (both elements of the cyclic subgroup of order 2) for `x` will give the same result, `1 + s`. More broadly, for any polynomial `b*x^t + b*x^(t-1) + ... + x + s`, where `t` is the order of at least one subgroup of GF(256), for all subgroups of order `t`, all elements of that subgroup, when chosen for `x`, will produce the same result. There are certainly other types of polynomials that have "share collisions." This type was just easy to find because it exploits the nature of finite fields. --- src/errors.rs | 5 ----- src/share/validation.rs | 5 ----- tests/recovery_errors.rs | 11 ----------- tests/ss1_recovery_errors.rs | 26 -------------------------- tests/thss_recovery_errors.rs | 23 ----------------------- 5 files changed, 70 deletions(-) diff --git a/src/errors.rs b/src/errors.rs index 6940357..315d47b 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -118,11 +118,6 @@ error_chain! { display("This share number ({}) has already been used by a previous share.", share_id) } - DuplicateShareData(share_id: u8) { - description("The data encoded in this share is the same as the one found in a previous share") - display("The data encoded in share #{} is the same as the one found in a previous share.", share_id) - } - InconsistentShares { description("The shares are inconsistent") display("The shares are inconsistent") diff --git a/src/share/validation.rs b/src/share/validation.rs index 139f3f7..45e0e63 100644 --- a/src/share/validation.rs +++ b/src/share/validation.rs @@ -55,11 +55,6 @@ pub(crate) fn validate_shares(shares: Vec) -> Result<(u8, Vec) bail!(ErrorKind::ShareParsingErrorEmptyShare(id)) } - if result.iter().any(|s| s.get_data() == share.get_data()) && share.get_threshold() != 1 { - // When threshold = 1, shares data can be the same - bail!(ErrorKind::DuplicateShareData(id)); - } - result.push(share); } diff --git a/tests/recovery_errors.rs b/tests/recovery_errors.rs index 7a36dbe..d986b69 100644 --- a/tests/recovery_errors.rs +++ b/tests/recovery_errors.rs @@ -66,17 +66,6 @@ fn test_recover_duplicate_shares_number() { recover_secret(&shares, false).unwrap(); } -#[test] -#[should_panic(expected = "DuplicateShareData")] -fn test_recover_duplicate_shares_data() { - let share1 = "2-1-CgnlCxRNtnkzENE".to_string(); - let share2 = "2-2-CgnlCxRNtnkzENE".to_string(); - - let shares = vec![share1, share2]; - - recover_secret(&shares, false).unwrap(); -} - #[test] #[should_panic(expected = "MissingShares")] fn test_recover_too_few_shares() { diff --git a/tests/ss1_recovery_errors.rs b/tests/ss1_recovery_errors.rs index 4ab71a2..1ad4d11 100644 --- a/tests/ss1_recovery_errors.rs +++ b/tests/ss1_recovery_errors.rs @@ -135,32 +135,6 @@ fn test_recover_duplicate_shares_number() { recover_secret(&shares).unwrap(); } -#[test] -#[should_panic(expected = "DuplicateShareData")] -fn test_recover_duplicate_shares_data() { - let hash = get_test_hash(); - let share1 = Share { - id: 1, - threshold: TEST_THRESHOLD, - shares_count: TEST_SHARES_COUNT, - data: "1YAYwmOHqZ69jA".to_string().into_bytes(), - hash: hash.clone(), - metadata: None, - }; - let share2 = Share { - id: 2, - threshold: TEST_THRESHOLD, - shares_count: TEST_SHARES_COUNT, - data: "1YAYwmOHqZ69jA".to_string().into_bytes(), - hash: hash.clone(), - metadata: None, - }; - - let shares = vec![share1, share2]; - - recover_secret(&shares).unwrap(); -} - #[test] #[should_panic(expected = "MissingShares")] fn test_recover_too_few_shares() { diff --git a/tests/thss_recovery_errors.rs b/tests/thss_recovery_errors.rs index 4c6c58a..173680a 100644 --- a/tests/thss_recovery_errors.rs +++ b/tests/thss_recovery_errors.rs @@ -106,29 +106,6 @@ fn test_recover_duplicate_shares_number() { recover_secret(&shares).unwrap(); } -#[test] -#[should_panic(expected = "DuplicateShareData")] -fn test_recover_duplicate_shares_data() { - let share1 = Share { - id: 1, - threshold: 2, - shares_count: 2, - data: "1YAYwmOHqZ69jA".to_string().into_bytes(), - metadata: None, - }; - let share2 = Share { - id: 2, - threshold: 2, - shares_count: 2, - data: "1YAYwmOHqZ69jA".to_string().into_bytes(), - metadata: None, - }; - - let shares = vec![share1, share2]; - - recover_secret(&shares).unwrap(); -} - #[test] #[should_panic(expected = "MissingShares")] fn test_recover_too_few_shares() { From 10209b674959ef1beba17852405dc5d724ca5ad9 Mon Sep 17 00:00:00 2001 From: Noah Vesely Date: Tue, 27 Mar 2018 14:24:43 -0600 Subject: [PATCH 11/35] Add ErrorKind::ShareParsingInvalidShareThreshold Ensures that threshold > 2 during the parsing process, since we ensure the same during the splitting process. --- src/errors.rs | 5 +++++ src/share/validation.rs | 2 ++ tests/recovery_errors.rs | 11 +++++++++++ 3 files changed, 18 insertions(+) diff --git a/src/errors.rs b/src/errors.rs index 315d47b..388d885 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -92,6 +92,11 @@ error_chain! { display("Found invalid share identifier ({})", share_id) } + ShareParsingInvalidShareThreshold(k: u8, id: u8) { + description("Threshold k must be bigger than or equal to 2") + display("Threshold k must be bigger than or equal to 2. Got k = {} for share identifier {}.", k, id) + } + InvalidSS1Parameters(r: usize, s: usize) { description("Invalid parameters for the SS1 sharing scheme") display("Invalid parameters for the SS1 sharing scheme: r = {}, s = {}.", r, s) diff --git a/src/share/validation.rs b/src/share/validation.rs index 45e0e63..4aa9069 100644 --- a/src/share/validation.rs +++ b/src/share/validation.rs @@ -39,6 +39,8 @@ pub(crate) fn validate_shares(shares: Vec) -> Result<(u8, Vec) if id < 1 { bail!(ErrorKind::ShareParsingInvalidShareId(id)) + } else if threshold < 2 { + bail!(ErrorKind::ShareParsingInvalidShareThreshold(threshold, id)) } k_compatibility_sets diff --git a/tests/recovery_errors.rs b/tests/recovery_errors.rs index d986b69..1fd7295 100644 --- a/tests/recovery_errors.rs +++ b/tests/recovery_errors.rs @@ -77,6 +77,17 @@ fn test_recover_too_few_shares() { recover_secret(&shares, false).unwrap(); } +#[test] +#[should_panic(expected = "ShareParsingInvalidShareThreshold")] +fn test_recover_invalid_share_threshold() { + let share1 = "1-1-CgnlCxRNtnkzENE".to_string(); + let share2 = "1-1-CgkAnUgP3lfwjyM".to_string(); + + let shares = vec![share1, share2]; + + recover_secret(&shares, false).unwrap(); +} + // See https://github.com/SpinResearch/RustySecrets/issues/43 #[test] fn test_recover_too_few_shares_bug() { From b48a74ab95e4ac4e9d296b1617942cd4d3ebdd44 Mon Sep 17 00:00:00 2001 From: Noah Vesely Date: Tue, 27 Mar 2018 14:30:50 -0600 Subject: [PATCH 12/35] Simplify threshold consistency validation Since the validation already confirms `shares` is not empty, `k_sets` will never match 0. --- src/share/validation.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/share/validation.rs b/src/share/validation.rs index 4aa9069..fde5b22 100644 --- a/src/share/validation.rs +++ b/src/share/validation.rs @@ -64,7 +64,6 @@ pub(crate) fn validate_shares(shares: Vec) -> Result<(u8, Vec) let k_sets = k_compatibility_sets.keys().count(); match k_sets { - 0 => bail!(ErrorKind::EmptyShares), 1 => {} // All shares have the same roothash. _ => { bail! { From c7f2742de8ead0550599b89a4bcbb0ccc7334e31 Mon Sep 17 00:00:00 2001 From: Noah Vesely Date: Tue, 27 Mar 2018 14:35:40 -0600 Subject: [PATCH 13/35] Fix arg order missing shares validation The arguments were provided in the wrong order. --- src/share/validation.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/share/validation.rs b/src/share/validation.rs index fde5b22..1c069fa 100644 --- a/src/share/validation.rs +++ b/src/share/validation.rs @@ -81,7 +81,7 @@ pub(crate) fn validate_shares(shares: Vec) -> Result<(u8, Vec) let threshold = k_compatibility_sets.keys().last().unwrap().to_owned(); if shares_count < threshold as usize { - bail!(ErrorKind::MissingShares(threshold as usize, shares_count)); + bail!(ErrorKind::MissingShares(shares_count, threshold as usize)); } Ok((threshold, result)) From 6d04a587f8cb8915157fb2a75dcfdbf67649e550 Mon Sep 17 00:00:00 2001 From: Noah Vesely Date: Tue, 27 Mar 2018 14:37:11 -0600 Subject: [PATCH 14/35] MissingShares should take `u8` for `required` arg --- src/errors.rs | 2 +- src/share/validation.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/errors.rs b/src/errors.rs index 388d885..b5d1bee 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -59,7 +59,7 @@ error_chain! { display("The shares are incompatible with each other.") } - MissingShares(provided: usize, required: usize) { + MissingShares(provided: usize, required: u8) { description("The number of shares provided is insufficient to recover the secret.") display("{} shares are required to recover the secret, found only {}.", required, provided) } diff --git a/src/share/validation.rs b/src/share/validation.rs index 1c069fa..143f5dd 100644 --- a/src/share/validation.rs +++ b/src/share/validation.rs @@ -81,7 +81,7 @@ pub(crate) fn validate_shares(shares: Vec) -> Result<(u8, Vec) let threshold = k_compatibility_sets.keys().last().unwrap().to_owned(); if shares_count < threshold as usize { - bail!(ErrorKind::MissingShares(shares_count, threshold as usize)); + bail!(ErrorKind::MissingShares(shares_count, threshold)); } Ok((threshold, result)) From 8ab91bbf93451b1557ca629e86b4dea24459cee2 Mon Sep 17 00:00:00 2001 From: Noah Vesely Date: Tue, 27 Mar 2018 14:47:02 -0600 Subject: [PATCH 15/35] More specific validation error when share thresholds mismatch --- src/errors.rs | 5 +++++ src/share/validation.rs | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/errors.rs b/src/errors.rs index b5d1bee..9c300ff 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -59,6 +59,11 @@ error_chain! { display("The shares are incompatible with each other.") } + IncompatibleThresholds(sets: Vec>) { + description("The shares are incompatible with each other because they do not all have the same threshold.") + display("The shares are incompatible with each other because they do not all have the same threshold.") + } + MissingShares(provided: usize, required: u8) { description("The number of shares provided is insufficient to recover the secret.") display("{} shares are required to recover the secret, found only {}.", required, provided) diff --git a/src/share/validation.rs b/src/share/validation.rs index 143f5dd..a94b4dd 100644 --- a/src/share/validation.rs +++ b/src/share/validation.rs @@ -67,7 +67,7 @@ pub(crate) fn validate_shares(shares: Vec) -> Result<(u8, Vec) 1 => {} // All shares have the same roothash. _ => { bail! { - ErrorKind::IncompatibleSets( + ErrorKind::IncompatibleThresholds( k_compatibility_sets .values() .map(|x| x.to_owned()) From fefd5ab3694282470bf87d974bedc2d0b6c0b3d0 Mon Sep 17 00:00:00 2001 From: Noah Vesely Date: Tue, 27 Mar 2018 15:22:21 -0600 Subject: [PATCH 16/35] Validate shares have the same data length --- src/errors.rs | 5 +++++ src/share/validation.rs | 31 +++++++++++++++++++++++++++---- tests/recovery_errors.rs | 11 +++++++++++ 3 files changed, 43 insertions(+), 4 deletions(-) diff --git a/src/errors.rs b/src/errors.rs index 9c300ff..40fe950 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -64,6 +64,11 @@ error_chain! { display("The shares are incompatible with each other because they do not all have the same threshold.") } + IncompatibleDataLengths(sets: Vec>) { + description("The shares are incompatible with each other because they do not all have the same share data length.") + display("The shares are incompatible with each other because they do not all have the same share data length.") + } + MissingShares(provided: usize, required: u8) { description("The number of shares provided is insufficient to recover the secret.") display("{} shares are required to recover the secret, found only {}.", required, provided) diff --git a/src/share/validation.rs b/src/share/validation.rs index a94b4dd..93d0078 100644 --- a/src/share/validation.rs +++ b/src/share/validation.rs @@ -33,14 +33,17 @@ pub(crate) fn validate_shares(shares: Vec) -> Result<(u8, Vec) let mut result: Vec = Vec::with_capacity(shares_count); let mut k_compatibility_sets = HashMap::new(); + let mut data_len_compatibility_sets = HashMap::new(); for share in shares { - let (id, threshold) = (share.get_id(), share.get_threshold()); + let (id, threshold, data_len) = (share.get_id(), share.get_threshold(), share.get_data().len()); if id < 1 { bail!(ErrorKind::ShareParsingInvalidShareId(id)) } else if threshold < 2 { bail!(ErrorKind::ShareParsingInvalidShareThreshold(threshold, id)) + } else if data_len < 1 { + bail!(ErrorKind::ShareParsingErrorEmptyShare(id)) } k_compatibility_sets @@ -53,9 +56,12 @@ pub(crate) fn validate_shares(shares: Vec) -> Result<(u8, Vec) bail!(ErrorKind::DuplicateShareId(id)); } - if share.get_data().is_empty() { - bail!(ErrorKind::ShareParsingErrorEmptyShare(id)) - } + data_len_compatibility_sets + .entry(data_len) + .or_insert_with(HashSet::new); + let data_len_set = data_len_compatibility_sets.get_mut(&data_len).unwrap(); + data_len_set.insert(id); + result.push(share); } @@ -84,6 +90,23 @@ pub(crate) fn validate_shares(shares: Vec) -> Result<(u8, Vec) bail!(ErrorKind::MissingShares(shares_count, threshold)); } + // Validate share length consistency + let data_len_sets = data_len_compatibility_sets.keys().count(); + + match data_len_sets { + 1 => {} // All shares have the same `data` field len + _ => { + bail! { + ErrorKind::IncompatibleDataLengths( + data_len_compatibility_sets + .values() + .map(|x| x.to_owned()) + .collect(), + ) + } + } + } + Ok((threshold, result)) } diff --git a/tests/recovery_errors.rs b/tests/recovery_errors.rs index 1fd7295..c8f13e1 100644 --- a/tests/recovery_errors.rs +++ b/tests/recovery_errors.rs @@ -66,6 +66,17 @@ fn test_recover_duplicate_shares_number() { recover_secret(&shares, false).unwrap(); } +#[test] +#[should_panic(expected = "IncompatibleDataLengths")] +fn test_recover_incompatible_data_lengths() { + let share1 = "2-1-CgnlCxRNtnkzENE".to_string(); + let share2 = "2-2-ChbG46L1zRszs0PPn63XnnupmZTcgYJ3".to_string(); + + let shares = vec![share1, share2]; + + recover_secret(&shares, false).unwrap(); +} + #[test] #[should_panic(expected = "MissingShares")] fn test_recover_too_few_shares() { From 51f77faf47dfed3daa9541222d1b2c0e4d81ba85 Mon Sep 17 00:00:00 2001 From: Romain Ruetschi Date: Wed, 28 Mar 2018 14:49:47 +0200 Subject: [PATCH 17/35] Disable `dss` benchmarks until we expose the module. Closes #49 --- benches/ss1.rs | 1 + benches/thss.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/benches/ss1.rs b/benches/ss1.rs index 601e92f..d32b72b 100644 --- a/benches/ss1.rs +++ b/benches/ss1.rs @@ -1,5 +1,6 @@ #![cfg(test)] #![feature(test)] +#![cfg(feature = "dss")] extern crate rusty_secrets; extern crate test; diff --git a/benches/thss.rs b/benches/thss.rs index 95dc79c..b11386b 100644 --- a/benches/thss.rs +++ b/benches/thss.rs @@ -1,5 +1,6 @@ #![cfg(test)] #![feature(test)] +#![cfg(feature = "dss")] extern crate rusty_secrets; extern crate test; From 5ee3cf2d0078d21aae37064335c637d9760b4708 Mon Sep 17 00:00:00 2001 From: Noah Vesely Date: Wed, 28 Mar 2018 18:51:10 -0600 Subject: [PATCH 18/35] Change signatures of share validation fns * Pass a ref to `Vec` instead of recreating and moving the object through several functions. * Return `slen`/ `data_len`, since we'll be using it anyway in `recover_secrets` --- src/dss/ss1/scheme.rs | 3 ++- src/dss/thss/scheme.rs | 5 ++--- src/share/validation.rs | 22 ++++++++++++---------- src/sss/scheme.rs | 3 +-- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/dss/ss1/scheme.rs b/src/dss/ss1/scheme.rs index 0801a28..9672e5e 100644 --- a/src/dss/ss1/scheme.rs +++ b/src/dss/ss1/scheme.rs @@ -247,7 +247,8 @@ impl SS1 { &self, shares: &[Share], ) -> Result<(Vec, AccessStructure, Option)> { - let (_, shares) = validate_shares(shares.to_vec())?; + let shares = shares.to_vec(); + validate_shares(&shares)?; let underlying_shares = shares .iter() diff --git a/src/dss/thss/scheme.rs b/src/dss/thss/scheme.rs index c11cfd7..141c932 100644 --- a/src/dss/thss/scheme.rs +++ b/src/dss/thss/scheme.rs @@ -89,9 +89,8 @@ impl ThSS { &self, shares: &[Share], ) -> Result<(Vec, AccessStructure, Option)> { - let (threshold, shares) = validate_shares(shares.to_vec())?; - - let cypher_len = shares[0].data.len(); + let shares = shares.to_vec(); + let (threshold, cypher_len) = validate_shares(&shares)?; let polys = (0..cypher_len) .map(|i| { diff --git a/src/share/validation.rs b/src/share/validation.rs index 93d0078..8a256b1 100644 --- a/src/share/validation.rs +++ b/src/share/validation.rs @@ -11,27 +11,27 @@ use share::{IsShare, IsSignedShare}; /// TODO: Doc pub(crate) fn validate_signed_shares( - shares: Vec, + shares: &Vec, verify_signatures: bool, -) -> Result<(u8, Vec)> { - let (threshold, shares) = validate_shares(shares)?; +) -> Result<(u8, usize)> { + let result = validate_shares(shares)?; if verify_signatures { S::verify_signatures(&shares)?; } - Ok((threshold, shares)) + Ok(result) } /// TODO: Doc -pub(crate) fn validate_shares(shares: Vec) -> Result<(u8, Vec)> { +pub(crate) fn validate_shares(shares: &Vec) -> Result<(u8, usize)> { if shares.is_empty() { bail!(ErrorKind::EmptyShares); } let shares_count = shares.len(); - let mut result: Vec = Vec::with_capacity(shares_count); + let mut ids = Vec::with_capacity(shares_count); let mut k_compatibility_sets = HashMap::new(); let mut data_len_compatibility_sets = HashMap::new(); @@ -52,7 +52,7 @@ pub(crate) fn validate_shares(shares: Vec) -> Result<(u8, Vec) let k_set = k_compatibility_sets.get_mut(&threshold).unwrap(); k_set.insert(id); - if result.iter().any(|s| s.get_id() == id) { + if ids.iter().any(|&x| x == id) { bail!(ErrorKind::DuplicateShareId(id)); } @@ -62,8 +62,7 @@ pub(crate) fn validate_shares(shares: Vec) -> Result<(u8, Vec) let data_len_set = data_len_compatibility_sets.get_mut(&data_len).unwrap(); data_len_set.insert(id); - - result.push(share); + ids.push(id); } // Validate threshold @@ -107,7 +106,10 @@ pub(crate) fn validate_shares(shares: Vec) -> Result<(u8, Vec) } } - Ok((threshold, result)) + // It is safe to unwrap because data_len_sets == 1 + let slen = data_len_compatibility_sets.keys().last().unwrap().to_owned(); + + Ok((threshold, data_len)) } pub(crate) fn validate_share_count(threshold: u8, shares_count: u8) -> Result<(u8, u8)> { diff --git a/src/sss/scheme.rs b/src/sss/scheme.rs index d5021ba..4072c91 100644 --- a/src/sss/scheme.rs +++ b/src/sss/scheme.rs @@ -93,9 +93,8 @@ impl SSS { /// /// At least `k` distinct shares need to be provided to recover the share. pub fn recover_secret(shares: Vec, verify_signatures: bool) -> Result> { - let (threshold, shares) = validate_signed_shares(shares, verify_signatures)?; + let (threshold, slen) = validate_signed_shares(&shares, verify_signatures)?; - let slen = shares[0].data.len(); let mut col_in = Vec::with_capacity(threshold as usize); let mut secret = Vec::with_capacity(slen); for byteindex in 0..slen { From 2df49c5254eb95f4abba3bd2639eba5f9ae9d29e Mon Sep 17 00:00:00 2001 From: Noah Vesely Date: Wed, 28 Mar 2018 18:55:08 -0600 Subject: [PATCH 19/35] Standardize validation var identifier on --- src/share/validation.rs | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/share/validation.rs b/src/share/validation.rs index 8a256b1..0395da0 100644 --- a/src/share/validation.rs +++ b/src/share/validation.rs @@ -33,16 +33,20 @@ pub(crate) fn validate_shares(shares: &Vec) -> Result<(u8, usize) let mut ids = Vec::with_capacity(shares_count); let mut k_compatibility_sets = HashMap::new(); - let mut data_len_compatibility_sets = HashMap::new(); + let mut slen_compatibility_sets = HashMap::new(); for share in shares { - let (id, threshold, data_len) = (share.get_id(), share.get_threshold(), share.get_data().len()); + let (id, threshold, slen) = ( + share.get_id(), + share.get_threshold(), + share.get_data().len(), + ); if id < 1 { bail!(ErrorKind::ShareParsingInvalidShareId(id)) } else if threshold < 2 { bail!(ErrorKind::ShareParsingInvalidShareThreshold(threshold, id)) - } else if data_len < 1 { + } else if slen < 1 { bail!(ErrorKind::ShareParsingErrorEmptyShare(id)) } @@ -56,11 +60,11 @@ pub(crate) fn validate_shares(shares: &Vec) -> Result<(u8, usize) bail!(ErrorKind::DuplicateShareId(id)); } - data_len_compatibility_sets - .entry(data_len) + slen_compatibility_sets + .entry(slen) .or_insert_with(HashSet::new); - let data_len_set = data_len_compatibility_sets.get_mut(&data_len).unwrap(); - data_len_set.insert(id); + let slen_set = slen_compatibility_sets.get_mut(&slen).unwrap(); + slen_set.insert(id); ids.push(id); } @@ -90,14 +94,14 @@ pub(crate) fn validate_shares(shares: &Vec) -> Result<(u8, usize) } // Validate share length consistency - let data_len_sets = data_len_compatibility_sets.keys().count(); + let slen_sets = slen_compatibility_sets.keys().count(); - match data_len_sets { + match slen_sets { 1 => {} // All shares have the same `data` field len _ => { bail! { ErrorKind::IncompatibleDataLengths( - data_len_compatibility_sets + slen_compatibility_sets .values() .map(|x| x.to_owned()) .collect(), @@ -106,10 +110,10 @@ pub(crate) fn validate_shares(shares: &Vec) -> Result<(u8, usize) } } - // It is safe to unwrap because data_len_sets == 1 - let slen = data_len_compatibility_sets.keys().last().unwrap().to_owned(); + // It is safe to unwrap because slen_sets == 1 + let slen = slen_compatibility_sets.keys().last().unwrap().to_owned(); - Ok((threshold, data_len)) + Ok((threshold, slen)) } pub(crate) fn validate_share_count(threshold: u8, shares_count: u8) -> Result<(u8, u8)> { From 88134181e1a603d66d2b730cb11b6b37380ca753 Mon Sep 17 00:00:00 2001 From: Noah Vesely Date: Thu, 29 Mar 2018 00:39:24 -0600 Subject: [PATCH 20/35] Simplify share threshold and secret length consistency validation I think that using hashmaps and hash sets was overkill and made the code much longer and complicated than it needed to be. The new code also produces more useful error messages that will hopefully help users identify which share(s) are causing the inconsistency. --- src/errors.rs | 21 ++++++----- src/share/validation.rs | 81 +++++++++++----------------------------- tests/recovery_errors.rs | 15 +++++++- 3 files changed, 46 insertions(+), 71 deletions(-) diff --git a/src/errors.rs b/src/errors.rs index 40fe950..b05605e 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -59,16 +59,6 @@ error_chain! { display("The shares are incompatible with each other.") } - IncompatibleThresholds(sets: Vec>) { - description("The shares are incompatible with each other because they do not all have the same threshold.") - display("The shares are incompatible with each other because they do not all have the same threshold.") - } - - IncompatibleDataLengths(sets: Vec>) { - description("The shares are incompatible with each other because they do not all have the same share data length.") - display("The shares are incompatible with each other because they do not all have the same share data length.") - } - MissingShares(provided: usize, required: u8) { description("The number of shares provided is insufficient to recover the secret.") display("{} shares are required to recover the secret, found only {}.", required, provided) @@ -133,10 +123,21 @@ error_chain! { display("This share number ({}) has already been used by a previous share.", share_id) } + InconsistentSecretLengths(id: u8, slen_: usize, ids: Vec, slen: usize) { + description("The shares are incompatible with each other because they do not all have the same secret length.") + display("The share identifier {} had secret length {}, while the secret length {} was found for share identifier(s): {:?}.", id, slen_, slen, ids) + } + InconsistentShares { description("The shares are inconsistent") display("The shares are inconsistent") } + + InconsistentThresholds(id: u8, k_: u8, ids: Vec, k: u8) { + description("The shares are incompatible with each other because they do not all have the same threshold.") + display("The share identifier {} had k = {}, while k = {} was found for share identifier(s): {:?}.", id, k_, k, ids) + } + } foreign_links { diff --git a/src/share/validation.rs b/src/share/validation.rs index 0395da0..9b4e158 100644 --- a/src/share/validation.rs +++ b/src/share/validation.rs @@ -1,5 +1,3 @@ -use std::collections::{HashMap, HashSet}; - use errors::*; use share::{IsShare, IsSignedShare}; @@ -32,11 +30,11 @@ pub(crate) fn validate_shares(shares: &Vec) -> Result<(u8, usize) let shares_count = shares.len(); let mut ids = Vec::with_capacity(shares_count); - let mut k_compatibility_sets = HashMap::new(); - let mut slen_compatibility_sets = HashMap::new(); + let mut threshold = 0; + let mut slen = 0; for share in shares { - let (id, threshold, slen) = ( + let (id, threshold_, slen_) = ( share.get_id(), share.get_threshold(), share.get_data().len(), @@ -44,75 +42,40 @@ pub(crate) fn validate_shares(shares: &Vec) -> Result<(u8, usize) if id < 1 { bail!(ErrorKind::ShareParsingInvalidShareId(id)) - } else if threshold < 2 { + } else if threshold_ < 2 { bail!(ErrorKind::ShareParsingInvalidShareThreshold(threshold, id)) - } else if slen < 1 { + } else if slen_ < 1 { bail!(ErrorKind::ShareParsingErrorEmptyShare(id)) } - k_compatibility_sets - .entry(threshold) - .or_insert_with(HashSet::new); - let k_set = k_compatibility_sets.get_mut(&threshold).unwrap(); - k_set.insert(id); - if ids.iter().any(|&x| x == id) { bail!(ErrorKind::DuplicateShareId(id)); } - slen_compatibility_sets - .entry(slen) - .or_insert_with(HashSet::new); - let slen_set = slen_compatibility_sets.get_mut(&slen).unwrap(); - slen_set.insert(id); - - ids.push(id); - } - - // Validate threshold - let k_sets = k_compatibility_sets.keys().count(); - - match k_sets { - 1 => {} // All shares have the same roothash. - _ => { - bail! { - ErrorKind::IncompatibleThresholds( - k_compatibility_sets - .values() - .map(|x| x.to_owned()) - .collect(), - ) - } + if threshold == 0 { + threshold = threshold_; + } else if threshold_ != threshold { + bail!(ErrorKind::InconsistentThresholds( + id, + threshold_, + ids, + threshold + )) } - } - // It is safe to unwrap because k_sets == 1 - let threshold = k_compatibility_sets.keys().last().unwrap().to_owned(); + if slen == 0 { + slen = slen_; + } else if slen_ != slen { + bail!(ErrorKind::InconsistentSecretLengths(id, slen_, ids, slen)) + } - if shares_count < threshold as usize { - bail!(ErrorKind::MissingShares(shares_count, threshold)); + ids.push(id); } - // Validate share length consistency - let slen_sets = slen_compatibility_sets.keys().count(); - - match slen_sets { - 1 => {} // All shares have the same `data` field len - _ => { - bail! { - ErrorKind::IncompatibleDataLengths( - slen_compatibility_sets - .values() - .map(|x| x.to_owned()) - .collect(), - ) - } - } + if shares_count < threshold as usize { + bail!(ErrorKind::MissingShares(shares_count, threshold)) } - // It is safe to unwrap because slen_sets == 1 - let slen = slen_compatibility_sets.keys().last().unwrap().to_owned(); - Ok((threshold, slen)) } diff --git a/tests/recovery_errors.rs b/tests/recovery_errors.rs index c8f13e1..fa862f3 100644 --- a/tests/recovery_errors.rs +++ b/tests/recovery_errors.rs @@ -67,8 +67,8 @@ fn test_recover_duplicate_shares_number() { } #[test] -#[should_panic(expected = "IncompatibleDataLengths")] -fn test_recover_incompatible_data_lengths() { +#[should_panic(expected = "InconsistentSecretLengths")] +fn test_recover_inconsistent_secret_lengths() { let share1 = "2-1-CgnlCxRNtnkzENE".to_string(); let share2 = "2-2-ChbG46L1zRszs0PPn63XnnupmZTcgYJ3".to_string(); @@ -77,6 +77,17 @@ fn test_recover_incompatible_data_lengths() { recover_secret(&shares, false).unwrap(); } +#[test] +#[should_panic(expected = "InconsistentThresholds")] +fn test_inconsistent_thresholds() { + let share1 = "2-1-CgnlCxRNtnkzENE".to_string(); + let share2 = "3-2-CgkAnUgP3lfwjyM".to_string(); + + let shares = vec![share1, share2]; + + recover_secret(&shares, false).unwrap(); +} + #[test] #[should_panic(expected = "MissingShares")] fn test_recover_too_few_shares() { From 07de9be1ff0283c20b766680d7ef53bc4740f872 Mon Sep 17 00:00:00 2001 From: Noah Vesely Date: Thu, 29 Mar 2018 01:22:54 -0600 Subject: [PATCH 21/35] Validation consistency between format & validation modules The best place to catch share problems is immediately during parsing from `&str`, however, because `validate_shares` takes any type that implements the `IsShare` trait, and there's nothing about that trait that guarantees that the share id, threshold, and secret length will be valid, I thought it best to leave those three tests in `validate_shares` as a defensive coding practice. --- src/share/validation.rs | 3 +++ src/sss/format.rs | 12 ++++++------ tests/recovery_errors.rs | 15 +++++++++------ 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/share/validation.rs b/src/share/validation.rs index 9b4e158..d7d302f 100644 --- a/src/share/validation.rs +++ b/src/share/validation.rs @@ -40,6 +40,9 @@ pub(crate) fn validate_shares(shares: &Vec) -> Result<(u8, usize) share.get_data().len(), ); + // Public-facing `Share::share_from_string` performs these three tests, but in case another + // type which implements `IsShare` is implemented later that doesn't do that validation, + // we'll leave them. if id < 1 { bail!(ErrorKind::ShareParsingInvalidShareId(id)) } else if threshold_ < 2 { diff --git a/src/sss/format.rs b/src/sss/format.rs index 0e7c3ea..142ae8b 100644 --- a/src/sss/format.rs +++ b/src/sss/format.rs @@ -49,12 +49,12 @@ pub(crate) fn share_from_string(s: &str, is_signed: bool) -> Result { (k, i, p3) }; - if k < 1 || i < 1 { - bail! { - ErrorKind::ShareParsingError( - format!("Found illegal share info: threshold = {}, identifier = {}.", k, i), - ) - } + if i < 1 { + bail!(ErrorKind::ShareParsingInvalidShareId(i)) + } else if k < 2 { + bail!(ErrorKind::ShareParsingInvalidShareThreshold(k, i)) + } else if p3.is_empty() { + bail!(ErrorKind::ShareParsingErrorEmptyShare(i)) } let raw_data = base64::decode_config(p3, BASE64_CONFIG).chain_err(|| { diff --git a/tests/recovery_errors.rs b/tests/recovery_errors.rs index fa862f3..0e1e8f5 100644 --- a/tests/recovery_errors.rs +++ b/tests/recovery_errors.rs @@ -11,6 +11,13 @@ fn test_recover_no_shares() { } } +#[test] +#[should_panic(expected = "ShareParsingErrorEmptyShare")] +fn test_share_parsing_error_empty_share() { + let shares = vec!["2-1-".to_string()]; + recover_secret(&shares, false).unwrap(); +} + #[test] #[should_panic(expected = "ShareParsingError")] fn test_recover_2_parts_share() { @@ -34,13 +41,9 @@ fn test_recover_incorrect_share_num() { } #[test] -#[should_panic(expected = "ShareParsingError")] +#[should_panic(expected = "ShareParsingInvalidShareId")] fn test_recover_0_share_num() { - let share1 = "2-0-1YAYwmOHqZ69jA".to_string(); - let share2 = "2-1-YJZQDGm22Y77Gw".to_string(); - - let shares = vec![share1, share2]; - + let shares = vec!["2-0-1YAYwmOHqZ69jA".to_string()]; recover_secret(&shares, false).unwrap(); } From 463d42b014a8c60bb0dbd3084a7c3f60e5d42f62 Mon Sep 17 00:00:00 2001 From: Noah Vesely Date: Thu, 29 Mar 2018 01:26:44 -0600 Subject: [PATCH 22/35] Minor improvement to validation --- src/share/validation.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/share/validation.rs b/src/share/validation.rs index d7d302f..57794b9 100644 --- a/src/share/validation.rs +++ b/src/share/validation.rs @@ -34,11 +34,9 @@ pub(crate) fn validate_shares(shares: &Vec) -> Result<(u8, usize) let mut slen = 0; for share in shares { - let (id, threshold_, slen_) = ( - share.get_id(), - share.get_threshold(), - share.get_data().len(), - ); + let id = share.get_id(); + let threshold_ = share.get_threshold(); + let slen_ = share.get_data().len(); // Public-facing `Share::share_from_string` performs these three tests, but in case another // type which implements `IsShare` is implemented later that doesn't do that validation, @@ -75,6 +73,8 @@ pub(crate) fn validate_shares(shares: &Vec) -> Result<(u8, usize) ids.push(id); } + // Only once the threshold is confirmed as consistent should we determine if shares are + // missing. if shares_count < threshold as usize { bail!(ErrorKind::MissingShares(shares_count, threshold)) } From a6ff8a7b95a0a37c6fb8cebb5eb92e8e1aebde6f Mon Sep 17 00:00:00 2001 From: Noah Vesely Date: Thu, 29 Mar 2018 02:53:57 -0600 Subject: [PATCH 23/35] Adds `no_more_than_five` formatter This should be useful when validating very large sets of shares. Wouldn't want to print out up to 254 shares. --- src/errors.rs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/errors.rs b/src/errors.rs index b05605e..1fbe12b 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -3,6 +3,7 @@ #![allow(unknown_lints, missing_docs)] use std::collections::HashSet; +use std::fmt; #[cfg(feature = "dss")] use dss::ss1; @@ -125,7 +126,7 @@ error_chain! { InconsistentSecretLengths(id: u8, slen_: usize, ids: Vec, slen: usize) { description("The shares are incompatible with each other because they do not all have the same secret length.") - display("The share identifier {} had secret length {}, while the secret length {} was found for share identifier(s): {:?}.", id, slen_, slen, ids) + display("The share identifier {} had secret length {}, while the secret length {} was found for share identifier(s): {}.", id, slen_, slen, no_more_than_five(ids)) } InconsistentShares { @@ -135,7 +136,7 @@ error_chain! { InconsistentThresholds(id: u8, k_: u8, ids: Vec, k: u8) { description("The shares are incompatible with each other because they do not all have the same threshold.") - display("The share identifier {} had k = {}, while k = {} was found for share identifier(s): {:?}.", id, k_, k, ids) + display("The share identifier {} had k = {}, while k = {} was found for share identifier(s): {}.", id, k_, k, no_more_than_five(ids)) } } @@ -145,3 +146,19 @@ error_chain! { IntegerParsingError(::std::num::ParseIntError); } } + +/// Takes a `Vec` and formats it like the normal `fmt::Debug` implementation, unless it has more +//than five elements, in which case the rest are replaced by ellipsis. +fn no_more_than_five(vec: &Vec) -> String { + let len = vec.len(); + if len > 5 { + let mut string = String::from("["); + for item in vec.iter().take(5) { + string += &format!("{}, ", item); + } + string.push_str("...]"); + string + } else { + format!("{:?}", vec) + } +} From 12cefb1d18ed0ccd8059e4b993ea66a959a40c10 Mon Sep 17 00:00:00 2001 From: Noah Vesely Date: Mon, 2 Apr 2018 15:02:10 -0500 Subject: [PATCH 24/35] Rustfmt updates + refactor Travis configuration (#60) * Update rustfmt compliance Looks like rustfmt has made some improvements recently, so wanted to bring the code up to date. * Add rustfmt to nightly item in Travis matrix * Use Travis Cargo cache * Allow fast_finish in Travis Items that match the `allow_failures` predicate (right now, just Rust nightly), will still finish, but Travis won't wait for them to report a result if the other builds have already finished. * Run kcov in a separate matrix build in Travis * Rework allowed_failures logic We don't want rustfmt to match `allow_failures` just because it needs to use nightly, while we do want nightly to match `allow_failures`. Env vars provide a solution. * Add --all switch to rustfmt Travis * Test building docs in Travis * Use exact Ubuntu dependencies listed for kcov Some of the dependencies we were installing were not listed on https://github.com/SimonKagstrom/kcov/blob/master/INSTALL.md, and we were missing one dependency that was listed there. When `sudo: true` Travis uses Ubuntu Trusty. * No need to build before running kcov kcov builds its own test executables. * Generate `Cargo.lock` w/ `cargo update` before running kcov As noted in aeb3906cce8e3e26c7bc80d6aec417b365f3d2f1 it is not necessary to build the project before running kcov, but kcov does require a `Cargo.lock` file, which can be generated with `cargo update`. --- .travis.yml | 56 +++++++++++++++++++++-------------- benches/ss1.rs | 22 +++++++++----- benches/sss.rs | 10 +++---- benches/thss.rs | 10 +++---- benches/wrapped_secrets.rs | 16 +++++----- build.rs | 4 +-- src/dss/format.rs | 2 +- src/dss/metadata.rs | 2 +- src/dss/mod.rs | 2 +- src/dss/ss1/mod.rs | 2 +- src/dss/ss1/scheme.rs | 16 +++++----- src/dss/ss1/serialize.rs | 4 +-- src/dss/ss1/share.rs | 2 +- src/dss/thss/scheme.rs | 6 ++-- src/dss/thss/serialize.rs | 4 +-- src/dss/thss/share.rs | 2 +- src/dss/utils.rs | 2 +- src/gf256.rs | 13 ++++---- src/lagrange.rs | 2 +- src/lib.rs | 6 ++-- src/sss/format.rs | 4 +-- src/sss/scheme.rs | 8 ++--- src/sss/share.rs | 4 +-- src/wrapped_secrets/scheme.rs | 4 +-- 24 files changed, 114 insertions(+), 89 deletions(-) diff --git a/.travis.yml b/.travis.yml index 13be6b3..cd35f73 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,38 +1,50 @@ - -sudo: required - language: rust +cache: cargo # https://docs.travis-ci.com/user/caching/#Rust-Cargo-cache rust: - stable - beta - - nightly matrix: + # Since this item is allowed to fail, don't wait for it's result to mark the + # build complete. + fast_finish: true allow_failures: - - rust: nightly + - env: NAME='nightly' + - env: NAME='kcov' + include: + - env: NAME='nightly' + rust: nightly + - env: NAME='rustfmt' + rust: nightly + before_script: + - rustup component add rustfmt-preview + script: + - cargo fmt --all -- --write-mode=diff + - env: NAME='kcov' + sudo: required # travis-ci/travis-ci#9061 + before_script: + - cargo install cargo-update || echo "cargo-update already installed" + - cargo install cargo-kcov || echo "cargo-kcov already installed" + - cargo install-update -a + script: + - cargo kcov --print-install-kcov-sh | sh + - cargo update # Creates `Cargo.lock` needed by next command + - cargo kcov --verbose --features dss --coveralls -- --verify --exclude-pattern=/.cargo,/usr/lib,src/proto + addons: + apt: + packages: + - libcurl4-openssl-dev + - libdw-dev + - binutils-dev + - libiberty-dev + - zlib1g-dev env: global: - RUSTFLAGS="-C link-dead-code" -addons: - apt: - packages: - - libcurl4-openssl-dev - - libdw-dev - - cmake - - g++ - - pkg-config - - binutils-dev - - libiberty-dev - script: - cargo build --verbose --all-features - cargo test --verbose --all-features - -after_success: - - cargo install cargo-kcov - - cargo kcov --print-install-kcov-sh | sh - - cargo kcov --verbose --features dss --coveralls -- --verify --exclude-pattern=/.cargo,/usr/lib,src/proto - + - cargo doc --verbose --all-features diff --git a/benches/ss1.rs b/benches/ss1.rs index d32b72b..f6e993a 100644 --- a/benches/ss1.rs +++ b/benches/ss1.rs @@ -10,29 +10,37 @@ mod shared; mod ss1 { use rusty_secrets::dss::ss1; - use test::{black_box, Bencher}; use shared; + use test::{black_box, Bencher}; macro_rules! bench_generate { - ($name:ident, $k:expr, $n:expr, $secret:ident) => ( + ($name:ident, $k:expr, $n:expr, $secret:ident) => { #[bench] fn $name(b: &mut Bencher) { let secret = shared::$secret(); b.iter(move || { - let shares = ss1::split_secret($k, $n, &secret, ss1::Reproducibility::reproducible(), &None).unwrap(); + let shares = ss1::split_secret( + $k, + $n, + &secret, + ss1::Reproducibility::reproducible(), + &None, + ).unwrap(); black_box(shares); }); } - ) + }; } macro_rules! bench_recover { - ($name:ident, $k:expr, $n:expr, $secret:ident) => ( + ($name:ident, $k:expr, $n:expr, $secret:ident) => { #[bench] fn $name(b: &mut Bencher) { let secret = shared::$secret(); - let all_shares = ss1::split_secret($k, $n, &secret, ss1::Reproducibility::reproducible(), &None).unwrap(); + let all_shares = + ss1::split_secret($k, $n, &secret, ss1::Reproducibility::reproducible(), &None) + .unwrap(); let shares = &all_shares.into_iter().take($k).collect::>().clone(); b.iter(|| { @@ -40,7 +48,7 @@ mod ss1 { black_box(result); }); } - ) + }; } bench_generate!(generate_1kb_3_5, 3, 5, secret_1kb); diff --git a/benches/sss.rs b/benches/sss.rs index b48b6aa..65ead56 100644 --- a/benches/sss.rs +++ b/benches/sss.rs @@ -8,12 +8,12 @@ mod shared; mod sss { - use test::{black_box, Bencher}; use rusty_secrets::sss; use shared; + use test::{black_box, Bencher}; macro_rules! bench_generate { - ($name:ident, $k:expr, $n:expr, $secret:ident, $signed:expr) => ( + ($name:ident, $k:expr, $n:expr, $secret:ident, $signed:expr) => { #[bench] fn $name(b: &mut Bencher) { let secret = shared::$secret(); @@ -23,11 +23,11 @@ mod sss { black_box(shares); }); } - ) + }; } macro_rules! bench_recover { - ($name:ident, $k:expr, $n:expr, $secret:ident, $signed:expr) => ( + ($name:ident, $k:expr, $n:expr, $secret:ident, $signed:expr) => { #[bench] fn $name(b: &mut Bencher) { let secret = shared::$secret(); @@ -39,7 +39,7 @@ mod sss { black_box(result); }); } - ) + }; } bench_generate!(generate_1kb_3_5, 3, 5, secret_1kb, false); diff --git a/benches/thss.rs b/benches/thss.rs index b11386b..c4dd97d 100644 --- a/benches/thss.rs +++ b/benches/thss.rs @@ -10,11 +10,11 @@ mod shared; mod thss { use rusty_secrets::dss::thss; - use test::{black_box, Bencher}; use shared; + use test::{black_box, Bencher}; macro_rules! bench_generate { - ($name:ident, $k:expr, $n:expr, $secret:ident) => ( + ($name:ident, $k:expr, $n:expr, $secret:ident) => { #[bench] fn $name(b: &mut Bencher) { let secret = shared::$secret(); @@ -24,11 +24,11 @@ mod thss { black_box(shares); }); } - ) + }; } macro_rules! bench_recover { - ($name:ident, $k:expr, $n:expr, $secret:ident) => ( + ($name:ident, $k:expr, $n:expr, $secret:ident) => { #[bench] fn $name(b: &mut Bencher) { let secret = shared::$secret(); @@ -40,7 +40,7 @@ mod thss { black_box(result); }); } - ) + }; } bench_generate!(generate_1kb_3_5, 3, 5, secret_1kb); diff --git a/benches/wrapped_secrets.rs b/benches/wrapped_secrets.rs index 627f376..af57141 100644 --- a/benches/wrapped_secrets.rs +++ b/benches/wrapped_secrets.rs @@ -8,30 +8,32 @@ mod shared; mod wrapped_secrets { - use test::{black_box, Bencher}; use rusty_secrets::wrapped_secrets; use shared; + use test::{black_box, Bencher}; macro_rules! bench_generate { - ($name:ident, $k:expr, $n:expr, $secret:ident, $signed:expr) => ( + ($name:ident, $k:expr, $n:expr, $secret:ident, $signed:expr) => { #[bench] fn $name(b: &mut Bencher) { let secret = shared::$secret(); b.iter(move || { - let shares = wrapped_secrets::split_secret($k, $n, secret, None, $signed).unwrap(); + let shares = + wrapped_secrets::split_secret($k, $n, secret, None, $signed).unwrap(); black_box(shares); }); } - ) + }; } macro_rules! bench_recover { - ($name:ident, $k:expr, $n:expr, $secret:ident, $signed:expr) => ( + ($name:ident, $k:expr, $n:expr, $secret:ident, $signed:expr) => { #[bench] fn $name(b: &mut Bencher) { let secret = shared::$secret(); - let all_shares = wrapped_secrets::split_secret($k, $n, &secret, None, $signed).unwrap(); + let all_shares = + wrapped_secrets::split_secret($k, $n, &secret, None, $signed).unwrap(); let shares = all_shares.into_iter().take($k).collect::>(); b.iter(|| { @@ -39,7 +41,7 @@ mod wrapped_secrets { black_box(result); }); } - ) + }; } bench_generate!(generate_1kb_3_5, 3, 5, secret_1kb, false); diff --git a/build.rs b/build.rs index b47873e..a4d5019 100644 --- a/build.rs +++ b/build.rs @@ -1,9 +1,9 @@ use std::env; +use std::fmt; use std::fs::File; use std::io::Write; -use std::path::Path; -use std::fmt; use std::num::Wrapping; +use std::path::Path; const POLY: u8 = 0x1D; diff --git a/src/dss/format.rs b/src/dss/format.rs index 70669b5..c4d0386 100644 --- a/src/dss/format.rs +++ b/src/dss/format.rs @@ -1,7 +1,7 @@ use std::error::Error; -use protobuf::{self, Message}; use base64; +use protobuf::{self, Message}; use errors::*; use proto::dss::ShareProto; diff --git a/src/dss/metadata.rs b/src/dss/metadata.rs index 86c3f92..fa11f24 100644 --- a/src/dss/metadata.rs +++ b/src/dss/metadata.rs @@ -1,5 +1,5 @@ -use std::collections::BTreeMap; use ring::digest; +use std::collections::BTreeMap; /// A share's public metadata. #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord, Default)] diff --git a/src/dss/mod.rs b/src/dss/mod.rs index ab45caa..f7739d2 100644 --- a/src/dss/mod.rs +++ b/src/dss/mod.rs @@ -27,8 +27,8 @@ //! **ErrDet** | An inauthentic set of shares produced by an adversary will be flagged as such when fed to the recovery algorithm. //! **Repro** | Share reproducible: The scheme can produce shares in a deterministic way. -pub mod thss; pub mod ss1; +pub mod thss; mod metadata; diff --git a/src/dss/ss1/mod.rs b/src/dss/ss1/mod.rs index 78335d2..18a4b06 100644 --- a/src/dss/ss1/mod.rs +++ b/src/dss/ss1/mod.rs @@ -29,8 +29,8 @@ mod share; pub use self::share::*; mod scheme; -use self::scheme::SS1; pub use self::scheme::Reproducibility; +use self::scheme::SS1; use dss::AccessStructure; diff --git a/src/dss/ss1/scheme.rs b/src/dss/ss1/scheme.rs index 9672e5e..49c9e4e 100644 --- a/src/dss/ss1/scheme.rs +++ b/src/dss/ss1/scheme.rs @@ -1,17 +1,17 @@ use std::collections::HashSet; -use ring::{hkdf, hmac}; -use ring::rand::{SecureRandom, SystemRandom}; -use ring::digest::{Context, SHA256}; use rand::{ChaChaRng, Rng, SeedableRng}; +use ring::digest::{Context, SHA256}; +use ring::rand::{SecureRandom, SystemRandom}; +use ring::{hkdf, hmac}; -use errors::*; -use dss::{thss, AccessStructure}; -use dss::thss::{MetaData, ThSS}; -use dss::random::{random_bytes_count, FixedRandom, MAX_MESSAGE_SIZE}; -use share::validation::{validate_share_count, validate_shares}; use super::share::*; +use dss::random::{random_bytes_count, FixedRandom, MAX_MESSAGE_SIZE}; +use dss::thss::{MetaData, ThSS}; use dss::utils; +use dss::{thss, AccessStructure}; +use errors::*; +use share::validation::{validate_share_count, validate_shares}; use vol_hash::VOLHash; /// We bound the message size at about 16MB to avoid overflow in `random_bytes_count`. diff --git a/src/dss/ss1/serialize.rs b/src/dss/ss1/serialize.rs index ca040df..15b48d9 100644 --- a/src/dss/ss1/serialize.rs +++ b/src/dss/ss1/serialize.rs @@ -1,8 +1,8 @@ -use errors::*; use super::{MetaData, Share}; use dss::format::{format_share_protobuf, parse_share_protobuf}; -use proto::dss::{MetaDataProto, ShareProto}; use dss::utils::{btreemap_to_hashmap, hashmap_to_btreemap}; +use errors::*; +use proto::dss::{MetaDataProto, ShareProto}; pub(crate) fn share_to_string(share: Share) -> String { let proto = share_to_protobuf(share); diff --git a/src/dss/ss1/share.rs b/src/dss/ss1/share.rs index 4ca4178..d1f6fcc 100644 --- a/src/dss/ss1/share.rs +++ b/src/dss/ss1/share.rs @@ -1,6 +1,6 @@ +use super::serialize::{share_from_string, share_to_string}; use errors::*; use share::IsShare; -use super::serialize::{share_from_string, share_to_string}; pub use dss::metadata::MetaData; diff --git a/src/dss/thss/scheme.rs b/src/dss/thss/scheme.rs index 141c932..e7d0d1e 100644 --- a/src/dss/thss/scheme.rs +++ b/src/dss/thss/scheme.rs @@ -4,15 +4,15 @@ use std::fmt; use ring::rand::{SecureRandom, SystemRandom}; +use dss::random::{random_bytes, random_bytes_count, MAX_MESSAGE_SIZE}; use errors::*; use gf256::Gf256; -use dss::random::{random_bytes, random_bytes_count, MAX_MESSAGE_SIZE}; -use share::validation::{validate_share_count, validate_shares}; use lagrange; +use share::validation::{validate_share_count, validate_shares}; use super::AccessStructure; -use super::share::*; use super::encode::encode_secret; +use super::share::*; /// We bound the message size at about 16MB to avoid overflow in `random_bytes_count`. /// Moreover, given the current performances, it is almost unpractical to run diff --git a/src/dss/thss/serialize.rs b/src/dss/thss/serialize.rs index 7190934..1111f55 100644 --- a/src/dss/thss/serialize.rs +++ b/src/dss/thss/serialize.rs @@ -1,8 +1,8 @@ -use errors::*; use super::{MetaData, Share}; use dss::format::{format_share_protobuf, parse_share_protobuf}; -use proto::dss::{MetaDataProto, ShareProto}; use dss::utils::{btreemap_to_hashmap, hashmap_to_btreemap}; +use errors::*; +use proto::dss::{MetaDataProto, ShareProto}; pub(crate) fn share_to_string(share: Share) -> String { let proto = share_to_protobuf(share); diff --git a/src/dss/thss/share.rs b/src/dss/thss/share.rs index 15a942b..f68bf15 100644 --- a/src/dss/thss/share.rs +++ b/src/dss/thss/share.rs @@ -1,6 +1,6 @@ +use super::serialize::{share_from_string, share_to_string}; use errors::*; use share::IsShare; -use super::serialize::{share_from_string, share_to_string}; pub use dss::metadata::MetaData; diff --git a/src/dss/utils.rs b/src/dss/utils.rs index 59a2362..20a0fed 100644 --- a/src/dss/utils.rs +++ b/src/dss/utils.rs @@ -1,7 +1,7 @@ use std; -use std::hash::Hash; use std::collections::{BTreeMap, HashMap}; +use std::hash::Hash; /// Transmutes a `&[u8]` into a `&[u32]`. /// Despite `std::mem::transmute` being very unsafe in diff --git a/src/gf256.rs b/src/gf256.rs index 23546d9..49ad57e 100644 --- a/src/gf256.rs +++ b/src/gf256.rs @@ -143,7 +143,9 @@ impl Neg for Gf256 { #[macro_export] #[doc(hidden)] macro_rules! gf256 { - ($e:expr) => (Gf256::from_byte($e)) + ($e:expr) => { + Gf256::from_byte($e) + }; } #[macro_export] @@ -178,10 +180,10 @@ mod tests { mod vectors { use super::*; + use flate2::read::GzDecoder; + use itertools::Itertools; use std::fs::File; use std::io::{BufRead, BufReader}; - use itertools::Itertools; - use flate2::read::GzDecoder; macro_rules! mk_test { ($id:ident, $op:expr, $val:expr) => { @@ -196,7 +198,8 @@ mod tests { }); let ref_path = format!("tests/fixtures/gf256/gf256_{}.txt.gz", stringify!($id)); - let reference = BufReader::new(GzDecoder::new(File::open(ref_path).unwrap()).unwrap()); + let reference = + BufReader::new(GzDecoder::new(File::open(ref_path).unwrap()).unwrap()); for ((i, j, k), line) in results.zip(reference.lines()) { let left = format!("{} {} {} = {}", i, $op, j, k); @@ -204,7 +207,7 @@ mod tests { assert_eq!(left, right); } } - } + }; } mk_test!(add, "+", |i: Gf256, j: Gf256| i + j); diff --git a/src/lagrange.rs b/src/lagrange.rs index 4118818..b49a91f 100644 --- a/src/lagrange.rs +++ b/src/lagrange.rs @@ -86,10 +86,10 @@ pub(crate) fn interpolate(points: &[(Gf256, Gf256)]) -> Poly { #[allow(trivial_casts)] mod tests { - use std; use super::*; use gf256::*; use quickcheck::*; + use std; quickcheck! { diff --git a/src/lib.rs b/src/lib.rs index 4b88428..90d5c3c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -18,15 +18,15 @@ extern crate ring; #[macro_use] mod gf256; -mod share; -mod poly; mod lagrange; +mod poly; +mod share; mod vol_hash; pub mod errors; +pub mod proto; pub mod sss; pub mod wrapped_secrets; -pub mod proto; #[cfg(feature = "dss")] pub mod dss; diff --git a/src/sss/format.rs b/src/sss/format.rs index 142ae8b..e6cb2a7 100644 --- a/src/sss/format.rs +++ b/src/sss/format.rs @@ -1,9 +1,9 @@ +use base64; use errors::*; use merkle_sigs::{MerklePublicKey, Proof, PublicKey}; +use proto::wrapped::ShareProto; use protobuf::{self, Message, RepeatedField}; -use base64; use sss::{Share, HASH_ALGO}; -use proto::wrapped::ShareProto; use std::error::Error; const BASE64_CONFIG: base64::Config = base64::STANDARD_NO_PAD; diff --git a/src/sss/scheme.rs b/src/sss/scheme.rs index 4072c91..836bec6 100644 --- a/src/sss/scheme.rs +++ b/src/sss/scheme.rs @@ -1,13 +1,13 @@ //! SSS provides Shamir's secret sharing with raw data. -use rand::{OsRng, Rng}; use merkle_sigs::sign_data_vec; +use rand::{OsRng, Rng}; use errors::*; -use sss::{Share, HASH_ALGO}; -use sss::format::format_share_for_signing; -use share::validation::{validate_share_count, validate_signed_shares}; use lagrange::interpolate_at; +use share::validation::{validate_share_count, validate_signed_shares}; +use sss::format::format_share_for_signing; +use sss::{Share, HASH_ALGO}; use super::encode::encode_secret_byte; diff --git a/src/sss/share.rs b/src/sss/share.rs index f46ad67..e3ff1ca 100644 --- a/src/sss/share.rs +++ b/src/sss/share.rs @@ -1,8 +1,8 @@ -use std::error::Error; use std::collections::{HashMap, HashSet}; +use std::error::Error; -use merkle_sigs::{MerklePublicKey, Proof}; use merkle_sigs::verify_data_vec_signature; +use merkle_sigs::{MerklePublicKey, Proof}; use errors::*; use share::{IsShare, IsSignedShare}; diff --git a/src/wrapped_secrets/scheme.rs b/src/wrapped_secrets/scheme.rs index 40c50f8..f3a5896 100644 --- a/src/wrapped_secrets/scheme.rs +++ b/src/wrapped_secrets/scheme.rs @@ -1,8 +1,8 @@ use errors::*; +use proto::VersionProto; +use proto::wrapped::SecretProto; use protobuf; use protobuf::Message; -use proto::wrapped::SecretProto; -use proto::VersionProto; use sss::SSS; pub(crate) use sss::Share; From a96c806ddbdc426418bb7d23d7f7b2336fb9152c Mon Sep 17 00:00:00 2001 From: Romain Ruetschi Date: Mon, 16 Apr 2018 21:18:13 +0200 Subject: [PATCH 25/35] Add rust-toolchain file --- rust-toolchain | 1 + 1 file changed, 1 insertion(+) create mode 100644 rust-toolchain diff --git a/rust-toolchain b/rust-toolchain new file mode 100644 index 0000000..f9e8384 --- /dev/null +++ b/rust-toolchain @@ -0,0 +1 @@ +1.24.1 From 3d7bf8dc4759dfd1cc5da88d9d11f32314f345c7 Mon Sep 17 00:00:00 2001 From: Romain Ruetschi Date: Mon, 16 Apr 2018 21:22:01 +0200 Subject: [PATCH 26/35] Add EditorConfig configuration file --- .editorconfig | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..3a8d3f7 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,16 @@ +# EditorConfig helps developers define and maintain consistent +# coding styles between different editors and IDEs +# editorconfig.org + +root = true + +[*] +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true +indent_style = space +indent_size = 4 + +[*.md] +trim_trailing_whitespace = false From 288d70478b91afa1de64cac638f7a9102fc0be9d Mon Sep 17 00:00:00 2001 From: Romain Ruetschi Date: Mon, 16 Apr 2018 21:23:16 +0200 Subject: [PATCH 27/35] Add back Cargo.lock Although RustySecrets is a library, it is important that all contributors to the library are using the very same version of every package, as we cannot always trust downstream deps to follow SemVer to the letter. --- .gitignore | 4 - Cargo.lock | 452 +++++++++++++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 2 + 3 files changed, 454 insertions(+), 4 deletions(-) create mode 100644 Cargo.lock diff --git a/.gitignore b/.gitignore index 7316468..236c55b 100644 --- a/.gitignore +++ b/.gitignore @@ -2,10 +2,6 @@ # Will have compiled files and executables /target/ -# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries -# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock -Cargo.lock - # These are backup files generated by rustfmt **/*.rs.bk diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..843a0b8 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,452 @@ +[[package]] +name = "aho-corasick" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "arrayvec" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "nodrop 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "base64" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "byteorder 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "safemem 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "bitflags" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "byteorder" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "cc" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "cfg-if" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "crossbeam-deque" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "crossbeam-epoch 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "nodrop 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "crossbeam-utils" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "either" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "env_logger" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "error-chain" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "flate2" +version = "0.2.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", + "miniz-sys 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "fuchsia-zircon" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "fuchsia-zircon-sys" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "gcc" +version = "0.3.54" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "itertools" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "kernel32-sys" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "lamport_sigs" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", + "ring 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "lazy_static" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "lazy_static" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "libc" +version = "0.2.40" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "log" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "log" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "memchr" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "memoffset" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "merkle" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "protobuf 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "ring 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "merkle_sigs" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lamport_sigs 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "merkle 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ring 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "miniz-sys" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cc 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "nodrop" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "num_cpus" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "protobuf" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "quickcheck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "env_logger 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand" +version = "0.3.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rayon" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rayon-core 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rayon-core" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "regex" +version = "0.1.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "aho-corasick 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "thread_local 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "regex-syntax" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "ring" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", + "rayon 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", + "untrusted 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rusty_secrets" +version = "0.2.2-pre" +dependencies = [ + "base64 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "flate2 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", + "itertools 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)", + "merkle_sigs 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "quickcheck 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "ring 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "safemem" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "scopeguard" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "thread-id" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "thread_local" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "thread-id 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "untrusted" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "utf8-ranges" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "winapi" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "winapi" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "winapi-build" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[metadata] +"checksum aho-corasick 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ca972c2ea5f742bfce5687b9aef75506a764f61d37f8f649047846a9686ddb66" +"checksum arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "a1e964f9e24d588183fcb43503abda40d288c8657dfc27311516ce2f05675aef" +"checksum base64 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "229d032f1a99302697f10b27167ae6d03d49d032e6a8e2550e8d3fc13356d2b4" +"checksum bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b3c30d3802dfb7281680d6285f2ccdaa8c2d8fee41f93805dba5c4cf50dc23cf" +"checksum byteorder 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "73b5bdfe7ee3ad0b99c9801d58807a9dbc9e09196365b0203853b99889ab3c87" +"checksum cc 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "2b4911e4bdcb4100c7680e7e854ff38e23f1b34d4d9e079efae3da2801341ffc" +"checksum cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d4c819a1287eb618df47cc647173c5c4c66ba19d888a6e50d605672aed3140de" +"checksum crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f739f8c5363aca78cfb059edf753d8f0d36908c348f3d8d1503f03d8b75d9cf3" +"checksum crossbeam-epoch 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "927121f5407de9956180ff5e936fe3cf4324279280001cd56b669d28ee7e9150" +"checksum crossbeam-utils 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2760899e32a1d58d5abb31129f8fae5de75220bc2176e77ff7c627ae45c918d9" +"checksum either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3be565ca5c557d7f59e7cfcf1844f9e3033650c929c6566f511e8005f205c1d0" +"checksum env_logger 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "15abd780e45b3ea4f76b4e9a26ff4843258dd8a3eed2775a0e7368c2e7936c2f" +"checksum error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ff511d5dc435d703f4971bc399647c9bc38e20cb41452e3b9feb4765419ed3f3" +"checksum flate2 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)" = "e6234dd4468ae5d1e2dbb06fe2b058696fdc50a339c68a393aefbf00bc81e423" +"checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" +"checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" +"checksum gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)" = "5e33ec290da0d127825013597dbdfc28bee4964690c7ce1166cbc2a7bd08b1bb" +"checksum itertools 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)" = "f58856976b776fedd95533137617a02fb25719f40e7d9b01c7043cd65474f450" +"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" +"checksum lamport_sigs 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5dff26ae558be16afda65815c847447c81eede19c639982e49e33bd15973d857" +"checksum lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73" +"checksum lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c8f31047daa365f19be14b47c29df4f7c3b581832407daabe6ae77397619237d" +"checksum libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)" = "6fd41f331ac7c5b8ac259b8bf82c75c0fb2e469bbf37d2becbba9a6a2221965b" +"checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b" +"checksum log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "89f010e843f2b1a31dbd316b3b8d443758bc634bed37aabade59c686d644e0a2" +"checksum memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d8b629fb514376c675b98c1421e80b151d3817ac42d7c667717d282761418d20" +"checksum memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0f9dc261e2b62d7a622bf416ea3c5245cdd5d9a7fcc428c0d06804dfce1775b3" +"checksum merkle 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a6311caa1c5c71548021dfc5f6113fca485d453185fdc44da92bafe266f6a5fe" +"checksum merkle_sigs 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "94367864019d3b781c28c67d0a7057da0df498525982869c47ecfd73ece29f26" +"checksum miniz-sys 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "609ce024854aeb19a0ef7567d348aaa5a746b32fb72e336df7fcc16869d7e2b4" +"checksum nodrop 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "9a2228dca57108069a5262f2ed8bd2e82496d2e074a06d1ccc7ce1687b6ae0a2" +"checksum num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c51a3322e4bca9d212ad9a158a02abc6934d005490c054a2778df73a70aa0a30" +"checksum protobuf 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "40e2484e639dcae0985fc483ad76ce7ad78ee5aa092751d7d538f0b20d76486b" +"checksum quickcheck 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "02c2411d418cea2364325b18a205664f9ef8252e06b2e911db97c0b0d98b1406" +"checksum rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "15a732abf9d20f0ad8eeb6f909bf6868722d9a06e1e50802b6a70351f40b4eb1" +"checksum rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "eba5f8cb59cc50ed56be8880a5c7b496bfd9bd26394e176bc67884094145c2c5" +"checksum rayon 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b614fe08b6665cb9a231d07ac1364b0ef3cb3698f1239ee0c4c3a88a524f54c8" +"checksum rayon-core 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9d24ad214285a7729b174ed6d3bcfcb80177807f959d95fafd5bfc5c4f201ac8" +"checksum regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)" = "4fd4ace6a8cf7860714a2c2280d6c1f7e6a413486c13298bbc86fd3da019402f" +"checksum regex-syntax 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "f9ec002c35e86791825ed294b50008eea9ddfc8def4420124fbc6b08db834957" +"checksum ring 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6f7d28b30a72c01b458428e0ae988d4149c20d902346902be881e3edc4bb325c" +"checksum safemem 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e27a8b19b835f7aea908818e871f5cc3a5a186550c30773be987e155e8163d8f" +"checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" +"checksum thread-id 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a9539db560102d1cef46b8b78ce737ff0bb64e7e18d35b2a5688f7d097d0ff03" +"checksum thread_local 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "8576dbbfcaef9641452d5cf0df9b0e7eeab7694956dd33bb61515fb8f18cfdd5" +"checksum untrusted 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f392d7819dbe58833e26872f5f6f0d68b7bbbe90fc3667e98731c4a15ad9a7ae" +"checksum utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a1ca13c08c41c9c3e04224ed9ff80461d97e121589ff27c753a16cb10830ae0f" +"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" +"checksum winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "04e3bd221fcbe8a271359c04f21a76db7d0c6028862d1bb5512d85e1e2eb5bb3" +"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" +"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/Cargo.toml b/Cargo.toml index 4da5b1a..afc1403 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,6 +13,8 @@ license = "BSD-3-Clause" readme = "README.md" build = "build.rs" +exclude = ["Cargo.lock"] + [badges] travis-ci = { repository = "SpinResearch/RustySecrets", branch = "master" } coveralls = { repository = "SpinResearch/RustySecrets", branch = "master", service = "github" } From 625f5e3cbbec3479a9fd9e553d06de45a2666261 Mon Sep 17 00:00:00 2001 From: Romain Ruetschi Date: Mon, 16 Apr 2018 21:23:55 +0200 Subject: [PATCH 28/35] Add @nvesely to the list of authors --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.toml b/Cargo.toml index afc1403..a9f19fb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,6 +5,7 @@ authors = [ "Frederic Jacobs ", "Romain Ruetschi ", "Dylan Bourgeois ", + "Noah Vesely ", "sellibitze" ] description = "Implementation of threshold Shamir's secret sharing in the Rust programming language." From c5ac23ae90fcd66f73a8103879a06bbe701f8c86 Mon Sep 17 00:00:00 2001 From: Romain Ruetschi Date: Mon, 16 Apr 2018 21:25:02 +0200 Subject: [PATCH 29/35] Add license name to README, and update year --- LICENSE | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/LICENSE b/LICENSE index b2e6f8f..aab64d9 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ BSD 3-Clause License -Copyright (c) 2016, Spin Research +Copyright (c) 2016-2018, Spin Research All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/README.md b/README.md index 4b6451f..e6a7a1b 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ any security vulnerability in this code privately to anybody.** ## License -See [LICENSE](LICENSE). +RustySecrets is distributed under the BSD 3-Clause license. See the [LICENSE](LICENSE) file for more information. ## Vocabulary From 4cdf06d245b1105f0cdb1ec56a7824a15dda6e25 Mon Sep 17 00:00:00 2001 From: Eyal Kalderon Date: Fri, 4 May 2018 16:52:41 +0800 Subject: [PATCH 30/35] Add support for custom RNGs in SSS and WrappedSecrets (#64) --- Cargo.toml | 1 + src/sss/mod.rs | 36 +++++++++++++++++++++++- src/sss/scheme.rs | 17 +++++++---- src/wrapped_secrets/mod.rs | 53 ++++++++++++++++++++++++++++++++++- src/wrapped_secrets/scheme.rs | 6 ++-- 5 files changed, 103 insertions(+), 10 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a9f19fb..4c0c981 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -39,6 +39,7 @@ default-features = false itertools = "^0.7" quickcheck = "^0.4" flate2 = "^0.2" +rand = "^0.4.2" [profile.bench] opt-level = 3 diff --git a/src/sss/mod.rs b/src/sss/mod.rs index 7709d1b..20505ea 100644 --- a/src/sss/mod.rs +++ b/src/sss/mod.rs @@ -13,11 +13,14 @@ pub(crate) use self::scheme::*; mod encode; +use rand::{OsRng, Rng}; use ring::digest::{Algorithm, SHA512}; static HASH_ALGO: &'static Algorithm = &SHA512; /// Performs threshold k-out-of-n Shamir's secret sharing. /// +/// Uses a `rand::OsRng` as a source of entropy. +/// /// # Examples /// /// ``` @@ -37,7 +40,38 @@ static HASH_ALGO: &'static Algorithm = &SHA512; /// ``` pub fn split_secret(k: u8, n: u8, secret: &[u8], sign_shares: bool) -> Result> { SSS::default() - .split_secret(k, n, secret, sign_shares) + .split_secret(&mut OsRng::new()?, k, n, secret, sign_shares) + .map(|shares| shares.into_iter().map(Share::into_string).collect()) +} + +/// Performs threshold k-out-of-n Shamir's secret sharing with a custom RNG. +/// +/// # Examples +/// +/// ``` +/// use rusty_secrets::sss::split_secret; +/// +/// let secret = "These programs were never about terrorism: they’re about economic spying, \ +/// social control, and diplomatic manipulation. They’re about power."; +/// +/// match split_secret(7, 10, &secret.as_bytes(), true) { +/// Ok(shares) => { +/// // Do something with the shares +/// }, +/// Err(_) => { +/// // Deal with error +/// } +/// } +/// ``` +pub fn split_secret_rng( + rng: &mut R, + k: u8, + n: u8, + secret: &[u8], + sign_shares: bool, +) -> Result> { + SSS::default() + .split_secret(rng, k, n, secret, sign_shares) .map(|shares| shares.into_iter().map(Share::into_string).collect()) } diff --git a/src/sss/scheme.rs b/src/sss/scheme.rs index 836bec6..3cbc8e6 100644 --- a/src/sss/scheme.rs +++ b/src/sss/scheme.rs @@ -1,7 +1,7 @@ //! SSS provides Shamir's secret sharing with raw data. use merkle_sigs::sign_data_vec; -use rand::{OsRng, Rng}; +use rand::Rng; use errors::*; use lagrange::interpolate_at; @@ -17,15 +17,16 @@ pub(crate) struct SSS; impl SSS { /// Performs threshold k-out-of-n Shamir's secret sharing. - pub fn split_secret( + pub fn split_secret( &self, + rng: &mut R, threshold: u8, shares_count: u8, secret: &[u8], sign_shares: bool, ) -> Result> { let (threshold, shares_count) = validate_share_count(threshold, shares_count)?; - let shares = Self::secret_share(secret, threshold, shares_count)?; + let shares = Self::secret_share(rng, secret, threshold, shares_count)?; let signatures = if sign_shares { let shares_to_sign = shares @@ -67,19 +68,23 @@ impl SSS { Ok(result.collect()) } - fn secret_share(src: &[u8], threshold: u8, shares_count: u8) -> Result>> { + fn secret_share( + rng: &mut R, + src: &[u8], + threshold: u8, + shares_count: u8, + ) -> Result>> { let mut result = Vec::with_capacity(shares_count as usize); for _ in 0..(shares_count as usize) { result.push(vec![0u8; src.len()]); } let mut col_in = vec![0u8; threshold as usize]; let mut col_out = Vec::with_capacity(shares_count as usize); - let mut osrng = OsRng::new()?; for (c, &s) in src.iter().enumerate() { col_in[0] = s; // NOTE: switch to `try_fill_bytes` when it lands in a stable release: // https://github.com/rust-lang-nursery/rand/commit/230b2258dbd99ff8bd991008c972d923d4b5d10c - osrng.fill_bytes(&mut col_in[1..]); + rng.fill_bytes(&mut col_in[1..]); col_out.clear(); encode_secret_byte(&*col_in, shares_count, &mut col_out)?; for (&y, share) in col_out.iter().zip(result.iter_mut()) { diff --git a/src/wrapped_secrets/mod.rs b/src/wrapped_secrets/mod.rs index 3a797fd..5be7e08 100644 --- a/src/wrapped_secrets/mod.rs +++ b/src/wrapped_secrets/mod.rs @@ -3,11 +3,15 @@ use errors::*; use proto::wrapped::SecretProto; +use rand::{OsRng, Rng}; + mod scheme; pub(crate) use self::scheme::*; /// Performs threshold k-out-of-n Shamir's secret sharing. /// +/// Uses an `OsRng` as a source of entropy. +/// /// # Examples /// /// ``` @@ -41,7 +45,54 @@ pub fn split_secret( sign_shares: bool, ) -> Result> { WrappedSecrets::default() - .split_secret(k, n, secret, mime_type, sign_shares) + .split_secret(&mut OsRng::new()?, k, n, secret, mime_type, sign_shares) + .map(|shares| shares.into_iter().map(Share::into_string).collect()) +} + +/// Performs threshold k-out-of-n Shamir's secret sharing with a custom RNG. +/// +/// # Examples +/// +/// ``` +/// # extern crate rusty_secrets; +/// # extern crate rand; +/// # +/// # fn main() { +/// use rusty_secrets::wrapped_secrets::split_secret_rng; +/// use rand::ChaChaRng; +/// +/// let secret = "These programs were never about terrorism: they’re about economic spying, \ +/// social control, and diplomatic manipulation. They’re about power."; +/// +/// let result = split_secret_rng( +/// &mut ChaChaRng::new_unseeded(), +/// 7, +/// 10, +/// &secret.as_bytes(), +/// Some("text/html".to_string()), +/// true, +/// ); +/// +/// match result { +/// Ok(shares) => { +/// // Do something with the shares +/// }, +/// Err(_) => { +/// // Deal with error +/// } +/// } +/// # } +/// ``` +pub fn split_secret_rng( + rng: &mut R, + k: u8, + n: u8, + secret: &[u8], + mime_type: Option, + sign_shares: bool, +) -> Result> { + WrappedSecrets::default() + .split_secret(rng, k, n, secret, mime_type, sign_shares) .map(|shares| shares.into_iter().map(Share::into_string).collect()) } diff --git a/src/wrapped_secrets/scheme.rs b/src/wrapped_secrets/scheme.rs index f3a5896..a704e39 100644 --- a/src/wrapped_secrets/scheme.rs +++ b/src/wrapped_secrets/scheme.rs @@ -3,6 +3,7 @@ use proto::VersionProto; use proto::wrapped::SecretProto; use protobuf; use protobuf::Message; +use rand::Rng; use sss::SSS; pub(crate) use sss::Share; @@ -12,8 +13,9 @@ pub(crate) struct WrappedSecrets; impl WrappedSecrets { /// Performs threshold k-out-of-n Shamir's secret sharing. - pub fn split_secret( + pub fn split_secret( &self, + rng: &mut R, k: u8, n: u8, secret: &[u8], @@ -30,7 +32,7 @@ impl WrappedSecrets { let data = rusty_secret.write_to_bytes().unwrap(); - SSS::default().split_secret(k, n, data.as_slice(), sign_shares) + SSS::default().split_secret(rng, k, n, data.as_slice(), sign_shares) } /// Recovers the secret from a k-out-of-n Shamir's secret sharing. From 83651a295b04bcaf9a0336305c0a9a382b3a9ebf Mon Sep 17 00:00:00 2001 From: Eyal Kalderon Date: Fri, 4 May 2018 17:45:58 +0800 Subject: [PATCH 31/35] Correct copy-pasted doc comment for split_secret_rng --- src/sss/mod.rs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/sss/mod.rs b/src/sss/mod.rs index 20505ea..1cb8f3a 100644 --- a/src/sss/mod.rs +++ b/src/sss/mod.rs @@ -49,12 +49,26 @@ pub fn split_secret(k: u8, n: u8, secret: &[u8], sign_shares: bool) -> Result ChaChaRng { +/// # let mut rng = ChaChaRng::new_unseeded(); +/// # rng.set_counter(42, 42); +/// # rng +/// # } +/// # +/// # fn main() { +/// use rusty_secrets::sss::split_secret_rng; /// /// let secret = "These programs were never about terrorism: they’re about economic spying, \ /// social control, and diplomatic manipulation. They’re about power."; /// -/// match split_secret(7, 10, &secret.as_bytes(), true) { +/// let mut rng = some_custom_rng(); +/// +/// match split_secret_rng(&mut rng, 7, 10, &secret.as_bytes(), true) { /// Ok(shares) => { /// // Do something with the shares /// }, @@ -62,6 +76,7 @@ pub fn split_secret(k: u8, n: u8, secret: &[u8], sign_shares: bool) -> Result( rng: &mut R, From cbf6dcc02c0868840c494f83278e5cc66f655c8c Mon Sep 17 00:00:00 2001 From: Romain Ruetschi Date: Fri, 11 May 2018 16:50:52 +0200 Subject: [PATCH 32/35] Fix wrong validation of threshold Fortunately as both MIN_SHARES and MIN_THRESHOLD are both set to 2 in errors.rs, the typo had no impact on validation correctness. --- src/share/validation.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/share/validation.rs b/src/share/validation.rs index 57794b9..1b894cf 100644 --- a/src/share/validation.rs +++ b/src/share/validation.rs @@ -83,7 +83,7 @@ pub(crate) fn validate_shares(shares: &Vec) -> Result<(u8, usize) } pub(crate) fn validate_share_count(threshold: u8, shares_count: u8) -> Result<(u8, u8)> { - if threshold < MIN_SHARES { + if threshold < MIN_THRESHOLD { bail!(ErrorKind::ThresholdTooSmall(threshold)); } if shares_count > MAX_SHARES { From 380af14aa604cf8fd485d8b384358887ab9a7f06 Mon Sep 17 00:00:00 2001 From: Ding Xiang Fei Date: Thu, 17 May 2018 18:01:47 +0800 Subject: [PATCH 33/35] * Remove auto-generated schemata * Build schemata with `protoc_rust` in `build.rs` `protoc_rust` is added as a build dependency. It is used to trans-compile `.proto` schemata into Rust source. `build.rs` will put the trans-compiled schemata in place. --- Cargo.lock | 452 --------------------------------- Cargo.toml | 5 +- build.rs | 45 +++- src/proto/dss/metadata.rs | 253 ------------------ src/proto/dss/secret.rs | 369 --------------------------- src/proto/dss/share.rs | 492 ------------------------------------ src/proto/version.rs | 100 -------- src/proto/wrapped/secret.rs | 328 ------------------------ src/proto/wrapped/share.rs | 333 ------------------------ 9 files changed, 47 insertions(+), 2330 deletions(-) delete mode 100644 Cargo.lock delete mode 100644 src/proto/dss/metadata.rs delete mode 100644 src/proto/dss/secret.rs delete mode 100644 src/proto/dss/share.rs delete mode 100644 src/proto/version.rs delete mode 100644 src/proto/wrapped/secret.rs delete mode 100644 src/proto/wrapped/share.rs diff --git a/Cargo.lock b/Cargo.lock deleted file mode 100644 index 843a0b8..0000000 --- a/Cargo.lock +++ /dev/null @@ -1,452 +0,0 @@ -[[package]] -name = "aho-corasick" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "arrayvec" -version = "0.4.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "nodrop 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "base64" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "byteorder 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "safemem 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "bitflags" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "byteorder" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "cc" -version = "1.0.9" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "cfg-if" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "crossbeam-deque" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "crossbeam-epoch 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "crossbeam-epoch" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "nodrop 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "crossbeam-utils" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "either" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "env_logger" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "error-chain" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "flate2" -version = "0.2.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", - "miniz-sys 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "fuchsia-zircon" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "fuchsia-zircon-sys" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "gcc" -version = "0.3.54" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "itertools" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "kernel32-sys" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "lamport_sigs" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", - "ring 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "lazy_static" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "lazy_static" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "libc" -version = "0.2.40" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "log" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "log" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "memchr" -version = "0.1.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "memoffset" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "merkle" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "protobuf 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "ring 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "merkle_sigs" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "lamport_sigs 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "merkle 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ring 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "miniz-sys" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cc 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "nodrop" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "num_cpus" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "protobuf" -version = "1.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "quickcheck" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "env_logger 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand" -version = "0.3.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rayon" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rayon-core 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rayon-core" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "regex" -version = "0.1.80" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "aho-corasick 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "thread_local 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "regex-syntax" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "ring" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", - "rayon 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", - "untrusted 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rusty_secrets" -version = "0.2.2-pre" -dependencies = [ - "base64 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "flate2 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", - "itertools 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)", - "merkle_sigs 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "protobuf 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "quickcheck 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "ring 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "safemem" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "scopeguard" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "thread-id" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "thread_local" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "thread-id 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "untrusted" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "utf8-ranges" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "winapi" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "winapi" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "winapi-build" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[metadata] -"checksum aho-corasick 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ca972c2ea5f742bfce5687b9aef75506a764f61d37f8f649047846a9686ddb66" -"checksum arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "a1e964f9e24d588183fcb43503abda40d288c8657dfc27311516ce2f05675aef" -"checksum base64 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "229d032f1a99302697f10b27167ae6d03d49d032e6a8e2550e8d3fc13356d2b4" -"checksum bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b3c30d3802dfb7281680d6285f2ccdaa8c2d8fee41f93805dba5c4cf50dc23cf" -"checksum byteorder 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "73b5bdfe7ee3ad0b99c9801d58807a9dbc9e09196365b0203853b99889ab3c87" -"checksum cc 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "2b4911e4bdcb4100c7680e7e854ff38e23f1b34d4d9e079efae3da2801341ffc" -"checksum cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d4c819a1287eb618df47cc647173c5c4c66ba19d888a6e50d605672aed3140de" -"checksum crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f739f8c5363aca78cfb059edf753d8f0d36908c348f3d8d1503f03d8b75d9cf3" -"checksum crossbeam-epoch 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "927121f5407de9956180ff5e936fe3cf4324279280001cd56b669d28ee7e9150" -"checksum crossbeam-utils 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2760899e32a1d58d5abb31129f8fae5de75220bc2176e77ff7c627ae45c918d9" -"checksum either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3be565ca5c557d7f59e7cfcf1844f9e3033650c929c6566f511e8005f205c1d0" -"checksum env_logger 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "15abd780e45b3ea4f76b4e9a26ff4843258dd8a3eed2775a0e7368c2e7936c2f" -"checksum error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ff511d5dc435d703f4971bc399647c9bc38e20cb41452e3b9feb4765419ed3f3" -"checksum flate2 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)" = "e6234dd4468ae5d1e2dbb06fe2b058696fdc50a339c68a393aefbf00bc81e423" -"checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" -"checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" -"checksum gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)" = "5e33ec290da0d127825013597dbdfc28bee4964690c7ce1166cbc2a7bd08b1bb" -"checksum itertools 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)" = "f58856976b776fedd95533137617a02fb25719f40e7d9b01c7043cd65474f450" -"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" -"checksum lamport_sigs 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5dff26ae558be16afda65815c847447c81eede19c639982e49e33bd15973d857" -"checksum lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73" -"checksum lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c8f31047daa365f19be14b47c29df4f7c3b581832407daabe6ae77397619237d" -"checksum libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)" = "6fd41f331ac7c5b8ac259b8bf82c75c0fb2e469bbf37d2becbba9a6a2221965b" -"checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b" -"checksum log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "89f010e843f2b1a31dbd316b3b8d443758bc634bed37aabade59c686d644e0a2" -"checksum memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d8b629fb514376c675b98c1421e80b151d3817ac42d7c667717d282761418d20" -"checksum memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0f9dc261e2b62d7a622bf416ea3c5245cdd5d9a7fcc428c0d06804dfce1775b3" -"checksum merkle 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a6311caa1c5c71548021dfc5f6113fca485d453185fdc44da92bafe266f6a5fe" -"checksum merkle_sigs 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "94367864019d3b781c28c67d0a7057da0df498525982869c47ecfd73ece29f26" -"checksum miniz-sys 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "609ce024854aeb19a0ef7567d348aaa5a746b32fb72e336df7fcc16869d7e2b4" -"checksum nodrop 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "9a2228dca57108069a5262f2ed8bd2e82496d2e074a06d1ccc7ce1687b6ae0a2" -"checksum num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c51a3322e4bca9d212ad9a158a02abc6934d005490c054a2778df73a70aa0a30" -"checksum protobuf 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "40e2484e639dcae0985fc483ad76ce7ad78ee5aa092751d7d538f0b20d76486b" -"checksum quickcheck 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "02c2411d418cea2364325b18a205664f9ef8252e06b2e911db97c0b0d98b1406" -"checksum rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "15a732abf9d20f0ad8eeb6f909bf6868722d9a06e1e50802b6a70351f40b4eb1" -"checksum rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "eba5f8cb59cc50ed56be8880a5c7b496bfd9bd26394e176bc67884094145c2c5" -"checksum rayon 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b614fe08b6665cb9a231d07ac1364b0ef3cb3698f1239ee0c4c3a88a524f54c8" -"checksum rayon-core 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9d24ad214285a7729b174ed6d3bcfcb80177807f959d95fafd5bfc5c4f201ac8" -"checksum regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)" = "4fd4ace6a8cf7860714a2c2280d6c1f7e6a413486c13298bbc86fd3da019402f" -"checksum regex-syntax 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "f9ec002c35e86791825ed294b50008eea9ddfc8def4420124fbc6b08db834957" -"checksum ring 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6f7d28b30a72c01b458428e0ae988d4149c20d902346902be881e3edc4bb325c" -"checksum safemem 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e27a8b19b835f7aea908818e871f5cc3a5a186550c30773be987e155e8163d8f" -"checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" -"checksum thread-id 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a9539db560102d1cef46b8b78ce737ff0bb64e7e18d35b2a5688f7d097d0ff03" -"checksum thread_local 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "8576dbbfcaef9641452d5cf0df9b0e7eeab7694956dd33bb61515fb8f18cfdd5" -"checksum untrusted 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f392d7819dbe58833e26872f5f6f0d68b7bbbe90fc3667e98731c4a15ad9a7ae" -"checksum utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a1ca13c08c41c9c3e04224ed9ff80461d97e121589ff27c753a16cb10830ae0f" -"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" -"checksum winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "04e3bd221fcbe8a271359c04f21a76db7d0c6028862d1bb5512d85e1e2eb5bb3" -"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" -"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" -"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/Cargo.toml b/Cargo.toml index 4c0c981..f6332b4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,7 +29,10 @@ base64 = "0.9.0" rand = "^0.4.2" ring = "^0.12" merkle_sigs = "^1.4" -protobuf = "^1.4" +protobuf = "^1.5" + +[build-dependencies] +protoc-rust = "1.5" [dependencies.error-chain] version = "0.11.0" diff --git a/build.rs b/build.rs index a4d5019..6e6d346 100644 --- a/build.rs +++ b/build.rs @@ -1,3 +1,4 @@ +extern crate protoc_rust; use std::env; use std::fmt; use std::fs::File; @@ -68,8 +69,25 @@ impl fmt::Display for Tables { } } -#[allow(unused_must_use)] -fn main() { +fn build_protobuf<'a>( + out_dir: &'a str, + input: &'a [&'a str], + includes: &'a [&'a str], +) { + use self::protoc_rust::{run, Args, Customize}; + run( + Args { + out_dir, + input, + includes, + customize: Customize { + ..Default::default() + }, + } + ).expect("protoc"); +} + +fn generate_gf256_table() { let out_dir = env::var("OUT_DIR").unwrap(); let dest = Path::new(&out_dir).join("nothinghardcoded.rs"); @@ -87,3 +105,26 @@ fn main() { generate_tables(&f); } + +#[allow(unused_must_use)] +fn main() { + generate_gf256_table(); + build_protobuf("src/proto", &["protobuf/version.proto"], &[]); + build_protobuf( + "src/proto/dss", + &[ + "protobuf/dss/metadata.proto", + "protobuf/dss/secret.proto", + "protobuf/dss/share.proto", + ], + &["protobuf", "protobuf/dss"] + ); + build_protobuf( + "src/proto/wrapped", + &[ + "protobuf/wrapped/secret.proto", + "protobuf/wrapped/share.proto" + ], + &["protobuf", "protobuf/dss"] + ); +} diff --git a/src/proto/dss/metadata.rs b/src/proto/dss/metadata.rs deleted file mode 100644 index 0b27f5d..0000000 --- a/src/proto/dss/metadata.rs +++ /dev/null @@ -1,253 +0,0 @@ -// This file is generated. Do not edit -// @generated - -// https://github.com/Manishearth/rust-clippy/issues/702 -#![allow(unknown_lints)] -#![allow(clippy)] - -#![cfg_attr(rustfmt, rustfmt_skip)] - -#![allow(box_pointers)] -#![allow(dead_code)] -#![allow(missing_docs)] -#![allow(non_camel_case_types)] -#![allow(non_snake_case)] -#![allow(non_upper_case_globals)] -#![allow(trivial_casts)] -#![allow(unsafe_code)] -#![allow(unused_imports)] -#![allow(unused_results)] - -use protobuf::Message as Message_imported_for_functions; -use protobuf::ProtobufEnum as ProtobufEnum_imported_for_functions; - -#[derive(PartialEq, Clone, Default)] -pub struct MetaDataProto { - // message fields - pub tags: ::std::collections::HashMap<::std::string::String, ::std::string::String>, - // special fields - unknown_fields: ::protobuf::UnknownFields, - cached_size: ::protobuf::CachedSize, -} - -// see codegen.rs for the explanation why impl Sync explicitly -unsafe impl ::std::marker::Sync for MetaDataProto {} - -impl MetaDataProto { - pub fn new() -> MetaDataProto { - ::std::default::Default::default() - } - - pub fn default_instance() -> &'static MetaDataProto { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const MetaDataProto, - }; - unsafe { instance.get(MetaDataProto::new) } - } - - // repeated .dss.MetaDataProto.TagsEntry tags = 1; - - pub fn clear_tags(&mut self) { - self.tags.clear(); - } - - // Param is passed by value, moved - pub fn set_tags( - &mut self, - v: ::std::collections::HashMap<::std::string::String, ::std::string::String>, - ) { - self.tags = v; - } - - // Mutable pointer to the field. - pub fn mut_tags( - &mut self, - ) -> &mut ::std::collections::HashMap<::std::string::String, ::std::string::String> { - &mut self.tags - } - - // Take field - pub fn take_tags( - &mut self, - ) -> ::std::collections::HashMap<::std::string::String, ::std::string::String> { - ::std::mem::replace(&mut self.tags, ::std::collections::HashMap::new()) - } - - pub fn get_tags( - &self, - ) -> &::std::collections::HashMap<::std::string::String, ::std::string::String> { - &self.tags - } - - fn get_tags_for_reflect( - &self, - ) -> &::std::collections::HashMap<::std::string::String, ::std::string::String> { - &self.tags - } - - fn mut_tags_for_reflect( - &mut self, - ) -> &mut ::std::collections::HashMap<::std::string::String, ::std::string::String> { - &mut self.tags - } -} - -impl ::protobuf::Message for MetaDataProto { - fn is_initialized(&self) -> bool { - true - } - - fn merge_from( - &mut self, - is: &mut ::protobuf::CodedInputStream, - ) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 1 => { - ::protobuf::rt::read_map_into::< - ::protobuf::types::ProtobufTypeString, - ::protobuf::types::ProtobufTypeString, - >(wire_type, is, &mut self.tags)?; - } - _ => { - ::protobuf::rt::read_unknown_or_skip_group( - field_number, - wire_type, - is, - self.mut_unknown_fields(), - )?; - } - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - my_size += ::protobuf::rt::compute_map_size::< - ::protobuf::types::ProtobufTypeString, - ::protobuf::types::ProtobufTypeString, - >(1, &self.tags); - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes( - &self, - os: &mut ::protobuf::CodedOutputStream, - ) -> ::protobuf::ProtobufResult<()> { - ::protobuf::rt::write_map_with_cached_sizes::< - ::protobuf::types::ProtobufTypeString, - ::protobuf::types::ProtobufTypeString, - >(1, &self.tags, os)?; - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - ::protobuf::MessageStatic::descriptor_static(None::) - } -} - -impl ::protobuf::MessageStatic for MetaDataProto { - fn new() -> MetaDataProto { - MetaDataProto::new() - } - - fn descriptor_static( - _: ::std::option::Option, - ) -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = - ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_map_accessor::<_, ::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeString>( - "tags", - MetaDataProto::get_tags_for_reflect, - MetaDataProto::mut_tags_for_reflect, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "MetaDataProto", - fields, - file_descriptor_proto() - ) - }) - } - } -} - -impl ::protobuf::Clear for MetaDataProto { - fn clear(&mut self) { - self.clear_tags(); - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for MetaDataProto { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for MetaDataProto { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -static file_descriptor_proto_data: &'static [u8] = b"\ - \n\x12dss/metadata.proto\x12\x03dss\"z\n\rMetaDataProto\x120\n\x04tags\ - \x18\x01\x20\x03(\x0b2\x1c.dss.MetaDataProto.TagsEntryR\x04tags\x1a7\n\t\ - TagsEntry\x12\x10\n\x03key\x18\x01\x20\x01(\tR\x03key\x12\x14\n\x05value\ - \x18\x02\x20\x01(\tR\x05value:\x028\x01Jz\n\x06\x12\x04\0\0\x06\x01\n\ - \x08\n\x01\x0c\x12\x03\0\0\x12\n\x08\n\x01\x02\x12\x03\x02\x08\x0b\n\n\n\ - \x02\x04\0\x12\x04\x04\0\x06\x01\n\n\n\x03\x04\0\x01\x12\x03\x04\x08\x15\ - \n\x0b\n\x04\x04\0\x02\0\x12\x03\x05\x02\x1f\n\r\n\x05\x04\0\x02\0\x04\ - \x12\x04\x05\x02\x04\x17\n\x0c\n\x05\x04\0\x02\0\x06\x12\x03\x05\x02\x15\ - \n\x0c\n\x05\x04\0\x02\0\x01\x12\x03\x05\x16\x1a\n\x0c\n\x05\x04\0\x02\0\ - \x03\x12\x03\x05\x1d\x1eb\x06proto3\ -"; - -static mut file_descriptor_proto_lazy: ::protobuf::lazy::Lazy<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::descriptor::FileDescriptorProto, -}; - -fn parse_descriptor_proto() -> ::protobuf::descriptor::FileDescriptorProto { - ::protobuf::parse_from_bytes(file_descriptor_proto_data).unwrap() -} - -pub fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto { - unsafe { file_descriptor_proto_lazy.get(|| parse_descriptor_proto()) } -} diff --git a/src/proto/dss/secret.rs b/src/proto/dss/secret.rs deleted file mode 100644 index 7b7a4c0..0000000 --- a/src/proto/dss/secret.rs +++ /dev/null @@ -1,369 +0,0 @@ -// This file is generated. Do not edit -// @generated - -// https://github.com/Manishearth/rust-clippy/issues/702 -#![allow(unknown_lints)] -#![allow(clippy)] - -#![cfg_attr(rustfmt, rustfmt_skip)] - -#![allow(box_pointers)] -#![allow(dead_code)] -#![allow(missing_docs)] -#![allow(non_camel_case_types)] -#![allow(non_snake_case)] -#![allow(non_upper_case_globals)] -#![allow(trivial_casts)] -#![allow(unsafe_code)] -#![allow(unused_imports)] -#![allow(unused_results)] - -use protobuf::Message as Message_imported_for_functions; -use protobuf::ProtobufEnum as ProtobufEnum_imported_for_functions; - -#[derive(PartialEq, Clone, Default)] -pub struct SecretProto { - // message fields - pub version: super::version::VersionProto, - pub secret: ::std::vec::Vec, - pub meta_data: ::protobuf::SingularPtrField, - // special fields - unknown_fields: ::protobuf::UnknownFields, - cached_size: ::protobuf::CachedSize, -} - -// see codegen.rs for the explanation why impl Sync explicitly -unsafe impl ::std::marker::Sync for SecretProto {} - -impl SecretProto { - pub fn new() -> SecretProto { - ::std::default::Default::default() - } - - pub fn default_instance() -> &'static SecretProto { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const SecretProto, - }; - unsafe { instance.get(SecretProto::new) } - } - - // .VersionProto version = 1; - - pub fn clear_version(&mut self) { - self.version = super::version::VersionProto::INITIAL_RELEASE; - } - - // Param is passed by value, moved - pub fn set_version(&mut self, v: super::version::VersionProto) { - self.version = v; - } - - pub fn get_version(&self) -> super::version::VersionProto { - self.version - } - - fn get_version_for_reflect(&self) -> &super::version::VersionProto { - &self.version - } - - fn mut_version_for_reflect(&mut self) -> &mut super::version::VersionProto { - &mut self.version - } - - // bytes secret = 2; - - pub fn clear_secret(&mut self) { - self.secret.clear(); - } - - // Param is passed by value, moved - pub fn set_secret(&mut self, v: ::std::vec::Vec) { - self.secret = v; - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_secret(&mut self) -> &mut ::std::vec::Vec { - &mut self.secret - } - - // Take field - pub fn take_secret(&mut self) -> ::std::vec::Vec { - ::std::mem::replace(&mut self.secret, ::std::vec::Vec::new()) - } - - pub fn get_secret(&self) -> &[u8] { - &self.secret - } - - fn get_secret_for_reflect(&self) -> &::std::vec::Vec { - &self.secret - } - - fn mut_secret_for_reflect(&mut self) -> &mut ::std::vec::Vec { - &mut self.secret - } - - // .dss.MetaDataProto meta_data = 3; - - pub fn clear_meta_data(&mut self) { - self.meta_data.clear(); - } - - pub fn has_meta_data(&self) -> bool { - self.meta_data.is_some() - } - - // Param is passed by value, moved - pub fn set_meta_data(&mut self, v: super::metadata::MetaDataProto) { - self.meta_data = ::protobuf::SingularPtrField::some(v); - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_meta_data(&mut self) -> &mut super::metadata::MetaDataProto { - if self.meta_data.is_none() { - self.meta_data.set_default(); - } - self.meta_data.as_mut().unwrap() - } - - // Take field - pub fn take_meta_data(&mut self) -> super::metadata::MetaDataProto { - self.meta_data.take().unwrap_or_else(|| { - super::metadata::MetaDataProto::new() - }) - } - - pub fn get_meta_data(&self) -> &super::metadata::MetaDataProto { - self.meta_data.as_ref().unwrap_or_else(|| { - super::metadata::MetaDataProto::default_instance() - }) - } - - fn get_meta_data_for_reflect( - &self, - ) -> &::protobuf::SingularPtrField { - &self.meta_data - } - - fn mut_meta_data_for_reflect( - &mut self, - ) -> &mut ::protobuf::SingularPtrField { - &mut self.meta_data - } -} - -impl ::protobuf::Message for SecretProto { - fn is_initialized(&self) -> bool { - for v in &self.meta_data { - if !v.is_initialized() { - return false; - } - } - true - } - - fn merge_from( - &mut self, - is: &mut ::protobuf::CodedInputStream, - ) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 1 => { - if wire_type != ::protobuf::wire_format::WireTypeVarint { - return ::std::result::Result::Err( - ::protobuf::rt::unexpected_wire_type(wire_type), - ); - } - let tmp = is.read_enum()?; - self.version = tmp; - } - 2 => { - ::protobuf::rt::read_singular_proto3_bytes_into( - wire_type, - is, - &mut self.secret, - )?; - } - 3 => { - ::protobuf::rt::read_singular_message_into(wire_type, is, &mut self.meta_data)?; - } - _ => { - ::protobuf::rt::read_unknown_or_skip_group( - field_number, - wire_type, - is, - self.mut_unknown_fields(), - )?; - } - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - if self.version != super::version::VersionProto::INITIAL_RELEASE { - my_size += ::protobuf::rt::enum_size(1, self.version); - } - if !self.secret.is_empty() { - my_size += ::protobuf::rt::bytes_size(2, &self.secret); - } - if let Some(ref v) = self.meta_data.as_ref() { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - } - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes( - &self, - os: &mut ::protobuf::CodedOutputStream, - ) -> ::protobuf::ProtobufResult<()> { - if self.version != super::version::VersionProto::INITIAL_RELEASE { - os.write_enum(1, self.version.value())?; - } - if !self.secret.is_empty() { - os.write_bytes(2, &self.secret)?; - } - if let Some(ref v) = self.meta_data.as_ref() { - os.write_tag( - 3, - ::protobuf::wire_format::WireTypeLengthDelimited, - )?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - } - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - ::protobuf::MessageStatic::descriptor_static(None::) - } -} - -impl ::protobuf::MessageStatic for SecretProto { - fn new() -> SecretProto { - SecretProto::new() - } - - fn descriptor_static( - _: ::std::option::Option, - ) -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = - ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeEnum>( - "version", - SecretProto::get_version_for_reflect, - SecretProto::mut_version_for_reflect, - )); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeBytes>( - "secret", - SecretProto::get_secret_for_reflect, - SecretProto::mut_secret_for_reflect, - )); - fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( - "meta_data", - SecretProto::get_meta_data_for_reflect, - SecretProto::mut_meta_data_for_reflect, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "SecretProto", - fields, - file_descriptor_proto() - ) - }) - } - } -} - -impl ::protobuf::Clear for SecretProto { - fn clear(&mut self) { - self.clear_version(); - self.clear_secret(); - self.clear_meta_data(); - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for SecretProto { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for SecretProto { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -static file_descriptor_proto_data: &'static [u8] = b"\ - \n\x10dss/secret.proto\x1a\rversion.proto\x1a\x12dss/metadata.proto\"\ - \x7f\n\x0bSecretProto\x12'\n\x07version\x18\x01\x20\x01(\x0e2\r.VersionP\ - rotoR\x07version\x12\x16\n\x06secret\x18\x02\x20\x01(\x0cR\x06secret\x12\ - /\n\tmeta_data\x18\x03\x20\x01(\x0b2\x12.dss.MetaDataProtoR\x08metaDataJ\ - \x92\x02\n\x06\x12\x04\0\0\t\x01\n\x08\n\x01\x0c\x12\x03\0\0\x12\n\t\n\ - \x02\x03\0\x12\x03\x02\x07\x16\n\t\n\x02\x03\x01\x12\x03\x03\x07\x1b\n\n\ - \n\x02\x04\0\x12\x04\x05\0\t\x01\n\n\n\x03\x04\0\x01\x12\x03\x05\x08\x13\ - \n\x0b\n\x04\x04\0\x02\0\x12\x03\x06\x08!\n\r\n\x05\x04\0\x02\0\x04\x12\ - \x04\x06\x08\x05\x15\n\x0c\n\x05\x04\0\x02\0\x06\x12\x03\x06\x08\x14\n\ - \x0c\n\x05\x04\0\x02\0\x01\x12\x03\x06\x15\x1c\n\x0c\n\x05\x04\0\x02\0\ - \x03\x12\x03\x06\x1f\x20\n\x0b\n\x04\x04\0\x02\x01\x12\x03\x07\x08\x19\n\ - \r\n\x05\x04\0\x02\x01\x04\x12\x04\x07\x08\x06!\n\x0c\n\x05\x04\0\x02\ - \x01\x05\x12\x03\x07\x08\r\n\x0c\n\x05\x04\0\x02\x01\x01\x12\x03\x07\x0e\ - \x14\n\x0c\n\x05\x04\0\x02\x01\x03\x12\x03\x07\x17\x18\n\x0b\n\x04\x04\0\ - \x02\x02\x12\x03\x08\x08(\n\r\n\x05\x04\0\x02\x02\x04\x12\x04\x08\x08\ - \x07\x19\n\x0c\n\x05\x04\0\x02\x02\x06\x12\x03\x08\x08\x19\n\x0c\n\x05\ - \x04\0\x02\x02\x01\x12\x03\x08\x1a#\n\x0c\n\x05\x04\0\x02\x02\x03\x12\ - \x03\x08&'b\x06proto3\ -"; - -static mut file_descriptor_proto_lazy: ::protobuf::lazy::Lazy<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::descriptor::FileDescriptorProto, -}; - -fn parse_descriptor_proto() -> ::protobuf::descriptor::FileDescriptorProto { - ::protobuf::parse_from_bytes(file_descriptor_proto_data).unwrap() -} - -pub fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto { - unsafe { file_descriptor_proto_lazy.get(|| parse_descriptor_proto()) } -} diff --git a/src/proto/dss/share.rs b/src/proto/dss/share.rs deleted file mode 100644 index 4eb8e40..0000000 --- a/src/proto/dss/share.rs +++ /dev/null @@ -1,492 +0,0 @@ -// This file is generated. Do not edit -// @generated - -// https://github.com/Manishearth/rust-clippy/issues/702 -#![allow(unknown_lints)] -#![allow(clippy)] - -#![cfg_attr(rustfmt, rustfmt_skip)] - -#![allow(box_pointers)] -#![allow(dead_code)] -#![allow(missing_docs)] -#![allow(non_camel_case_types)] -#![allow(non_snake_case)] -#![allow(non_upper_case_globals)] -#![allow(trivial_casts)] -#![allow(unsafe_code)] -#![allow(unused_imports)] -#![allow(unused_results)] - -use protobuf::Message as Message_imported_for_functions; -use protobuf::ProtobufEnum as ProtobufEnum_imported_for_functions; - -#[derive(PartialEq,Clone,Default)] -pub struct ShareProto { - // message fields - pub id: u32, - pub threshold: u32, - pub shares_count: u32, - pub data: ::std::vec::Vec, - pub hash: ::std::vec::Vec, - pub meta_data: ::protobuf::SingularPtrField, - // special fields - unknown_fields: ::protobuf::UnknownFields, - cached_size: ::protobuf::CachedSize, -} - -// see codegen.rs for the explanation why impl Sync explicitly -unsafe impl ::std::marker::Sync for ShareProto {} - -impl ShareProto { - pub fn new() -> ShareProto { - ::std::default::Default::default() - } - - pub fn default_instance() -> &'static ShareProto { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ShareProto, - }; - unsafe { - instance.get(ShareProto::new) - } - } - - // uint32 id = 1; - - pub fn clear_id(&mut self) { - self.id = 0; - } - - // Param is passed by value, moved - pub fn set_id(&mut self, v: u32) { - self.id = v; - } - - pub fn get_id(&self) -> u32 { - self.id - } - - fn get_id_for_reflect(&self) -> &u32 { - &self.id - } - - fn mut_id_for_reflect(&mut self) -> &mut u32 { - &mut self.id - } - - // uint32 threshold = 2; - - pub fn clear_threshold(&mut self) { - self.threshold = 0; - } - - // Param is passed by value, moved - pub fn set_threshold(&mut self, v: u32) { - self.threshold = v; - } - - pub fn get_threshold(&self) -> u32 { - self.threshold - } - - fn get_threshold_for_reflect(&self) -> &u32 { - &self.threshold - } - - fn mut_threshold_for_reflect(&mut self) -> &mut u32 { - &mut self.threshold - } - - // uint32 shares_count = 3; - - pub fn clear_shares_count(&mut self) { - self.shares_count = 0; - } - - // Param is passed by value, moved - pub fn set_shares_count(&mut self, v: u32) { - self.shares_count = v; - } - - pub fn get_shares_count(&self) -> u32 { - self.shares_count - } - - fn get_shares_count_for_reflect(&self) -> &u32 { - &self.shares_count - } - - fn mut_shares_count_for_reflect(&mut self) -> &mut u32 { - &mut self.shares_count - } - - // bytes data = 4; - - pub fn clear_data(&mut self) { - self.data.clear(); - } - - // Param is passed by value, moved - pub fn set_data(&mut self, v: ::std::vec::Vec) { - self.data = v; - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_data(&mut self) -> &mut ::std::vec::Vec { - &mut self.data - } - - // Take field - pub fn take_data(&mut self) -> ::std::vec::Vec { - ::std::mem::replace(&mut self.data, ::std::vec::Vec::new()) - } - - pub fn get_data(&self) -> &[u8] { - &self.data - } - - fn get_data_for_reflect(&self) -> &::std::vec::Vec { - &self.data - } - - fn mut_data_for_reflect(&mut self) -> &mut ::std::vec::Vec { - &mut self.data - } - - // bytes hash = 5; - - pub fn clear_hash(&mut self) { - self.hash.clear(); - } - - // Param is passed by value, moved - pub fn set_hash(&mut self, v: ::std::vec::Vec) { - self.hash = v; - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_hash(&mut self) -> &mut ::std::vec::Vec { - &mut self.hash - } - - // Take field - pub fn take_hash(&mut self) -> ::std::vec::Vec { - ::std::mem::replace(&mut self.hash, ::std::vec::Vec::new()) - } - - pub fn get_hash(&self) -> &[u8] { - &self.hash - } - - fn get_hash_for_reflect(&self) -> &::std::vec::Vec { - &self.hash - } - - fn mut_hash_for_reflect(&mut self) -> &mut ::std::vec::Vec { - &mut self.hash - } - - // .dss.MetaDataProto meta_data = 6; - - pub fn clear_meta_data(&mut self) { - self.meta_data.clear(); - } - - pub fn has_meta_data(&self) -> bool { - self.meta_data.is_some() - } - - // Param is passed by value, moved - pub fn set_meta_data(&mut self, v: super::metadata::MetaDataProto) { - self.meta_data = ::protobuf::SingularPtrField::some(v); - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_meta_data(&mut self) -> &mut super::metadata::MetaDataProto { - if self.meta_data.is_none() { - self.meta_data.set_default(); - } - self.meta_data.as_mut().unwrap() - } - - // Take field - pub fn take_meta_data(&mut self) -> super::metadata::MetaDataProto { - self.meta_data.take().unwrap_or_else(|| super::metadata::MetaDataProto::new()) - } - - pub fn get_meta_data(&self) -> &super::metadata::MetaDataProto { - self.meta_data.as_ref().unwrap_or_else(|| super::metadata::MetaDataProto::default_instance()) - } - - fn get_meta_data_for_reflect(&self) -> &::protobuf::SingularPtrField { - &self.meta_data - } - - fn mut_meta_data_for_reflect(&mut self) -> &mut ::protobuf::SingularPtrField { - &mut self.meta_data - } -} - -impl ::protobuf::Message for ShareProto { - fn is_initialized(&self) -> bool { - for v in &self.meta_data { - if !v.is_initialized() { - return false; - } - }; - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 1 => { - if wire_type != ::protobuf::wire_format::WireTypeVarint { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - let tmp = is.read_uint32()?; - self.id = tmp; - }, - 2 => { - if wire_type != ::protobuf::wire_format::WireTypeVarint { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - let tmp = is.read_uint32()?; - self.threshold = tmp; - }, - 3 => { - if wire_type != ::protobuf::wire_format::WireTypeVarint { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - let tmp = is.read_uint32()?; - self.shares_count = tmp; - }, - 4 => { - ::protobuf::rt::read_singular_proto3_bytes_into(wire_type, is, &mut self.data)?; - }, - 5 => { - ::protobuf::rt::read_singular_proto3_bytes_into(wire_type, is, &mut self.hash)?; - }, - 6 => { - ::protobuf::rt::read_singular_message_into(wire_type, is, &mut self.meta_data)?; - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - if self.id != 0 { - my_size += ::protobuf::rt::value_size(1, self.id, ::protobuf::wire_format::WireTypeVarint); - } - if self.threshold != 0 { - my_size += ::protobuf::rt::value_size(2, self.threshold, ::protobuf::wire_format::WireTypeVarint); - } - if self.shares_count != 0 { - my_size += ::protobuf::rt::value_size(3, self.shares_count, ::protobuf::wire_format::WireTypeVarint); - } - if !self.data.is_empty() { - my_size += ::protobuf::rt::bytes_size(4, &self.data); - } - if !self.hash.is_empty() { - my_size += ::protobuf::rt::bytes_size(5, &self.hash); - } - if let Some(ref v) = self.meta_data.as_ref() { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - } - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { - if self.id != 0 { - os.write_uint32(1, self.id)?; - } - if self.threshold != 0 { - os.write_uint32(2, self.threshold)?; - } - if self.shares_count != 0 { - os.write_uint32(3, self.shares_count)?; - } - if !self.data.is_empty() { - os.write_bytes(4, &self.data)?; - } - if !self.hash.is_empty() { - os.write_bytes(5, &self.hash)?; - } - if let Some(ref v) = self.meta_data.as_ref() { - os.write_tag(6, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - } - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - ::protobuf::MessageStatic::descriptor_static(None::) - } -} - -impl ::protobuf::MessageStatic for ShareProto { - fn new() -> ShareProto { - ShareProto::new() - } - - fn descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeUint32>( - "id", - ShareProto::get_id_for_reflect, - ShareProto::mut_id_for_reflect, - )); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeUint32>( - "threshold", - ShareProto::get_threshold_for_reflect, - ShareProto::mut_threshold_for_reflect, - )); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeUint32>( - "shares_count", - ShareProto::get_shares_count_for_reflect, - ShareProto::mut_shares_count_for_reflect, - )); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeBytes>( - "data", - ShareProto::get_data_for_reflect, - ShareProto::mut_data_for_reflect, - )); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeBytes>( - "hash", - ShareProto::get_hash_for_reflect, - ShareProto::mut_hash_for_reflect, - )); - fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( - "meta_data", - ShareProto::get_meta_data_for_reflect, - ShareProto::mut_meta_data_for_reflect, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "ShareProto", - fields, - file_descriptor_proto() - ) - }) - } - } -} - -impl ::protobuf::Clear for ShareProto { - fn clear(&mut self) { - self.clear_id(); - self.clear_threshold(); - self.clear_shares_count(); - self.clear_data(); - self.clear_hash(); - self.clear_meta_data(); - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for ShareProto { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for ShareProto { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -static file_descriptor_proto_data: &'static [u8] = b"\ - \n\x0fdss/share.proto\x12\x03dss\x1a\x12dss/metadata.proto\"\xb6\x01\n\n\ - ShareProto\x12\x0e\n\x02id\x18\x01\x20\x01(\rR\x02id\x12\x1c\n\tthreshol\ - d\x18\x02\x20\x01(\rR\tthreshold\x12!\n\x0cshares_count\x18\x03\x20\x01(\ - \rR\x0bsharesCount\x12\x12\n\x04data\x18\x04\x20\x01(\x0cR\x04data\x12\ - \x12\n\x04hash\x18\x05\x20\x01(\x0cR\x04hash\x12/\n\tmeta_data\x18\x06\ - \x20\x01(\x0b2\x12.dss.MetaDataProtoR\x08metaDataJ\xe3\x03\n\x06\x12\x04\ - \0\0\r\x01\n\x08\n\x01\x0c\x12\x03\0\0\x12\n\x08\n\x01\x02\x12\x03\x02\ - \x08\x0b\n\t\n\x02\x03\0\x12\x03\x04\x07\x1b\n\n\n\x02\x04\0\x12\x04\x06\ - \0\r\x01\n\n\n\x03\x04\0\x01\x12\x03\x06\x08\x12\n\x0b\n\x04\x04\0\x02\0\ - \x12\x03\x07\x02\x10\n\r\n\x05\x04\0\x02\0\x04\x12\x04\x07\x02\x06\x14\n\ - \x0c\n\x05\x04\0\x02\0\x05\x12\x03\x07\x02\x08\n\x0c\n\x05\x04\0\x02\0\ - \x01\x12\x03\x07\t\x0b\n\x0c\n\x05\x04\0\x02\0\x03\x12\x03\x07\x0e\x0f\n\ - \x0b\n\x04\x04\0\x02\x01\x12\x03\x08\x02\x17\n\r\n\x05\x04\0\x02\x01\x04\ - \x12\x04\x08\x02\x07\x10\n\x0c\n\x05\x04\0\x02\x01\x05\x12\x03\x08\x02\ - \x08\n\x0c\n\x05\x04\0\x02\x01\x01\x12\x03\x08\t\x12\n\x0c\n\x05\x04\0\ - \x02\x01\x03\x12\x03\x08\x15\x16\n\x0b\n\x04\x04\0\x02\x02\x12\x03\t\x02\ - \x1a\n\r\n\x05\x04\0\x02\x02\x04\x12\x04\t\x02\x08\x17\n\x0c\n\x05\x04\0\ - \x02\x02\x05\x12\x03\t\x02\x08\n\x0c\n\x05\x04\0\x02\x02\x01\x12\x03\t\t\ - \x15\n\x0c\n\x05\x04\0\x02\x02\x03\x12\x03\t\x18\x19\n\x0b\n\x04\x04\0\ - \x02\x03\x12\x03\n\x02\x11\n\r\n\x05\x04\0\x02\x03\x04\x12\x04\n\x02\t\ - \x1a\n\x0c\n\x05\x04\0\x02\x03\x05\x12\x03\n\x02\x07\n\x0c\n\x05\x04\0\ - \x02\x03\x01\x12\x03\n\x08\x0c\n\x0c\n\x05\x04\0\x02\x03\x03\x12\x03\n\ - \x0f\x10\n\x0b\n\x04\x04\0\x02\x04\x12\x03\x0b\x02\x11\n\r\n\x05\x04\0\ - \x02\x04\x04\x12\x04\x0b\x02\n\x11\n\x0c\n\x05\x04\0\x02\x04\x05\x12\x03\ - \x0b\x02\x07\n\x0c\n\x05\x04\0\x02\x04\x01\x12\x03\x0b\x08\x0c\n\x0c\n\ - \x05\x04\0\x02\x04\x03\x12\x03\x0b\x0f\x10\n\x0b\n\x04\x04\0\x02\x05\x12\ - \x03\x0c\x02\"\n\r\n\x05\x04\0\x02\x05\x04\x12\x04\x0c\x02\x0b\x11\n\x0c\ - \n\x05\x04\0\x02\x05\x06\x12\x03\x0c\x02\x13\n\x0c\n\x05\x04\0\x02\x05\ - \x01\x12\x03\x0c\x14\x1d\n\x0c\n\x05\x04\0\x02\x05\x03\x12\x03\x0c\x20!b\ - \x06proto3\ -"; - -static mut file_descriptor_proto_lazy: ::protobuf::lazy::Lazy<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::descriptor::FileDescriptorProto, -}; - -fn parse_descriptor_proto() -> ::protobuf::descriptor::FileDescriptorProto { - ::protobuf::parse_from_bytes(file_descriptor_proto_data).unwrap() -} - -pub fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto { - unsafe { - file_descriptor_proto_lazy.get(|| { - parse_descriptor_proto() - }) - } -} diff --git a/src/proto/version.rs b/src/proto/version.rs deleted file mode 100644 index 9680b35..0000000 --- a/src/proto/version.rs +++ /dev/null @@ -1,100 +0,0 @@ -// This file is generated. Do not edit -// @generated - -// https://github.com/Manishearth/rust-clippy/issues/702 -#![allow(unknown_lints)] -#![allow(clippy)] - -#![cfg_attr(rustfmt, rustfmt_skip)] - -#![allow(box_pointers)] -#![allow(dead_code)] -#![allow(missing_docs)] -#![allow(non_camel_case_types)] -#![allow(non_snake_case)] -#![allow(non_upper_case_globals)] -#![allow(trivial_casts)] -#![allow(unsafe_code)] -#![allow(unused_imports)] -#![allow(unused_results)] - -use protobuf::Message as Message_imported_for_functions; -use protobuf::ProtobufEnum as ProtobufEnum_imported_for_functions; - -#[derive(Clone,PartialEq,Eq,Debug,Hash)] -pub enum VersionProto { - INITIAL_RELEASE = 0, -} - -impl ::protobuf::ProtobufEnum for VersionProto { - fn value(&self) -> i32 { - *self as i32 - } - - fn from_i32(value: i32) -> ::std::option::Option { - match value { - 0 => ::std::option::Option::Some(VersionProto::INITIAL_RELEASE), - _ => ::std::option::Option::None - } - } - - fn values() -> &'static [Self] { - static values: &'static [VersionProto] = &[ - VersionProto::INITIAL_RELEASE, - ]; - values - } - - fn enum_descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::EnumDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::EnumDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::EnumDescriptor, - }; - unsafe { - descriptor.get(|| { - ::protobuf::reflect::EnumDescriptor::new("VersionProto", file_descriptor_proto()) - }) - } - } -} - -impl ::std::marker::Copy for VersionProto { -} - -impl ::std::default::Default for VersionProto { - fn default() -> Self { - VersionProto::INITIAL_RELEASE - } -} - -impl ::protobuf::reflect::ProtobufValue for VersionProto { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Enum(self.descriptor()) - } -} - -static file_descriptor_proto_data: &'static [u8] = b"\ - \n\rversion.proto*#\n\x0cVersionProto\x12\x13\n\x0fINITIAL_RELEASE\x10\0\ - JS\n\x06\x12\x04\x01\0\x05\x01\n\x08\n\x01\x0c\x12\x03\x01\0\x12\n\n\n\ - \x02\x05\0\x12\x04\x03\0\x05\x01\n\n\n\x03\x05\0\x01\x12\x03\x03\x05\x11\ - \n\x0b\n\x04\x05\0\x02\0\x12\x03\x04\x02\x16\n\x0c\n\x05\x05\0\x02\0\x01\ - \x12\x03\x04\x02\x11\n\x0c\n\x05\x05\0\x02\0\x02\x12\x03\x04\x14\x15b\ - \x06proto3\ -"; - -static mut file_descriptor_proto_lazy: ::protobuf::lazy::Lazy<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::descriptor::FileDescriptorProto, -}; - -fn parse_descriptor_proto() -> ::protobuf::descriptor::FileDescriptorProto { - ::protobuf::parse_from_bytes(file_descriptor_proto_data).unwrap() -} - -pub fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto { - unsafe { - file_descriptor_proto_lazy.get(|| { - parse_descriptor_proto() - }) - } -} diff --git a/src/proto/wrapped/secret.rs b/src/proto/wrapped/secret.rs deleted file mode 100644 index 3906856..0000000 --- a/src/proto/wrapped/secret.rs +++ /dev/null @@ -1,328 +0,0 @@ -// This file is generated. Do not edit -// @generated - -// https://github.com/Manishearth/rust-clippy/issues/702 -#![allow(unknown_lints)] -#![allow(clippy)] - -#![cfg_attr(rustfmt, rustfmt_skip)] - -#![allow(box_pointers)] -#![allow(dead_code)] -#![allow(missing_docs)] -#![allow(non_camel_case_types)] -#![allow(non_snake_case)] -#![allow(non_upper_case_globals)] -#![allow(trivial_casts)] -#![allow(unsafe_code)] -#![allow(unused_imports)] -#![allow(unused_results)] - -use protobuf::Message as Message_imported_for_functions; -use protobuf::ProtobufEnum as ProtobufEnum_imported_for_functions; - -#[derive(PartialEq,Clone,Default)] -pub struct SecretProto { - // message fields - pub version: super::version::VersionProto, - pub secret: ::std::vec::Vec, - pub mime_type: ::std::string::String, - // special fields - unknown_fields: ::protobuf::UnknownFields, - cached_size: ::protobuf::CachedSize, -} - -// see codegen.rs for the explanation why impl Sync explicitly -unsafe impl ::std::marker::Sync for SecretProto {} - -impl SecretProto { - pub fn new() -> SecretProto { - ::std::default::Default::default() - } - - pub fn default_instance() -> &'static SecretProto { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const SecretProto, - }; - unsafe { - instance.get(SecretProto::new) - } - } - - // .VersionProto version = 1; - - pub fn clear_version(&mut self) { - self.version = super::version::VersionProto::INITIAL_RELEASE; - } - - // Param is passed by value, moved - pub fn set_version(&mut self, v: super::version::VersionProto) { - self.version = v; - } - - pub fn get_version(&self) -> super::version::VersionProto { - self.version - } - - fn get_version_for_reflect(&self) -> &super::version::VersionProto { - &self.version - } - - fn mut_version_for_reflect(&mut self) -> &mut super::version::VersionProto { - &mut self.version - } - - // bytes secret = 2; - - pub fn clear_secret(&mut self) { - self.secret.clear(); - } - - // Param is passed by value, moved - pub fn set_secret(&mut self, v: ::std::vec::Vec) { - self.secret = v; - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_secret(&mut self) -> &mut ::std::vec::Vec { - &mut self.secret - } - - // Take field - pub fn take_secret(&mut self) -> ::std::vec::Vec { - ::std::mem::replace(&mut self.secret, ::std::vec::Vec::new()) - } - - pub fn get_secret(&self) -> &[u8] { - &self.secret - } - - fn get_secret_for_reflect(&self) -> &::std::vec::Vec { - &self.secret - } - - fn mut_secret_for_reflect(&mut self) -> &mut ::std::vec::Vec { - &mut self.secret - } - - // string mime_type = 3; - - pub fn clear_mime_type(&mut self) { - self.mime_type.clear(); - } - - // Param is passed by value, moved - pub fn set_mime_type(&mut self, v: ::std::string::String) { - self.mime_type = v; - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_mime_type(&mut self) -> &mut ::std::string::String { - &mut self.mime_type - } - - // Take field - pub fn take_mime_type(&mut self) -> ::std::string::String { - ::std::mem::replace(&mut self.mime_type, ::std::string::String::new()) - } - - pub fn get_mime_type(&self) -> &str { - &self.mime_type - } - - fn get_mime_type_for_reflect(&self) -> &::std::string::String { - &self.mime_type - } - - fn mut_mime_type_for_reflect(&mut self) -> &mut ::std::string::String { - &mut self.mime_type - } -} - -impl ::protobuf::Message for SecretProto { - fn is_initialized(&self) -> bool { - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 1 => { - if wire_type != ::protobuf::wire_format::WireTypeVarint { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - let tmp = is.read_enum()?; - self.version = tmp; - }, - 2 => { - ::protobuf::rt::read_singular_proto3_bytes_into(wire_type, is, &mut self.secret)?; - }, - 3 => { - ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.mime_type)?; - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - if self.version != super::version::VersionProto::INITIAL_RELEASE { - my_size += ::protobuf::rt::enum_size(1, self.version); - } - if !self.secret.is_empty() { - my_size += ::protobuf::rt::bytes_size(2, &self.secret); - } - if !self.mime_type.is_empty() { - my_size += ::protobuf::rt::string_size(3, &self.mime_type); - } - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { - if self.version != super::version::VersionProto::INITIAL_RELEASE { - os.write_enum(1, self.version.value())?; - } - if !self.secret.is_empty() { - os.write_bytes(2, &self.secret)?; - } - if !self.mime_type.is_empty() { - os.write_string(3, &self.mime_type)?; - } - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - ::protobuf::MessageStatic::descriptor_static(None::) - } -} - -impl ::protobuf::MessageStatic for SecretProto { - fn new() -> SecretProto { - SecretProto::new() - } - - fn descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeEnum>( - "version", - SecretProto::get_version_for_reflect, - SecretProto::mut_version_for_reflect, - )); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeBytes>( - "secret", - SecretProto::get_secret_for_reflect, - SecretProto::mut_secret_for_reflect, - )); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "mime_type", - SecretProto::get_mime_type_for_reflect, - SecretProto::mut_mime_type_for_reflect, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "SecretProto", - fields, - file_descriptor_proto() - ) - }) - } - } -} - -impl ::protobuf::Clear for SecretProto { - fn clear(&mut self) { - self.clear_version(); - self.clear_secret(); - self.clear_mime_type(); - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for SecretProto { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for SecretProto { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -static file_descriptor_proto_data: &'static [u8] = b"\ - \n\x14wrapped/secret.proto\x12\x07wrapped\x1a\rversion.proto\"k\n\x0bSec\ - retProto\x12'\n\x07version\x18\x01\x20\x01(\x0e2\r.VersionProtoR\x07vers\ - ion\x12\x16\n\x06secret\x18\x02\x20\x01(\x0cR\x06secret\x12\x1b\n\tmime_\ - type\x18\x03\x20\x01(\tR\x08mimeTypeJ\x91\x02\n\x06\x12\x04\0\0\n\x01\n\ - \x08\n\x01\x0c\x12\x03\0\0\x12\n\x08\n\x01\x02\x12\x03\x02\x08\x0f\n\t\n\ - \x02\x03\0\x12\x03\x04\x07\x16\n\n\n\x02\x04\0\x12\x04\x06\0\n\x01\n\n\n\ - \x03\x04\0\x01\x12\x03\x06\x08\x13\n\x0b\n\x04\x04\0\x02\0\x12\x03\x07\ - \x08!\n\r\n\x05\x04\0\x02\0\x04\x12\x04\x07\x08\x06\x15\n\x0c\n\x05\x04\ - \0\x02\0\x06\x12\x03\x07\x08\x14\n\x0c\n\x05\x04\0\x02\0\x01\x12\x03\x07\ - \x15\x1c\n\x0c\n\x05\x04\0\x02\0\x03\x12\x03\x07\x1f\x20\n\x0b\n\x04\x04\ - \0\x02\x01\x12\x03\x08\x08\x19\n\r\n\x05\x04\0\x02\x01\x04\x12\x04\x08\ - \x08\x07!\n\x0c\n\x05\x04\0\x02\x01\x05\x12\x03\x08\x08\r\n\x0c\n\x05\ - \x04\0\x02\x01\x01\x12\x03\x08\x0e\x14\n\x0c\n\x05\x04\0\x02\x01\x03\x12\ - \x03\x08\x17\x18\n\x0b\n\x04\x04\0\x02\x02\x12\x03\t\x08\x1d\n\r\n\x05\ - \x04\0\x02\x02\x04\x12\x04\t\x08\x08\x19\n\x0c\n\x05\x04\0\x02\x02\x05\ - \x12\x03\t\x08\x0e\n\x0c\n\x05\x04\0\x02\x02\x01\x12\x03\t\x0f\x18\n\x0c\ - \n\x05\x04\0\x02\x02\x03\x12\x03\t\x1b\x1cb\x06proto3\ -"; - -static mut file_descriptor_proto_lazy: ::protobuf::lazy::Lazy<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::descriptor::FileDescriptorProto, -}; - -fn parse_descriptor_proto() -> ::protobuf::descriptor::FileDescriptorProto { - ::protobuf::parse_from_bytes(file_descriptor_proto_data).unwrap() -} - -pub fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto { - unsafe { - file_descriptor_proto_lazy.get(|| { - parse_descriptor_proto() - }) - } -} diff --git a/src/proto/wrapped/share.rs b/src/proto/wrapped/share.rs deleted file mode 100644 index 3bbdbb6..0000000 --- a/src/proto/wrapped/share.rs +++ /dev/null @@ -1,333 +0,0 @@ -// This file is generated. Do not edit -// @generated - -// https://github.com/Manishearth/rust-clippy/issues/702 -#![allow(unknown_lints)] -#![allow(clippy)] - -#![cfg_attr(rustfmt, rustfmt_skip)] - -#![allow(box_pointers)] -#![allow(dead_code)] -#![allow(missing_docs)] -#![allow(non_camel_case_types)] -#![allow(non_snake_case)] -#![allow(non_upper_case_globals)] -#![allow(trivial_casts)] -#![allow(unsafe_code)] -#![allow(unused_imports)] -#![allow(unused_results)] - -use protobuf::Message as Message_imported_for_functions; -use protobuf::ProtobufEnum as ProtobufEnum_imported_for_functions; - -#[derive(PartialEq,Clone,Default)] -pub struct ShareProto { - // message fields - pub shamir_data: ::std::vec::Vec, - pub signature: ::protobuf::RepeatedField<::std::vec::Vec>, - pub proof: ::std::vec::Vec, - // special fields - unknown_fields: ::protobuf::UnknownFields, - cached_size: ::protobuf::CachedSize, -} - -// see codegen.rs for the explanation why impl Sync explicitly -unsafe impl ::std::marker::Sync for ShareProto {} - -impl ShareProto { - pub fn new() -> ShareProto { - ::std::default::Default::default() - } - - pub fn default_instance() -> &'static ShareProto { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ShareProto, - }; - unsafe { - instance.get(ShareProto::new) - } - } - - // bytes shamir_data = 1; - - pub fn clear_shamir_data(&mut self) { - self.shamir_data.clear(); - } - - // Param is passed by value, moved - pub fn set_shamir_data(&mut self, v: ::std::vec::Vec) { - self.shamir_data = v; - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_shamir_data(&mut self) -> &mut ::std::vec::Vec { - &mut self.shamir_data - } - - // Take field - pub fn take_shamir_data(&mut self) -> ::std::vec::Vec { - ::std::mem::replace(&mut self.shamir_data, ::std::vec::Vec::new()) - } - - pub fn get_shamir_data(&self) -> &[u8] { - &self.shamir_data - } - - fn get_shamir_data_for_reflect(&self) -> &::std::vec::Vec { - &self.shamir_data - } - - fn mut_shamir_data_for_reflect(&mut self) -> &mut ::std::vec::Vec { - &mut self.shamir_data - } - - // repeated bytes signature = 2; - - pub fn clear_signature(&mut self) { - self.signature.clear(); - } - - // Param is passed by value, moved - pub fn set_signature(&mut self, v: ::protobuf::RepeatedField<::std::vec::Vec>) { - self.signature = v; - } - - // Mutable pointer to the field. - pub fn mut_signature(&mut self) -> &mut ::protobuf::RepeatedField<::std::vec::Vec> { - &mut self.signature - } - - // Take field - pub fn take_signature(&mut self) -> ::protobuf::RepeatedField<::std::vec::Vec> { - ::std::mem::replace(&mut self.signature, ::protobuf::RepeatedField::new()) - } - - pub fn get_signature(&self) -> &[::std::vec::Vec] { - &self.signature - } - - fn get_signature_for_reflect(&self) -> &::protobuf::RepeatedField<::std::vec::Vec> { - &self.signature - } - - fn mut_signature_for_reflect(&mut self) -> &mut ::protobuf::RepeatedField<::std::vec::Vec> { - &mut self.signature - } - - // bytes proof = 3; - - pub fn clear_proof(&mut self) { - self.proof.clear(); - } - - // Param is passed by value, moved - pub fn set_proof(&mut self, v: ::std::vec::Vec) { - self.proof = v; - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_proof(&mut self) -> &mut ::std::vec::Vec { - &mut self.proof - } - - // Take field - pub fn take_proof(&mut self) -> ::std::vec::Vec { - ::std::mem::replace(&mut self.proof, ::std::vec::Vec::new()) - } - - pub fn get_proof(&self) -> &[u8] { - &self.proof - } - - fn get_proof_for_reflect(&self) -> &::std::vec::Vec { - &self.proof - } - - fn mut_proof_for_reflect(&mut self) -> &mut ::std::vec::Vec { - &mut self.proof - } -} - -impl ::protobuf::Message for ShareProto { - fn is_initialized(&self) -> bool { - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 1 => { - ::protobuf::rt::read_singular_proto3_bytes_into(wire_type, is, &mut self.shamir_data)?; - }, - 2 => { - ::protobuf::rt::read_repeated_bytes_into(wire_type, is, &mut self.signature)?; - }, - 3 => { - ::protobuf::rt::read_singular_proto3_bytes_into(wire_type, is, &mut self.proof)?; - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - if !self.shamir_data.is_empty() { - my_size += ::protobuf::rt::bytes_size(1, &self.shamir_data); - } - for value in &self.signature { - my_size += ::protobuf::rt::bytes_size(2, &value); - }; - if !self.proof.is_empty() { - my_size += ::protobuf::rt::bytes_size(3, &self.proof); - } - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { - if !self.shamir_data.is_empty() { - os.write_bytes(1, &self.shamir_data)?; - } - for v in &self.signature { - os.write_bytes(2, &v)?; - }; - if !self.proof.is_empty() { - os.write_bytes(3, &self.proof)?; - } - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - ::protobuf::MessageStatic::descriptor_static(None::) - } -} - -impl ::protobuf::MessageStatic for ShareProto { - fn new() -> ShareProto { - ShareProto::new() - } - - fn descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeBytes>( - "shamir_data", - ShareProto::get_shamir_data_for_reflect, - ShareProto::mut_shamir_data_for_reflect, - )); - fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeBytes>( - "signature", - ShareProto::get_signature_for_reflect, - ShareProto::mut_signature_for_reflect, - )); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeBytes>( - "proof", - ShareProto::get_proof_for_reflect, - ShareProto::mut_proof_for_reflect, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "ShareProto", - fields, - file_descriptor_proto() - ) - }) - } - } -} - -impl ::protobuf::Clear for ShareProto { - fn clear(&mut self) { - self.clear_shamir_data(); - self.clear_signature(); - self.clear_proof(); - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for ShareProto { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for ShareProto { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -static file_descriptor_proto_data: &'static [u8] = b"\ - \n\x13wrapped/share.proto\x12\x07wrapped\"a\n\nShareProto\x12\x1f\n\x0bs\ - hamir_data\x18\x01\x20\x01(\x0cR\nshamirData\x12\x1c\n\tsignature\x18\ - \x02\x20\x03(\x0cR\tsignature\x12\x14\n\x05proof\x18\x03\x20\x01(\x0cR\ - \x05proofJ\x85\x02\n\x06\x12\x04\0\0\x08\x01\n\x08\n\x01\x0c\x12\x03\0\0\ - \x12\n\x08\n\x01\x02\x12\x03\x02\x08\x0f\n\n\n\x02\x04\0\x12\x04\x04\0\ - \x08\x01\n\n\n\x03\x04\0\x01\x12\x03\x04\x08\x12\n\x0b\n\x04\x04\0\x02\0\ - \x12\x03\x05\x08\x1e\n\r\n\x05\x04\0\x02\0\x04\x12\x04\x05\x08\x04\x14\n\ - \x0c\n\x05\x04\0\x02\0\x05\x12\x03\x05\x08\r\n\x0c\n\x05\x04\0\x02\0\x01\ - \x12\x03\x05\x0e\x19\n\x0c\n\x05\x04\0\x02\0\x03\x12\x03\x05\x1c\x1d\n\ - \x0b\n\x04\x04\0\x02\x01\x12\x03\x06\x08%\n\x0c\n\x05\x04\0\x02\x01\x04\ - \x12\x03\x06\x08\x10\n\x0c\n\x05\x04\0\x02\x01\x05\x12\x03\x06\x11\x16\n\ - \x0c\n\x05\x04\0\x02\x01\x01\x12\x03\x06\x17\x20\n\x0c\n\x05\x04\0\x02\ - \x01\x03\x12\x03\x06#$\n\x0b\n\x04\x04\0\x02\x02\x12\x03\x07\x08\x18\n\r\ - \n\x05\x04\0\x02\x02\x04\x12\x04\x07\x08\x06%\n\x0c\n\x05\x04\0\x02\x02\ - \x05\x12\x03\x07\x08\r\n\x0c\n\x05\x04\0\x02\x02\x01\x12\x03\x07\x0e\x13\ - \n\x0c\n\x05\x04\0\x02\x02\x03\x12\x03\x07\x16\x17b\x06proto3\ -"; - -static mut file_descriptor_proto_lazy: ::protobuf::lazy::Lazy<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::descriptor::FileDescriptorProto, -}; - -fn parse_descriptor_proto() -> ::protobuf::descriptor::FileDescriptorProto { - ::protobuf::parse_from_bytes(file_descriptor_proto_data).unwrap() -} - -pub fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto { - unsafe { - file_descriptor_proto_lazy.get(|| { - parse_descriptor_proto() - }) - } -} From a7fb57f2944ecb14e6de33012d6cecde0f8e74e2 Mon Sep 17 00:00:00 2001 From: Ding Xiang Fei Date: Thu, 17 May 2018 23:10:16 +0800 Subject: [PATCH 34/35] pin protoc version to 3.5.1 --- .travis.yml | 13 +++++++++++-- Cargo.toml | 6 +++--- build.rs | 29 ++++++++++------------------- install_protobuf.sh | 22 ++++++++++++++++++++++ 4 files changed, 46 insertions(+), 24 deletions(-) create mode 100644 install_protobuf.sh diff --git a/.travis.yml b/.travis.yml index cd35f73..d2919d5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,9 @@ language: rust -cache: cargo # https://docs.travis-ci.com/user/caching/#Rust-Cargo-cache +cache: + directories: + - $HOME/protobuf + - $HOME/.cargo + - $TRAVIS_BUILD_DIR/target rust: - stable @@ -12,6 +16,7 @@ matrix: allow_failures: - env: NAME='nightly' - env: NAME='kcov' + - env: NAME='rustfmt' include: - env: NAME='nightly' rust: nightly @@ -20,7 +25,7 @@ matrix: before_script: - rustup component add rustfmt-preview script: - - cargo fmt --all -- --write-mode=diff + - cargo fmt --all -- --check - env: NAME='kcov' sudo: required # travis-ci/travis-ci#9061 before_script: @@ -45,6 +50,10 @@ env: - RUSTFLAGS="-C link-dead-code" script: + - export PATH=$PATH:$HOME/protobuf/bin - cargo build --verbose --all-features - cargo test --verbose --all-features - cargo doc --verbose --all-features + +before_install: + - bash install_protobuf.sh diff --git a/Cargo.toml b/Cargo.toml index f6332b4..3b634da 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,11 +28,11 @@ dss = [] base64 = "0.9.0" rand = "^0.4.2" ring = "^0.12" -merkle_sigs = "^1.4" -protobuf = "^1.5" +merkle_sigs = "1.5.0" +protobuf = "1.5.1" [build-dependencies] -protoc-rust = "1.5" +protoc-rust = "1.7.1" [dependencies.error-chain] version = "0.11.0" diff --git a/build.rs b/build.rs index 6e6d346..5b80827 100644 --- a/build.rs +++ b/build.rs @@ -69,22 +69,13 @@ impl fmt::Display for Tables { } } -fn build_protobuf<'a>( - out_dir: &'a str, - input: &'a [&'a str], - includes: &'a [&'a str], -) { - use self::protoc_rust::{run, Args, Customize}; - run( - Args { - out_dir, - input, - includes, - customize: Customize { - ..Default::default() - }, - } - ).expect("protoc"); +fn build_protobuf<'a>(out_dir: &'a str, input: &'a [&'a str], includes: &'a [&'a str]) { + use self::protoc_rust::{run, Args}; + run(Args { + out_dir, + input, + includes, + }).expect("protoc"); } fn generate_gf256_table() { @@ -117,14 +108,14 @@ fn main() { "protobuf/dss/secret.proto", "protobuf/dss/share.proto", ], - &["protobuf", "protobuf/dss"] + &["protobuf", "protobuf/dss"], ); build_protobuf( "src/proto/wrapped", &[ "protobuf/wrapped/secret.proto", - "protobuf/wrapped/share.proto" + "protobuf/wrapped/share.proto", ], - &["protobuf", "protobuf/dss"] + &["protobuf", "protobuf/dss"], ); } diff --git a/install_protobuf.sh b/install_protobuf.sh new file mode 100644 index 0000000..0a1432a --- /dev/null +++ b/install_protobuf.sh @@ -0,0 +1,22 @@ +#!/usr/bin/bash +set -e + +check_protoc_version () { + version="libprotoc $1" + PROTOC="$HOME/protobuf/bin/protoc" + if [ -f $PROTOC ]; then + this_version=`$PROTOC --version` + return `[ "$version" = "$this_version" ]` + else + return 1 + fi +} + +if check_protoc_version '3.5.1'; then + echo protoc version 3.5.1 detected. + exit +fi + +wget https://github.com/google/protobuf/archive/v3.5.1.tar.gz +tar -xzvf v3.5.1.tar.gz +cd protobuf-3.5.1 && ./autogen.sh && ./configure --prefix=$HOME/protobuf && make && make install From badb04dcbbb7d0cd59f4a11fede96a41a213d815 Mon Sep 17 00:00:00 2001 From: Ding Xiang Fei Date: Tue, 19 Jun 2018 13:50:46 +0800 Subject: [PATCH 35/35] another attempt to fix build with the new protobuf, but blocked by merkle.rs --- .travis.yml | 3 +++ Cargo.toml | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index d2919d5..909ff02 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,6 +24,9 @@ matrix: rust: nightly before_script: - rustup component add rustfmt-preview + - touch src/proto/version.rs + - touch src/proto/dss/metadata.rs src/proto/dss/secret.rs src/proto/dss/share.rs + - touch src/proto/wrapped/secret.rs src/proto/wrapped/share.rs script: - cargo fmt --all -- --check - env: NAME='kcov' diff --git a/Cargo.toml b/Cargo.toml index 3b634da..5ae3a7e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,10 +29,10 @@ base64 = "0.9.0" rand = "^0.4.2" ring = "^0.12" merkle_sigs = "1.5.0" -protobuf = "1.5.1" +protobuf = "^2.0.2" [build-dependencies] -protoc-rust = "1.7.1" +protoc-rust = "^2.0.2" [dependencies.error-chain] version = "0.11.0"