Skip to content

Commit ee416d7

Browse files
committed
Aligned to dependencies.
1 parent f0b6243 commit ee416d7

File tree

3 files changed

+54
-27
lines changed

3 files changed

+54
-27
lines changed

Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
[package]
22
name = "bc-shamir"
3-
version = "0.5.0"
3+
version = "0.6.0"
44
edition = "2021"
55
description = "Shamir's Secret Sharing (SSS) for Rust."
66
authors = ["Blockchain Commons"]
77
repository = "https://github.com/BlockchainCommons/bc-shamir-rust"
88
readme = "README.md"
99
license = "BSD-2-Clause-Patent"
1010
documentation = "https://docs.rs/bc-shamir"
11-
keywords = ["cryptography"] # Up to five
12-
categories = ["cryptography"] # https://crates.io/category_slugs
11+
keywords = ["cryptography"] # Up to five
12+
categories = ["cryptography"] # https://crates.io/category_slugs
1313

1414
[dependencies]
15-
bc-rand = "^0.2.0"
16-
bc-crypto = "^0.6.0"
15+
bc-rand = "^0.3.0"
16+
bc-crypto = "^0.7.0"
1717

1818
thiserror = "^1.0.48"
1919

README.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@
88

99
## Introduction
1010

11-
This is a pure-Rust implementation of [Shamir's Secret Sharing (SSS)](https://en.wikipedia.org/wiki/Shamir%27s_secret_sharing) is a cryptographic technique in which a *secret* is divided into parts, called *shares*, in such a way that a *threshold* of several shares are needed to reconstruct the secret. The shares are distributed in a way that makes it impossible for an attacker to know anything about the secret without having a threshold of shares. If the number of shares is less than the threshold, then no information about the secret is revealed.
11+
This is a pure-Rust implementation of [Shamir's Secret Sharing (SSS)](https://en.wikipedia.org/wiki/Shamir%27s_secret_sharing) is a cryptographic technique in which a _secret_ is divided into parts, called _shares_, in such a way that a _threshold_ of several shares are needed to reconstruct the secret. The shares are distributed in a way that makes it impossible for an attacker to know anything about the secret without having a threshold of shares. If the number of shares is less than the threshold, then no information about the secret is revealed.
1212

1313
## Getting Started
1414

1515
```toml
1616
[dependencies]
17-
bc-shamir = "0.5.0"
17+
bc-shamir = "0.6.0"
1818
```
19+
1920
## Related Projects
2021

2122
The primary client of this library is [sskr](https://crates.io/crates/sskr), which implements [Sharded Secret Key Reconstruction (SSKR)](https://github.com/BlockchainCommons/Research/blob/master/papers/bcr-2020-011-sskr.md)
@@ -59,10 +60,10 @@ If your company requires support to use our projects, please feel free to contac
5960

6061
The following people directly contributed to this repository. You can add your name here by getting involved. The first step is learning how to contribute from our [CONTRIBUTING.md](./CONTRIBUTING.md) documentation.
6162

62-
| Name | Role | Github | Email | GPG Fingerprint |
63-
| ----------------- | ------------------- | ------------------------------------------------- | ------------------------------------- | -------------------------------------------------- |
64-
| Christopher Allen | Principal Architect | [@ChristopherA](https://github.com/ChristopherA) | \<[email protected]\> | FDFE 14A5 4ECB 30FC 5D22 74EF F8D3 6C91 3574 05ED |
65-
| Wolf McNally | Lead Researcher/Engineer | [@WolfMcNally](https://github.com/wolfmcnally) | \<[email protected]\> | 9436 52EE 3844 1760 C3DC  3536 4B6C 2FCF 8947 80AE |
63+
| Name | Role | Github | Email | GPG Fingerprint |
64+
| ----------------- | ------------------------ | ------------------------------------------------ | ------------------------------------- | -------------------------------------------------- |
65+
| Christopher Allen | Principal Architect | [@ChristopherA](https://github.com/ChristopherA) | \<[email protected]\> | FDFE 14A5 4ECB 30FC 5D22 74EF F8D3 6C91 3574 05ED |
66+
| Wolf McNally | Lead Researcher/Engineer | [@WolfMcNally](https://github.com/wolfmcnally) | \<[email protected]\> | 9436 52EE 3844 1760 C3DC  3536 4B6C 2FCF 8947 80AE |
6667

6768
## Responsible Disclosure
6869

@@ -76,8 +77,8 @@ Please report suspected security vulnerabilities in private via email to Christo
7677

7778
The following keys may be used to communicate sensitive information to developers:
7879

79-
| Name | Fingerprint |
80-
| ----------------- | -------------------------------------------------- |
81-
| Christopher Allen | FDFE 14A5 4ECB 30FC 5D22 74EF F8D3 6C91 3574 05ED |
80+
| Name | Fingerprint |
81+
| ----------------- | ------------------------------------------------- |
82+
| Christopher Allen | FDFE 14A5 4ECB 30FC 5D22 74EF F8D3 6C91 3574 05ED |
8283

8384
You can import a key by running the following command with that individual’s fingerprint: `gpg --recv-keys "<fingerprint>"` Ensure that you put quotes around fingerprints that contain spaces.

src/lib.rs

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![doc(html_root_url = "https://docs.rs/bc-shamir/0.5.0")]
1+
#![doc(html_root_url = "https://docs.rs/bc-shamir/0.6.0")]
22
#![warn(rust_2018_idioms)]
33

44
//! ## Introduction
@@ -16,7 +16,7 @@
1616
//!
1717
//! ```toml
1818
//! [dependencies]
19-
//! bc-shamir = "0.5.0"
19+
//! bc-shamir = "0.6.0"
2020
//!```
2121
//!
2222
//! ## Usage
@@ -54,7 +54,6 @@
5454
//! # }
5555
//! ```
5656
57-
5857
/// The minimum length of a secret.
5958
pub const MIN_SECRET_LEN: usize = 16;
6059

@@ -71,7 +70,7 @@ mod error;
7170
pub use error::Error;
7271

7372
mod shamir;
74-
pub use shamir::{split_secret, recover_secret};
73+
pub use shamir::{recover_secret, split_secret};
7574

7675
#[cfg(test)]
7776
mod tests {
@@ -135,7 +134,10 @@ mod tests {
135134
assert_eq!(shares[4], hex!("1aa7fe3199bc5092ef3816b074cabdf2"));
136135

137136
let recovered_share_indexes = vec![1, 2, 4];
138-
let recovered_shares = recovered_share_indexes.iter().map(|index| shares[*index].clone()).collect::<Vec<_>>();
137+
let recovered_shares = recovered_share_indexes
138+
.iter()
139+
.map(|index| shares[*index].clone())
140+
.collect::<Vec<_>>();
139141
let recovered_secret = recover_secret(&recovered_share_indexes, &recovered_shares).unwrap();
140142
assert_eq!(recovered_secret, secret);
141143
}
@@ -148,16 +150,40 @@ mod tests {
148150
let shares = split_secret(2, 7, &secret, &mut rng).unwrap();
149151
assert_eq!(shares.len(), 7);
150152
//shares.iter().enumerate().for_each(|(index, share)| println!("{}: {}", index, hex::encode(share)));
151-
assert_eq!(shares[0], hex!("2dcd14c2252dc8489af3985030e74d5a48e8eff1478ab86e65b43869bf39d556"));
152-
assert_eq!(shares[1], hex!("a1dfdd798388aada635b9974472b4fc59a32ae520c42c9f6a0af70149b882487"));
153-
assert_eq!(shares[2], hex!("2ee99daf727c0c7773b89a18de64497ff7476dacd1015a45f482a893f7402cef"));
154-
assert_eq!(shares[3], hex!("a2fb5414d4d96ee58a109b3ca9a84be0259d2c0f9ac92bdd3199e0eed3f1dd3e"));
155-
assert_eq!(shares[4], hex!("2b851d188b8f5b3653659cc0f7fa45102dadf04b708767385cd803862fcb3c3f"));
156-
assert_eq!(shares[5], hex!("a797d4a32d2a39a4aacd9de48036478fff77b1e83b4f16a099c34bfb0b7acdee"));
157-
assert_eq!(shares[6], hex!("28a19475dcde9f09ba2e9e881979413592027216e60c8513cdee937c67b2c586"));
153+
assert_eq!(
154+
shares[0],
155+
hex!("2dcd14c2252dc8489af3985030e74d5a48e8eff1478ab86e65b43869bf39d556")
156+
);
157+
assert_eq!(
158+
shares[1],
159+
hex!("a1dfdd798388aada635b9974472b4fc59a32ae520c42c9f6a0af70149b882487")
160+
);
161+
assert_eq!(
162+
shares[2],
163+
hex!("2ee99daf727c0c7773b89a18de64497ff7476dacd1015a45f482a893f7402cef")
164+
);
165+
assert_eq!(
166+
shares[3],
167+
hex!("a2fb5414d4d96ee58a109b3ca9a84be0259d2c0f9ac92bdd3199e0eed3f1dd3e")
168+
);
169+
assert_eq!(
170+
shares[4],
171+
hex!("2b851d188b8f5b3653659cc0f7fa45102dadf04b708767385cd803862fcb3c3f")
172+
);
173+
assert_eq!(
174+
shares[5],
175+
hex!("a797d4a32d2a39a4aacd9de48036478fff77b1e83b4f16a099c34bfb0b7acdee")
176+
);
177+
assert_eq!(
178+
shares[6],
179+
hex!("28a19475dcde9f09ba2e9e881979413592027216e60c8513cdee937c67b2c586")
180+
);
158181

159182
let recovered_share_indexes = vec![3, 4];
160-
let recovered_shares = recovered_share_indexes.iter().map(|index| shares[*index].clone()).collect::<Vec<_>>();
183+
let recovered_shares = recovered_share_indexes
184+
.iter()
185+
.map(|index| shares[*index].clone())
186+
.collect::<Vec<_>>();
161187
let recovered_secret = recover_secret(&recovered_share_indexes, &recovered_shares).unwrap();
162188
assert_eq!(recovered_secret, secret);
163189
}

0 commit comments

Comments
 (0)