Skip to content

Commit

Permalink
[crypto] assert private keys not cloneable
Browse files Browse the repository at this point in the history
Closes: #1484
Approved by: huitseeker
  • Loading branch information
bmwill authored and bors-libra committed Nov 1, 2019
1 parent ebaf0a6 commit d74c33e
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 5 deletions.
8 changes: 7 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions crypto/crypto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ rand = "0.6.5"
serde = { version = "1.0.96", features = ["derive"] }
sha2 = "0.8.0"
sha3 = "0.8.2"
static_assertions = { version = "1.0.0", optional = true }
threshold_crypto = "0.3"
tiny-keccak = "1.5.0"
x25519-dalek = { git = "https://github.com/calibra/x25519-dalek.git", branch = "fiat", default-features = false }
Expand All @@ -43,6 +44,7 @@ ripemd160 = "0.8.0"

[features]
default = ["std", "u64_backend"]
assert-private-keys-not-cloneable = ["static_assertions"]
cloneable-private-keys = []
fuzzing = ["proptest", "proptest-derive", "cloneable-private-keys"]
std = ["curve25519-dalek/std", "ed25519-dalek/std", "x25519-dalek/std"]
Expand Down
3 changes: 3 additions & 0 deletions crypto/crypto/src/bls12381.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ type ThresholdBLSPrivateKey =
#[derive(Serialize, Deserialize, Deref, SilentDisplay, SilentDebug)]
pub struct BLS12381PrivateKey(ThresholdBLSPrivateKey);

#[cfg(feature = "assert-private-keys-not-cloneable")]
static_assertions::assert_not_impl_any!(BLS12381PrivateKey: Clone);

/// A BLS12-381 public key.
#[derive(Clone, Hash, Serialize, Deserialize, Deref, Debug, PartialEq, Eq)]
pub struct BLS12381PublicKey(threshold_crypto::PublicKey);
Expand Down
3 changes: 3 additions & 0 deletions crypto/crypto/src/ed25519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ const L: [u8; 32] = [
#[derive(SilentDisplay, SilentDebug)]
pub struct Ed25519PrivateKey(ed25519_dalek::SecretKey);

#[cfg(feature = "assert-private-keys-not-cloneable")]
static_assertions::assert_not_impl_any!(Ed25519PrivateKey: Clone);

/// An Ed25519 public key
#[derive(Clone, Debug)]
pub struct Ed25519PublicKey(ed25519_dalek::PublicKey);
Expand Down
5 changes: 1 addition & 4 deletions libra-node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ storage-service = { path = "../storage/storage-service", version = "0.1.0" }
libra-types = { path = "../types", version = "0.1.0" }
vm-runtime = { path = "../language/vm/vm-runtime", version = "0.1.0" }

[dev-dependencies]
config-builder = { path = "../config/config-builder", version = "0.1.0" }

[features]
default = []
fuzzing = ["libra-types/fuzzing"]
assert-private-keys-not-cloneable = ["libra-crypto/assert-private-keys-not-cloneable"]
1 change: 1 addition & 0 deletions x.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[package-exceptions]
libra-crypto = { path = "crypto/crypto", all-features = false }
libra-node = { path = "libra-node" }
testsuite = { path = "testsuite", system = true }

[clippy]
Expand Down

0 comments on commit d74c33e

Please sign in to comment.