Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
603882f
Small Rustfmt formatting fix to build.rs
psivesely Mar 15, 2018
5263953
Initial barycentric Langrange interpolation
psivesely Mar 16, 2018
be20e77
Use barycentric Lagrange interpolation in all cases.
romac Mar 19, 2018
e39bdaf
Ensure there is at least one point in QuickCheck tests
romac Mar 19, 2018
a2dafcf
Use Horner's method for evaluating polynomials
psivesely Mar 15, 2018
0b42b6b
Note algorithm in encode_secret_byte docstring
psivesely Mar 15, 2018
5a9bfb9
Update rand to ^0.4.2
psivesely Mar 16, 2018
b34a209
Add TODO note on unreleased Rng::try_fill_bytes
psivesely Mar 21, 2018
ecb22aa
Remove `ShareIdentifierTooBig` error and validation
psivesely Mar 26, 2018
2baa8ab
Remove `DuplicateShareData` error and validation
psivesely Mar 26, 2018
10209b6
Add ErrorKind::ShareParsingInvalidShareThreshold
psivesely Mar 27, 2018
b48a74a
Simplify threshold consistency validation
psivesely Mar 27, 2018
c7f2742
Fix arg order missing shares validation
psivesely Mar 27, 2018
6d04a58
MissingShares should take `u8` for `required` arg
psivesely Mar 27, 2018
8ab91bb
More specific validation error when share thresholds mismatch
psivesely Mar 27, 2018
fefd5ab
Validate shares have the same data length
psivesely Mar 27, 2018
51f77fa
Disable `dss` benchmarks until we expose the module.
romac Mar 28, 2018
5ee3cf2
Change signatures of share validation fns
psivesely Mar 29, 2018
2df49c5
Standardize validation var identifier on
psivesely Mar 29, 2018
8813418
Simplify share threshold and secret length consistency validation
psivesely Mar 29, 2018
07de9be
Validation consistency between format & validation modules
psivesely Mar 29, 2018
463d42b
Minor improvement to validation
psivesely Mar 29, 2018
a6ff8a7
Adds `no_more_than_five` formatter
psivesely Mar 29, 2018
12cefb1
Rustfmt updates + refactor Travis configuration (#60)
psivesely Apr 2, 2018
d29415e
Refactor barycentric interpolation for modularity
psivesely Mar 21, 2018
bc1f9d8
Introduce support for incremental secret computation
psivesely Mar 23, 2018
dc67d1b
Slight refactor of PartialSecret
psivesely Mar 23, 2018
c9f0a52
Adds `evaluate_at_x` method to `PartialSecret`
psivesely Mar 23, 2018
b605a00
Additional updates to PartialSecret
psivesely Mar 23, 2018
8d00278
Add sample sss module partial secret recovery fns
psivesely Mar 23, 2018
0f4213d
DRY and validation refactor for `PartialSecrets`
psivesely Mar 26, 2018
34bdb4d
Introduce IncrementalRecovery and refactor validation
psivesely Apr 1, 2018
85ed1e2
Lints to new incremental recovery code
psivesely Apr 1, 2018
de0250b
Remove `interpolate_at`, work directly with `PartialSecret`
psivesely Apr 1, 2018
dc8b436
Simplify verification
psivesely Apr 2, 2018
4998e5b
Refactor share::validation and sss::scheme modules
psivesely Apr 3, 2018
b92ab2a
Refactor validation
psivesely Apr 3, 2018
ae5ce47
Recover::update should fail if no ::shares_needed
psivesely Apr 3, 2018
92c3d2b
Store redundant PartialSecret data in Recovery
psivesely Apr 3, 2018
eebdab2
Use gf256! instead of Gf256::from_byte
psivesely Apr 3, 2018
368c35b
PartialSecrets to BarycentricWeights
psivesely Apr 3, 2018
3e971e4
Misc minor fixes to new Partial Interpolation capability
psivesely Apr 3, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 34 additions & 22 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -63,4 +63,3 @@ tag-prefix = "v"
tag-message = "Release version {{version}}."
doc-commit-message = "Update documentation."
dev-version-ext = "pre"

23 changes: 16 additions & 7 deletions benches/ss1.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#![cfg(test)]
#![feature(test)]
#![cfg(feature = "dss")]

extern crate rusty_secrets;
extern crate test;
Expand All @@ -9,37 +10,45 @@ 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::<Vec<_>>().clone();

b.iter(|| {
let result = ss1::recover_secret(&shares.to_vec()).unwrap();
black_box(result);
});
}
)
};
}

bench_generate!(generate_1kb_3_5, 3, 5, secret_1kb);
Expand Down
10 changes: 5 additions & 5 deletions benches/sss.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -39,7 +39,7 @@ mod sss {
black_box(result);
});
}
)
};
}

bench_generate!(generate_1kb_3_5, 3, 5, secret_1kb, false);
Expand Down
11 changes: 6 additions & 5 deletions benches/thss.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#![cfg(test)]
#![feature(test)]
#![cfg(feature = "dss")]

extern crate rusty_secrets;
extern crate test;
Expand All @@ -9,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();
Expand All @@ -23,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();
Expand All @@ -39,7 +40,7 @@ mod thss {
black_box(result);
});
}
)
};
}

bench_generate!(generate_1kb_3_5, 3, 5, secret_1kb);
Expand Down
16 changes: 9 additions & 7 deletions benches/wrapped_secrets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,40 @@ 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::<Vec<_>>();

b.iter(|| {
let result = wrapped_secrets::recover_secret(&shares, $signed).unwrap();
black_box(result);
});
}
)
};
}

bench_generate!(generate_1kb_3_5, 3, 5, secret_1kb, false);
Expand Down
8 changes: 4 additions & 4 deletions build.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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 = "
Expand Down
2 changes: 1 addition & 1 deletion src/dss/format.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::error::Error;

use protobuf::{self, Message};
use base64;
use protobuf::{self, Message};

use errors::*;
use proto::dss::ShareProto;
Expand Down
2 changes: 1 addition & 1 deletion src/dss/metadata.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion src/dss/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/dss/ss1/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
21 changes: 11 additions & 10 deletions src/dss/ss1/scheme.rs
Original file line number Diff line number Diff line change
@@ -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_all_shares, validate_share_count};
use vol_hash::VOLHash;

/// We bound the message size at about 16MB to avoid overflow in `random_bytes_count`.
Expand Down Expand Up @@ -247,13 +247,14 @@ impl SS1 {
&self,
shares: &[Share],
) -> Result<(Vec<u8>, AccessStructure, Option<MetaData>)> {
let (_, shares) = validate_shares(shares.to_vec())?;
let shares = shares.to_vec();
let (threshold, _) = validate_all_shares(&shares)?;

let underlying_shares = shares
.iter()
.map(|share| thss::Share {
id: share.id,
threshold: share.threshold,
threshold,
shares_count: share.shares_count,
data: share.data.clone(),
metadata: share.metadata.clone(),
Expand Down
4 changes: 2 additions & 2 deletions src/dss/ss1/serialize.rs
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/dss/ss1/share.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
Loading