mirror of
https://github.com/mii443/RustySecrets.git
synced 2025-08-22 16:25:32 +00:00
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`.
This commit is contained in:
committed by
Romain Ruetschi
parent
d6407c0e8a
commit
c25f661645
56
.travis.yml
56
.travis.yml
@ -1,38 +1,50 @@
|
|||||||
|
|
||||||
sudo: required
|
|
||||||
|
|
||||||
language: rust
|
language: rust
|
||||||
|
cache: cargo # https://docs.travis-ci.com/user/caching/#Rust-Cargo-cache
|
||||||
|
|
||||||
rust:
|
rust:
|
||||||
- stable
|
- stable
|
||||||
- beta
|
- beta
|
||||||
- nightly
|
|
||||||
|
|
||||||
matrix:
|
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:
|
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:
|
env:
|
||||||
global:
|
global:
|
||||||
- RUSTFLAGS="-C link-dead-code"
|
- RUSTFLAGS="-C link-dead-code"
|
||||||
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- libcurl4-openssl-dev
|
|
||||||
- libdw-dev
|
|
||||||
- cmake
|
|
||||||
- g++
|
|
||||||
- pkg-config
|
|
||||||
- binutils-dev
|
|
||||||
- libiberty-dev
|
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- cargo build --verbose --all-features
|
- cargo build --verbose --all-features
|
||||||
- cargo test --verbose --all-features
|
- cargo test --verbose --all-features
|
||||||
|
- cargo doc --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
|
|
||||||
|
|
||||||
|
@ -10,29 +10,37 @@ mod shared;
|
|||||||
mod ss1 {
|
mod ss1 {
|
||||||
|
|
||||||
use rusty_secrets::dss::ss1;
|
use rusty_secrets::dss::ss1;
|
||||||
use test::{black_box, Bencher};
|
|
||||||
use shared;
|
use shared;
|
||||||
|
use test::{black_box, Bencher};
|
||||||
|
|
||||||
macro_rules! bench_generate {
|
macro_rules! bench_generate {
|
||||||
($name:ident, $k:expr, $n:expr, $secret:ident) => (
|
($name:ident, $k:expr, $n:expr, $secret:ident) => {
|
||||||
#[bench]
|
#[bench]
|
||||||
fn $name(b: &mut Bencher) {
|
fn $name(b: &mut Bencher) {
|
||||||
let secret = shared::$secret();
|
let secret = shared::$secret();
|
||||||
|
|
||||||
b.iter(move || {
|
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);
|
black_box(shares);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
)
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! bench_recover {
|
macro_rules! bench_recover {
|
||||||
($name:ident, $k:expr, $n:expr, $secret:ident) => (
|
($name:ident, $k:expr, $n:expr, $secret:ident) => {
|
||||||
#[bench]
|
#[bench]
|
||||||
fn $name(b: &mut Bencher) {
|
fn $name(b: &mut Bencher) {
|
||||||
let secret = shared::$secret();
|
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();
|
let shares = &all_shares.into_iter().take($k).collect::<Vec<_>>().clone();
|
||||||
|
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
@ -40,7 +48,7 @@ mod ss1 {
|
|||||||
black_box(result);
|
black_box(result);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
)
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
bench_generate!(generate_1kb_3_5, 3, 5, secret_1kb);
|
bench_generate!(generate_1kb_3_5, 3, 5, secret_1kb);
|
||||||
|
@ -8,12 +8,12 @@ mod shared;
|
|||||||
|
|
||||||
mod sss {
|
mod sss {
|
||||||
|
|
||||||
use test::{black_box, Bencher};
|
|
||||||
use rusty_secrets::sss;
|
use rusty_secrets::sss;
|
||||||
use shared;
|
use shared;
|
||||||
|
use test::{black_box, Bencher};
|
||||||
|
|
||||||
macro_rules! bench_generate {
|
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]
|
#[bench]
|
||||||
fn $name(b: &mut Bencher) {
|
fn $name(b: &mut Bencher) {
|
||||||
let secret = shared::$secret();
|
let secret = shared::$secret();
|
||||||
@ -23,11 +23,11 @@ mod sss {
|
|||||||
black_box(shares);
|
black_box(shares);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
)
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! bench_recover {
|
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]
|
#[bench]
|
||||||
fn $name(b: &mut Bencher) {
|
fn $name(b: &mut Bencher) {
|
||||||
let secret = shared::$secret();
|
let secret = shared::$secret();
|
||||||
@ -39,7 +39,7 @@ mod sss {
|
|||||||
black_box(result);
|
black_box(result);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
)
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
bench_generate!(generate_1kb_3_5, 3, 5, secret_1kb, false);
|
bench_generate!(generate_1kb_3_5, 3, 5, secret_1kb, false);
|
||||||
|
@ -10,11 +10,11 @@ mod shared;
|
|||||||
mod thss {
|
mod thss {
|
||||||
|
|
||||||
use rusty_secrets::dss::thss;
|
use rusty_secrets::dss::thss;
|
||||||
use test::{black_box, Bencher};
|
|
||||||
use shared;
|
use shared;
|
||||||
|
use test::{black_box, Bencher};
|
||||||
|
|
||||||
macro_rules! bench_generate {
|
macro_rules! bench_generate {
|
||||||
($name:ident, $k:expr, $n:expr, $secret:ident) => (
|
($name:ident, $k:expr, $n:expr, $secret:ident) => {
|
||||||
#[bench]
|
#[bench]
|
||||||
fn $name(b: &mut Bencher) {
|
fn $name(b: &mut Bencher) {
|
||||||
let secret = shared::$secret();
|
let secret = shared::$secret();
|
||||||
@ -24,11 +24,11 @@ mod thss {
|
|||||||
black_box(shares);
|
black_box(shares);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
)
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! bench_recover {
|
macro_rules! bench_recover {
|
||||||
($name:ident, $k:expr, $n:expr, $secret:ident) => (
|
($name:ident, $k:expr, $n:expr, $secret:ident) => {
|
||||||
#[bench]
|
#[bench]
|
||||||
fn $name(b: &mut Bencher) {
|
fn $name(b: &mut Bencher) {
|
||||||
let secret = shared::$secret();
|
let secret = shared::$secret();
|
||||||
@ -40,7 +40,7 @@ mod thss {
|
|||||||
black_box(result);
|
black_box(result);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
)
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
bench_generate!(generate_1kb_3_5, 3, 5, secret_1kb);
|
bench_generate!(generate_1kb_3_5, 3, 5, secret_1kb);
|
||||||
|
@ -8,30 +8,32 @@ mod shared;
|
|||||||
|
|
||||||
mod wrapped_secrets {
|
mod wrapped_secrets {
|
||||||
|
|
||||||
use test::{black_box, Bencher};
|
|
||||||
use rusty_secrets::wrapped_secrets;
|
use rusty_secrets::wrapped_secrets;
|
||||||
use shared;
|
use shared;
|
||||||
|
use test::{black_box, Bencher};
|
||||||
|
|
||||||
macro_rules! bench_generate {
|
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]
|
#[bench]
|
||||||
fn $name(b: &mut Bencher) {
|
fn $name(b: &mut Bencher) {
|
||||||
let secret = shared::$secret();
|
let secret = shared::$secret();
|
||||||
|
|
||||||
b.iter(move || {
|
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);
|
black_box(shares);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
)
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! bench_recover {
|
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]
|
#[bench]
|
||||||
fn $name(b: &mut Bencher) {
|
fn $name(b: &mut Bencher) {
|
||||||
let secret = shared::$secret();
|
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<_>>();
|
let shares = all_shares.into_iter().take($k).collect::<Vec<_>>();
|
||||||
|
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
@ -39,7 +41,7 @@ mod wrapped_secrets {
|
|||||||
black_box(result);
|
black_box(result);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
)
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
bench_generate!(generate_1kb_3_5, 3, 5, secret_1kb, false);
|
bench_generate!(generate_1kb_3_5, 3, 5, secret_1kb, false);
|
||||||
|
4
build.rs
4
build.rs
@ -1,9 +1,9 @@
|
|||||||
use std::env;
|
use std::env;
|
||||||
|
use std::fmt;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::path::Path;
|
|
||||||
use std::fmt;
|
|
||||||
use std::num::Wrapping;
|
use std::num::Wrapping;
|
||||||
|
use std::path::Path;
|
||||||
|
|
||||||
const POLY: u8 = 0x1D;
|
const POLY: u8 = 0x1D;
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
|
|
||||||
use protobuf::{self, Message};
|
|
||||||
use base64;
|
use base64;
|
||||||
|
use protobuf::{self, Message};
|
||||||
|
|
||||||
use errors::*;
|
use errors::*;
|
||||||
use proto::dss::ShareProto;
|
use proto::dss::ShareProto;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use std::collections::BTreeMap;
|
|
||||||
use ring::digest;
|
use ring::digest;
|
||||||
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
/// A share's public metadata.
|
/// A share's public metadata.
|
||||||
#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord, Default)]
|
#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord, Default)]
|
||||||
|
@ -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.
|
//! **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.
|
//! **Repro** | Share reproducible: The scheme can produce shares in a deterministic way.
|
||||||
|
|
||||||
pub mod thss;
|
|
||||||
pub mod ss1;
|
pub mod ss1;
|
||||||
|
pub mod thss;
|
||||||
|
|
||||||
mod metadata;
|
mod metadata;
|
||||||
|
|
||||||
|
@ -29,8 +29,8 @@ mod share;
|
|||||||
pub use self::share::*;
|
pub use self::share::*;
|
||||||
|
|
||||||
mod scheme;
|
mod scheme;
|
||||||
use self::scheme::SS1;
|
|
||||||
pub use self::scheme::Reproducibility;
|
pub use self::scheme::Reproducibility;
|
||||||
|
use self::scheme::SS1;
|
||||||
|
|
||||||
use dss::AccessStructure;
|
use dss::AccessStructure;
|
||||||
|
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
|
||||||
use ring::{hkdf, hmac};
|
|
||||||
use ring::rand::{SecureRandom, SystemRandom};
|
|
||||||
use ring::digest::{Context, SHA256};
|
|
||||||
use rand::{ChaChaRng, Rng, SeedableRng};
|
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 super::share::*;
|
||||||
|
use dss::random::{random_bytes_count, FixedRandom, MAX_MESSAGE_SIZE};
|
||||||
|
use dss::thss::{MetaData, ThSS};
|
||||||
use dss::utils;
|
use dss::utils;
|
||||||
|
use dss::{thss, AccessStructure};
|
||||||
|
use errors::*;
|
||||||
|
use share::validation::{validate_share_count, validate_shares};
|
||||||
use vol_hash::VOLHash;
|
use vol_hash::VOLHash;
|
||||||
|
|
||||||
/// We bound the message size at about 16MB to avoid overflow in `random_bytes_count`.
|
/// We bound the message size at about 16MB to avoid overflow in `random_bytes_count`.
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use errors::*;
|
|
||||||
use super::{MetaData, Share};
|
use super::{MetaData, Share};
|
||||||
use dss::format::{format_share_protobuf, parse_share_protobuf};
|
use dss::format::{format_share_protobuf, parse_share_protobuf};
|
||||||
use proto::dss::{MetaDataProto, ShareProto};
|
|
||||||
use dss::utils::{btreemap_to_hashmap, hashmap_to_btreemap};
|
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 {
|
pub(crate) fn share_to_string(share: Share) -> String {
|
||||||
let proto = share_to_protobuf(share);
|
let proto = share_to_protobuf(share);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
|
use super::serialize::{share_from_string, share_to_string};
|
||||||
use errors::*;
|
use errors::*;
|
||||||
use share::IsShare;
|
use share::IsShare;
|
||||||
use super::serialize::{share_from_string, share_to_string};
|
|
||||||
|
|
||||||
pub use dss::metadata::MetaData;
|
pub use dss::metadata::MetaData;
|
||||||
|
|
||||||
|
@ -4,15 +4,15 @@ use std::fmt;
|
|||||||
|
|
||||||
use ring::rand::{SecureRandom, SystemRandom};
|
use ring::rand::{SecureRandom, SystemRandom};
|
||||||
|
|
||||||
|
use dss::random::{random_bytes, random_bytes_count, MAX_MESSAGE_SIZE};
|
||||||
use errors::*;
|
use errors::*;
|
||||||
use gf256::Gf256;
|
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 lagrange;
|
||||||
|
use share::validation::{validate_share_count, validate_shares};
|
||||||
|
|
||||||
use super::AccessStructure;
|
use super::AccessStructure;
|
||||||
use super::share::*;
|
|
||||||
use super::encode::encode_secret;
|
use super::encode::encode_secret;
|
||||||
|
use super::share::*;
|
||||||
|
|
||||||
/// We bound the message size at about 16MB to avoid overflow in `random_bytes_count`.
|
/// 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
|
/// Moreover, given the current performances, it is almost unpractical to run
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use errors::*;
|
|
||||||
use super::{MetaData, Share};
|
use super::{MetaData, Share};
|
||||||
use dss::format::{format_share_protobuf, parse_share_protobuf};
|
use dss::format::{format_share_protobuf, parse_share_protobuf};
|
||||||
use proto::dss::{MetaDataProto, ShareProto};
|
|
||||||
use dss::utils::{btreemap_to_hashmap, hashmap_to_btreemap};
|
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 {
|
pub(crate) fn share_to_string(share: Share) -> String {
|
||||||
let proto = share_to_protobuf(share);
|
let proto = share_to_protobuf(share);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
|
use super::serialize::{share_from_string, share_to_string};
|
||||||
use errors::*;
|
use errors::*;
|
||||||
use share::IsShare;
|
use share::IsShare;
|
||||||
use super::serialize::{share_from_string, share_to_string};
|
|
||||||
|
|
||||||
pub use dss::metadata::MetaData;
|
pub use dss::metadata::MetaData;
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use std;
|
use std;
|
||||||
|
|
||||||
use std::hash::Hash;
|
|
||||||
use std::collections::{BTreeMap, HashMap};
|
use std::collections::{BTreeMap, HashMap};
|
||||||
|
use std::hash::Hash;
|
||||||
|
|
||||||
/// Transmutes a `&[u8]` into a `&[u32]`.
|
/// Transmutes a `&[u8]` into a `&[u32]`.
|
||||||
/// Despite `std::mem::transmute` being very unsafe in
|
/// Despite `std::mem::transmute` being very unsafe in
|
||||||
|
13
src/gf256.rs
13
src/gf256.rs
@ -143,7 +143,9 @@ impl Neg for Gf256 {
|
|||||||
#[macro_export]
|
#[macro_export]
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
macro_rules! gf256 {
|
macro_rules! gf256 {
|
||||||
($e:expr) => (Gf256::from_byte($e))
|
($e:expr) => {
|
||||||
|
Gf256::from_byte($e)
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
@ -178,10 +180,10 @@ mod tests {
|
|||||||
|
|
||||||
mod vectors {
|
mod vectors {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use flate2::read::GzDecoder;
|
||||||
|
use itertools::Itertools;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::{BufRead, BufReader};
|
use std::io::{BufRead, BufReader};
|
||||||
use itertools::Itertools;
|
|
||||||
use flate2::read::GzDecoder;
|
|
||||||
|
|
||||||
macro_rules! mk_test {
|
macro_rules! mk_test {
|
||||||
($id:ident, $op:expr, $val:expr) => {
|
($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 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()) {
|
for ((i, j, k), line) in results.zip(reference.lines()) {
|
||||||
let left = format!("{} {} {} = {}", i, $op, j, k);
|
let left = format!("{} {} {} = {}", i, $op, j, k);
|
||||||
@ -204,7 +207,7 @@ mod tests {
|
|||||||
assert_eq!(left, right);
|
assert_eq!(left, right);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
mk_test!(add, "+", |i: Gf256, j: Gf256| i + j);
|
mk_test!(add, "+", |i: Gf256, j: Gf256| i + j);
|
||||||
|
@ -86,10 +86,10 @@ pub(crate) fn interpolate(points: &[(Gf256, Gf256)]) -> Poly {
|
|||||||
#[allow(trivial_casts)]
|
#[allow(trivial_casts)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
|
||||||
use std;
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use gf256::*;
|
use gf256::*;
|
||||||
use quickcheck::*;
|
use quickcheck::*;
|
||||||
|
use std;
|
||||||
|
|
||||||
quickcheck! {
|
quickcheck! {
|
||||||
|
|
||||||
|
@ -18,15 +18,15 @@ extern crate ring;
|
|||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
mod gf256;
|
mod gf256;
|
||||||
mod share;
|
|
||||||
mod poly;
|
|
||||||
mod lagrange;
|
mod lagrange;
|
||||||
|
mod poly;
|
||||||
|
mod share;
|
||||||
mod vol_hash;
|
mod vol_hash;
|
||||||
|
|
||||||
pub mod errors;
|
pub mod errors;
|
||||||
|
pub mod proto;
|
||||||
pub mod sss;
|
pub mod sss;
|
||||||
pub mod wrapped_secrets;
|
pub mod wrapped_secrets;
|
||||||
pub mod proto;
|
|
||||||
|
|
||||||
#[cfg(feature = "dss")]
|
#[cfg(feature = "dss")]
|
||||||
pub mod dss;
|
pub mod dss;
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
|
use base64;
|
||||||
use errors::*;
|
use errors::*;
|
||||||
use merkle_sigs::{MerklePublicKey, Proof, PublicKey};
|
use merkle_sigs::{MerklePublicKey, Proof, PublicKey};
|
||||||
use protobuf::{self, Message, RepeatedField};
|
|
||||||
use base64;
|
|
||||||
use sss::{Share, HASH_ALGO};
|
|
||||||
use proto::wrapped::ShareProto;
|
use proto::wrapped::ShareProto;
|
||||||
|
use protobuf::{self, Message, RepeatedField};
|
||||||
|
use sss::{Share, HASH_ALGO};
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
|
|
||||||
const BASE64_CONFIG: base64::Config = base64::STANDARD_NO_PAD;
|
const BASE64_CONFIG: base64::Config = base64::STANDARD_NO_PAD;
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
//! SSS provides Shamir's secret sharing with raw data.
|
//! SSS provides Shamir's secret sharing with raw data.
|
||||||
|
|
||||||
use rand::{OsRng, Rng};
|
|
||||||
use merkle_sigs::sign_data_vec;
|
use merkle_sigs::sign_data_vec;
|
||||||
|
use rand::{OsRng, Rng};
|
||||||
|
|
||||||
use errors::*;
|
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 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;
|
use super::encode::encode_secret_byte;
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use std::error::Error;
|
|
||||||
use std::collections::{HashMap, HashSet};
|
use std::collections::{HashMap, HashSet};
|
||||||
|
use std::error::Error;
|
||||||
|
|
||||||
use merkle_sigs::{MerklePublicKey, Proof};
|
|
||||||
use merkle_sigs::verify_data_vec_signature;
|
use merkle_sigs::verify_data_vec_signature;
|
||||||
|
use merkle_sigs::{MerklePublicKey, Proof};
|
||||||
|
|
||||||
use errors::*;
|
use errors::*;
|
||||||
use share::{IsShare, IsSignedShare};
|
use share::{IsShare, IsSignedShare};
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use errors::*;
|
use errors::*;
|
||||||
|
use proto::VersionProto;
|
||||||
|
use proto::wrapped::SecretProto;
|
||||||
use protobuf;
|
use protobuf;
|
||||||
use protobuf::Message;
|
use protobuf::Message;
|
||||||
use proto::wrapped::SecretProto;
|
|
||||||
use proto::VersionProto;
|
|
||||||
|
|
||||||
use sss::SSS;
|
use sss::SSS;
|
||||||
pub(crate) use sss::Share;
|
pub(crate) use sss::Share;
|
||||||
|
Reference in New Issue
Block a user