diff --git a/Cargo.lock b/Cargo.lock index b4c3abfe1efae86b3aa1be1060c1fed7c54b129e..8d8d33169531d4dfdecf39436c4c6919ca379a55 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -40,8 +40,8 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "duniter-keys" -version = "0.3.0" +name = "duniter-crypto" +version = "0.1.0" dependencies = [ "base58 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "base64 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -50,11 +50,11 @@ dependencies = [ [[package]] name = "duniter-protocol" -version = "0.2.0" +version = "0.3.0" dependencies = [ "base58 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "base64 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "duniter-keys 0.3.0", + "duniter-crypto 0.1.0", "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "linked-hash-map 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index c2e9aead4099b2c8caad969b0b019ba38df5df0e..6eccf045414c4c69515c9e2b30e691f50c0ee811 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [workspace] members = [ "wotb", - "keys", + "crypto", "protocol", ] diff --git a/keys/Cargo.toml b/crypto/Cargo.toml similarity index 71% rename from keys/Cargo.toml rename to crypto/Cargo.toml index 4b41f9dca79740bce4565b3b61ba72f5114d01e6..2ff539e5d6aa10f1124958d6b9d98290c8b8ae79 100644 --- a/keys/Cargo.toml +++ b/crypto/Cargo.toml @@ -1,8 +1,8 @@ [package] -name = "duniter-keys" -version = "0.3.0" +name = "duniter-crypto" +version = "0.1.0" authors = ["nanocryk <nanocryk@duniter.org>"] -description = "Manage cryptographic keys for the Duniter project." +description = "Manage cryptographic building blocks for the Duniter project." repository = "https://git.duniter.org/nodes/rust/duniter-rs" readme = "README.md" keywords = ["duniter", "keys", "cryptography"] diff --git a/crypto/README.md b/crypto/README.md new file mode 100644 index 0000000000000000000000000000000000000000..90a53c3c5cea2461dbeed9f0a29c279ae985aea4 --- /dev/null +++ b/crypto/README.md @@ -0,0 +1,7 @@ +# crypto + +`duniter-crypto` is a crate managing cryptographic building blocks for the Duniter project. + +## How to use it + +You can add `duniter-crypto` as a `cargo` dependency in your Rust project. diff --git a/keys/ed25519.rs b/crypto/keys/ed25519.rs similarity index 99% rename from keys/ed25519.rs rename to crypto/keys/ed25519.rs index 72cc61fbaf750f932ab1ca25536f21c55b3b481b..a3278a8abc0cfd2d02541775d36a60bb8c020429 100644 --- a/keys/ed25519.rs +++ b/crypto/keys/ed25519.rs @@ -312,7 +312,7 @@ impl KeyPairFromSaltedPasswordGenerator { #[cfg(test)] mod tests { use super::*; - use {KeyPair, Signature}; + use keys::{KeyPair, Signature}; #[test] fn base58_private_key() { diff --git a/keys/lib.rs b/crypto/keys/mod.rs similarity index 93% rename from keys/lib.rs rename to crypto/keys/mod.rs index 9b41694458270e08c5381919e60b93f31c1bda12..49b561418b1cbbd17d2095f9e29e3f3e4d9ae1d8 100644 --- a/keys/lib.rs +++ b/crypto/keys/mod.rs @@ -21,8 +21,8 @@ //! # Usage //! //! ``` -//! use duniter_keys::{Signature, PublicKey, PrivateKey, KeyPair}; -//! use duniter_keys::ed25519::KeyPairFromSaltedPasswordGenerator; +//! use duniter_crypto::keys::{Signature, PublicKey, PrivateKey, KeyPair}; +//! use duniter_crypto::keys::ed25519::KeyPairFromSaltedPasswordGenerator; //! //! let generator = KeyPairFromSaltedPasswordGenerator::with_default_parameters(); //! @@ -46,14 +46,6 @@ //! `ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/` //! with `=` as padding character. -#![deny(missing_docs, missing_debug_implementations, missing_copy_implementations, trivial_casts, - trivial_numeric_casts, unsafe_code, unstable_features, unused_import_braces, - unused_qualifications)] - -extern crate base58; -extern crate base64; -extern crate crypto; - use std::fmt::Display; use std::fmt::Debug; diff --git a/crypto/lib.rs b/crypto/lib.rs new file mode 100644 index 0000000000000000000000000000000000000000..d15f775578669fa2fc4821b9e48d8c16ebe4af18 --- /dev/null +++ b/crypto/lib.rs @@ -0,0 +1,26 @@ +// Copyright (C) 2018 The Duniter Project Developers. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see <https://www.gnu.org/licenses/>. + +//! Provide wrappers for cryptographic building blocks used by Duniter. + +#![deny(missing_docs, missing_debug_implementations, missing_copy_implementations, trivial_casts, + trivial_numeric_casts, unsafe_code, unstable_features, unused_import_braces, + unused_qualifications)] + +extern crate base58; +extern crate base64; +extern crate crypto; + +pub mod keys; diff --git a/keys/README.md b/keys/README.md deleted file mode 100644 index 288814b3ab032d5e36b5201d0eda571fd0f020b5..0000000000000000000000000000000000000000 --- a/keys/README.md +++ /dev/null @@ -1,9 +0,0 @@ -# keys - -`keys` is a crate managing cryptographic keys for the Duniter project. - -[Duniter]: https://duniter.org/en/ - -## How to use it - -You can add `duniter-keys` as a `cargo` dependency in your Rust project. diff --git a/protocol/Cargo.toml b/protocol/Cargo.toml index 09c94e70e3c00abc4f8c85bd1c5b8a0832672b39..b92ef593aecb01eaeab107c6f9958d537f008c94 100644 --- a/protocol/Cargo.toml +++ b/protocol/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "duniter-protocol" -version = "0.2.0" +version = "0.3.0" authors = ["nanocryk <nanocryk@duniter.org>"] description = "Implements the Duniter Protocol" repository = "https://git.duniter.org/nodes/rust/duniter-rs" @@ -18,4 +18,4 @@ base58 = "0.1.0" base64 = "0.8.0" lazy_static = "1.0.0" regex = "0.2" -duniter-keys = { path = "../keys" } +duniter-crypto = { path = "../crypto" } diff --git a/protocol/blockchain/mod.rs b/protocol/blockchain/mod.rs index ae0624f12298c7b6d8a878666142022a00fc990c..3d20cc64ff949e3fb8276ac14e2fd6b6a328afc8 100644 --- a/protocol/blockchain/mod.rs +++ b/protocol/blockchain/mod.rs @@ -17,7 +17,7 @@ use std::fmt::Debug; -use duniter_keys::{PrivateKey, PublicKey}; +use duniter_crypto::keys::{PrivateKey, PublicKey}; pub mod v10; @@ -138,7 +138,7 @@ pub trait DocumentParser<S, D, E> { #[cfg(test)] mod tests { use super::*; - use duniter_keys::{Signature, ed25519}; + use duniter_crypto::keys::{Signature, ed25519}; // simple text document for signature testing #[derive(Debug, Clone)] diff --git a/protocol/blockchain/v10/documents/identity.rs b/protocol/blockchain/v10/documents/identity.rs index 5720908d02bd4e716a7281a1b5b98f026fb728ae..36aa5a61635fb3c4f82fb772e241c787b1ed9dde 100644 --- a/protocol/blockchain/v10/documents/identity.rs +++ b/protocol/blockchain/v10/documents/identity.rs @@ -15,7 +15,7 @@ //! Wrappers around Identity documents. -use duniter_keys::{PublicKey, ed25519}; +use duniter_crypto::keys::{PublicKey, ed25519}; use regex::Regex; use Blockstamp; @@ -198,7 +198,7 @@ impl StandardTextDocumentParser for IdentityDocumentParser { #[cfg(test)] mod tests { use super::*; - use duniter_keys::{PrivateKey, PublicKey, Signature}; + use duniter_crypto::keys::{PrivateKey, PublicKey, Signature}; use blockchain::VerificationResult; #[test] diff --git a/protocol/blockchain/v10/documents/mod.rs b/protocol/blockchain/v10/documents/mod.rs index 681d2be6604efb3f050e8873bf7f1a2f9dfeb60a..b3c9d92822ec94cdc4b8f0359f3d518925298ffa 100644 --- a/protocol/blockchain/v10/documents/mod.rs +++ b/protocol/blockchain/v10/documents/mod.rs @@ -15,7 +15,7 @@ //! Provide wrappers around Duniter blockchain documents for protocol version 10. -use duniter_keys::{Signature, ed25519}; +use duniter_crypto::keys::{Signature, ed25519}; use regex::Regex; use blockchain::{Document, DocumentBuilder, DocumentParser}; use blockchain::v10::documents::identity::IdentityDocumentParser; @@ -99,7 +99,7 @@ pub trait TextDocumentBuilder: DocumentBuilder { &self, private_keys: Vec<ed25519::PrivateKey>, ) -> (String, Vec<ed25519::Signature>) { - use duniter_keys::PrivateKey; + use duniter_crypto::keys::PrivateKey; let text = self.generate_text(); diff --git a/protocol/lib.rs b/protocol/lib.rs index 84908914a5384bc2eed4cb7a35b5510681199504..c33934d42f43bb28863baa913d5bd80735f0de2a 100644 --- a/protocol/lib.rs +++ b/protocol/lib.rs @@ -22,7 +22,7 @@ extern crate base58; extern crate base64; extern crate crypto; -extern crate duniter_keys; +extern crate duniter_crypto; #[macro_use] extern crate lazy_static; extern crate linked_hash_map; @@ -30,7 +30,7 @@ extern crate regex; use std::fmt::{Debug, Display, Error, Formatter}; -use duniter_keys::BaseConvertionError; +use duniter_crypto::keys::BaseConvertionError; pub mod blockchain;