Commit 44685aae authored by Éloïs's avatar Éloïs

[ref] crypto: isolate bases convert & improve BaseConvertionError

parent 82a7b650
Pipeline #4554 passed with stages
in 10 minutes and 59 seconds
......@@ -245,10 +245,8 @@ dependencies = [
name = "dubp-documents"
version = "0.11.0"
dependencies = [
"base58 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"base64 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)",
"byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
"dup-crypto 0.5.0",
"dup-crypto 0.6.0",
"durs-common-tools 0.1.0",
"failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"json-pest-parser 0.1.0",
......@@ -267,7 +265,7 @@ dependencies = [
"dirs 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"dubp-documents 0.11.0",
"duniter-module 0.1.0-a0.1",
"dup-crypto 0.5.0",
"dup-crypto 0.6.0",
"durs-common-tools 0.1.0",
"rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
"rpassword 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -284,7 +282,7 @@ dependencies = [
"duniter-conf 0.1.0-a0.1",
"duniter-module 0.1.0-a0.1",
"duniter-network 0.1.0-a0.1",
"dup-crypto 0.5.0",
"dup-crypto 0.6.0",
"durs-blockchain 0.1.0-a0.1",
"durs-message 0.1.0-a0.1",
"durs-network-documents 0.3.0",
......@@ -303,7 +301,7 @@ name = "duniter-module"
version = "0.1.0-a0.1"
dependencies = [
"dubp-documents 0.11.0",
"dup-crypto 0.5.0",
"dup-crypto 0.6.0",
"durs-network-documents 0.3.0",
"serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -317,7 +315,7 @@ version = "0.1.0-a0.1"
dependencies = [
"dubp-documents 0.11.0",
"duniter-module 0.1.0-a0.1",
"dup-crypto 0.5.0",
"dup-crypto 0.6.0",
"durs-network-documents 0.3.0",
"serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -327,7 +325,7 @@ dependencies = [
[[package]]
name = "dup-crypto"
version = "0.5.0"
version = "0.6.0"
dependencies = [
"base58 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"base64 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -359,7 +357,7 @@ dependencies = [
"duniter-conf 0.1.0-a0.1",
"duniter-module 0.1.0-a0.1",
"duniter-network 0.1.0-a0.1",
"dup-crypto 0.5.0",
"dup-crypto 0.6.0",
"durs-blockchain-dal 0.1.0-a0.1",
"durs-common-tools 0.1.0",
"durs-message 0.1.0-a0.1",
......@@ -383,7 +381,7 @@ version = "0.1.0-a0.1"
dependencies = [
"dubp-documents 0.11.0",
"duniter-module 0.1.0-a0.1",
"dup-crypto 0.5.0",
"dup-crypto 0.6.0",
"durs-wot 0.8.0-a0.9",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"rustbreak 2.0.0-rc3 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -407,7 +405,7 @@ dependencies = [
"dubp-documents 0.11.0",
"duniter-module 0.1.0-a0.1",
"duniter-network 0.1.0-a0.1",
"dup-crypto 0.5.0",
"dup-crypto 0.6.0",
"durs-network-documents 0.3.0",
"serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -421,7 +419,7 @@ dependencies = [
"base58 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"bincode 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"dubp-documents 0.11.0",
"dup-crypto 0.5.0",
"dup-crypto 0.6.0",
"hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"pest 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"pest_derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -438,7 +436,7 @@ dependencies = [
"duniter-conf 0.1.0-a0.1",
"duniter-module 0.1.0-a0.1",
"duniter-network 0.1.0-a0.1",
"dup-crypto 0.5.0",
"dup-crypto 0.6.0",
"durs-message 0.1.0-a0.1",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -455,7 +453,7 @@ dependencies = [
"duniter-conf 0.1.0-a0.1",
"duniter-module 0.1.0-a0.1",
"duniter-network 0.1.0-a0.1",
"dup-crypto 0.5.0",
"dup-crypto 0.6.0",
"durs-message 0.1.0-a0.1",
"durs-network-documents 0.3.0",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -486,7 +484,7 @@ dependencies = [
"duniter-conf 0.1.0-a0.1",
"duniter-module 0.1.0-a0.1",
"duniter-network 0.1.0-a0.1",
"dup-crypto 0.5.0",
"dup-crypto 0.6.0",
"durs-message 0.1.0-a0.1",
"durs-network-documents 0.3.0",
"durs-ws2p-messages 0.1.0-a0.1",
......@@ -505,7 +503,7 @@ dependencies = [
"bincode 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
"dubp-documents 0.11.0",
"dup-crypto 0.5.0",
"dup-crypto 0.6.0",
"durs-network-documents 0.3.0",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"pretty_assertions 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -523,7 +521,7 @@ dependencies = [
"duniter-conf 0.1.0-a0.1",
"duniter-module 0.1.0-a0.1",
"duniter-network 0.1.0-a0.1",
"dup-crypto 0.5.0",
"dup-crypto 0.6.0",
"durs-message 0.1.0-a0.1",
"durs-network-documents 0.3.0",
"durs-wot 0.8.0-a0.9",
......
[package]
name = "dup-crypto"
version = "0.5.0"
version = "0.6.0"
authors = ["nanocryk <nanocryk@duniter.org>", "elois <elois@duniter.org>"]
description = "Manage cryptographic operations for the DUP (DUniter Protocol)."
repository = "https://git.duniter.org/nodes/rust/duniter-rs"
......
// Copyright (C) 2018 The Durs 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 base16 convertion tools
use crate::bases::BaseConvertionError;
/// Convert a hexadecimal string in an array of 32 bytes.
///
/// The hex string must only contains hex characters
/// and produce a 32 bytes value.
pub fn str_hex_to_32bytes(text: &str) -> Result<[u8; 32], BaseConvertionError> {
if text.len() != 64 {
Err(BaseConvertionError::InvalidLength {
expected: 64,
found: text.len(),
})
} else {
let mut bytes = [0u8; 32];
let chars: Vec<char> = text.chars().collect();
for i in 0..64 {
if i % 2 != 0 {
continue;
}
let byte1 = chars[i].to_digit(16);
let byte2 = chars[i + 1].to_digit(16);
if byte1.is_none() {
return Err(BaseConvertionError::InvalidCharacter {
character: chars[i],
offset: i,
});
} else if byte2.is_none() {
return Err(BaseConvertionError::InvalidCharacter {
character: chars[i + 1],
offset: i + 1,
});
}
let byte1 = byte1.unwrap() as u8;
let byte2 = byte2.unwrap() as u8;
let byte = (byte1 << 4) | byte2;
bytes[i / 2] = byte;
}
Ok(bytes)
}
}
// Copyright (C) 2018 The Durs 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 base58 convertion tools
pub use base58::ToBase58;
use crate::bases::BaseConvertionError;
use base58::{FromBase58, FromBase58Error};
/// Create an array of 32 bytes from a Base58 string.
pub fn str_base58_to_32bytes(base58_data: &str) -> Result<[u8; 32], BaseConvertionError> {
match base58_data.from_base58() {
Ok(result) => {
if result.len() == 32 {
let mut u8_array = [0; 32];
u8_array[..32].clone_from_slice(&result[..32]);
Ok(u8_array)
} else {
Err(BaseConvertionError::InvalidLength {
expected: 32,
found: result.len(),
})
}
}
Err(FromBase58Error::InvalidBase58Character(character, offset)) => {
Err(BaseConvertionError::InvalidCharacter { character, offset })
}
Err(FromBase58Error::InvalidBase58Length) => {
Err(BaseConvertionError::InvalidBaseConverterLength)
}
}
}
/// Create an array of 64bytes from a Base58 string.
pub fn str_base58_to_64bytes(base58_data: &str) -> Result<[u8; 64], BaseConvertionError> {
match base58_data.from_base58() {
Ok(result) => {
if result.len() == 64 {
let mut u8_array = [0; 64];
u8_array[..64].clone_from_slice(&result[..64]);
Ok(u8_array)
} else {
Err(BaseConvertionError::InvalidLength {
expected: 64,
found: result.len(),
})
}
}
Err(FromBase58Error::InvalidBase58Character(character, offset)) => {
Err(BaseConvertionError::InvalidCharacter { character, offset })
}
Err(FromBase58Error::InvalidBase58Length) => {
Err(BaseConvertionError::InvalidBaseConverterLength)
}
}
}
// Copyright (C) 2018 The Durs 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 base64 convertion tools
use crate::bases::BaseConvertionError;
/// Create an array of 64 bytes from a Base64 string.
pub fn str_base64_to64bytes(base64_data: &str) -> Result<[u8; 64], BaseConvertionError> {
let result = base64::decode(base64_data)?;
if result.len() == 64 {
let mut u8_array = [0; 64];
u8_array[..64].clone_from_slice(&base64::decode(base64_data)?[..64]);
Ok(u8_array)
} else {
Err(BaseConvertionError::InvalidLength {
found: result.len(),
expected: 64,
})
}
}
// Copyright (C) 2018 The Durs 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 base convertion tools
/// Base16 conversion tools
pub mod b16;
/// Base58 conversion tools
pub mod b58;
/// Base64 conversion tools
pub mod b64;
/// Errors enumeration for Base58/64 strings convertion.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Fail)]
pub enum BaseConvertionError {
#[fail(
display = "Data have invalid key length : expected {}, found {}.",
expected, found
)]
/// Data have invalid length.
InvalidLength {
/// Expected length
expected: usize,
/// Actual length
found: usize,
},
#[fail(display = "Invalid character '{}' at offset {}.", character, offset)]
/// Base58/64 have an invalid character.
InvalidCharacter {
/// Character
character: char,
/// Offset (=position)
offset: usize,
},
#[fail(display = "Invalid base converter length.")]
/// Base58/64 have invalid lendth
InvalidBaseConverterLength,
#[fail(display = "Invalid last symbol '{}' at offset {}.", symbol, offset)]
/// Base64 have invalid last symbol (symbol, offset)
InvalidLastSymbol {
/// Symbol
symbol: u8,
/// Offset (=position)
offset: usize,
},
}
impl From<base64::DecodeError> for BaseConvertionError {
fn from(err: base64::DecodeError) -> Self {
match err {
base64::DecodeError::InvalidByte(offset, byte) => {
BaseConvertionError::InvalidCharacter {
character: byte as char,
offset,
}
}
base64::DecodeError::InvalidLength => BaseConvertionError::InvalidBaseConverterLength,
base64::DecodeError::InvalidLastSymbol(offset, symbol) => {
BaseConvertionError::InvalidLastSymbol { symbol, offset }
}
}
}
}
......@@ -15,7 +15,7 @@
//! Provide wrappers for cryptographic hashs
use crate::keys::BaseConvertionError;
use crate::bases::*;
use crypto::digest::Digest;
use crypto::sha2::Sha256;
use rand::{thread_rng, Rng};
......@@ -93,36 +93,8 @@ impl Hash {
///
/// The hex string must only contains hex characters
/// and produce a 32 bytes value.
#[inline]
pub fn from_hex(text: &str) -> Result<Hash, BaseConvertionError> {
if text.len() != 64 {
Err(BaseConvertionError::InvalidKeyLendth(text.len(), 64))
} else {
let mut hash = Hash([0u8; 32]);
let chars: Vec<char> = text.chars().collect();
for i in 0..64 {
if i % 2 != 0 {
continue;
}
let byte1 = chars[i].to_digit(16);
let byte2 = chars[i + 1].to_digit(16);
if byte1.is_none() {
return Err(BaseConvertionError::InvalidCharacter(chars[i], i));
} else if byte2.is_none() {
return Err(BaseConvertionError::InvalidCharacter(chars[i + 1], i + 1));
}
let byte1 = byte1.unwrap() as u8;
let byte2 = byte2.unwrap() as u8;
let byte = (byte1 << 4) | byte2;
hash.0[i / 2] = byte;
}
Ok(hash)
}
Ok(Hash(b16::str_hex_to_32bytes(text)?))
}
}
......@@ -19,10 +19,10 @@
//!
//! [`KeyPairGenerator`]: struct.KeyPairGenerator.html
use super::{BaseConvertionError, PrivateKey as PrivateKeyMethods, PublicKey as PublicKeyMethods};
use base58::{FromBase58, FromBase58Error, ToBase58};
use super::{PrivateKey as PrivateKeyMethods, PublicKey as PublicKeyMethods};
use crate::bases::*;
use base58::ToBase58;
use base64;
use base64::DecodeError;
use crypto;
use serde::de::{Deserialize, Deserializer, Error, SeqAccess, Visitor};
use serde::ser::{Serialize, SerializeTuple, Serializer};
......@@ -99,29 +99,9 @@ impl<'de> Deserialize<'de> for Signature {
}
impl super::Signature for Signature {
#[inline]
fn from_base64(base64_data: &str) -> Result<Signature, BaseConvertionError> {
match base64::decode(base64_data) {
Ok(result) => {
if result.len() == 64 {
let mut u8_array = [0; 64];
u8_array[..64].clone_from_slice(&result[..64]);
Ok(Signature(u8_array))
} else {
Err(BaseConvertionError::InvalidKeyLendth(result.len(), 64))
}
}
Err(DecodeError::InvalidByte(pos, byte)) => {
Err(BaseConvertionError::InvalidCharacter(byte as char, pos))
}
Err(DecodeError::InvalidLength) => {
Err(BaseConvertionError::InvalidBaseConverterLength())
}
Err(DecodeError::InvalidLastSymbol(pos, byte)) => {
Err(BaseConvertionError::InvalidCharacter(byte as char, pos))
}
}
Ok(Signature(b64::str_base64_to64bytes(base64_data)?))
}
fn to_bytes_vector(&self) -> Vec<u8> {
......@@ -187,26 +167,9 @@ impl Debug for PublicKey {
impl super::PublicKey for PublicKey {
type Signature = Signature;
#[inline]
fn from_base58(base58_data: &str) -> Result<Self, BaseConvertionError> {
match base58_data.from_base58() {
Ok(result) => {
if result.len() == 32 {
let mut u8_array = [0; 32];
u8_array[..32].clone_from_slice(&result[..32]);
Ok(PublicKey(u8_array))
} else {
Err(BaseConvertionError::InvalidKeyLendth(result.len(), 32))
}
}
Err(FromBase58Error::InvalidBase58Character(character, pos)) => {
Err(BaseConvertionError::InvalidCharacter(character, pos))
}
Err(FromBase58Error::InvalidBase58Length) => {
Err(BaseConvertionError::InvalidBaseConverterLength())
}
}
Ok(PublicKey(b58::str_base58_to_32bytes(base58_data)?))
}
fn to_bytes_vector(&self) -> Vec<u8> {
......@@ -257,26 +220,9 @@ impl Eq for PrivateKey {}
impl super::PrivateKey for PrivateKey {
type Signature = Signature;
#[inline]
fn from_base58(base58_data: &str) -> Result<Self, BaseConvertionError> {
match base58_data.from_base58() {
Ok(result) => {
if result.len() == 64 {
let mut u8_array = [0; 64];
u8_array[..64].clone_from_slice(&result[..64]);
Ok(PrivateKey(u8_array))
} else {
Err(BaseConvertionError::InvalidKeyLendth(result.len(), 64))
}
}
Err(FromBase58Error::InvalidBase58Character(character, pos)) => {
Err(BaseConvertionError::InvalidCharacter(character, pos))
}
Err(FromBase58Error::InvalidBase58Length) => {
Err(BaseConvertionError::InvalidBaseConverterLength())
}
}
Ok(PrivateKey(b58::str_base58_to_64bytes(base58_data)?))
}
/// Sign a message with this private key.
......@@ -406,6 +352,7 @@ impl KeyPairFromSaltedPasswordGenerator {
mod tests {
use super::*;
use crate::keys::{KeyPair, Signature};
use base58::FromBase58;
#[test]
fn base58_private_key() {
......@@ -430,21 +377,27 @@ mod tests {
"468Q1XtTq7h84NorZdWBZFJrGkB18CbmbHr9tkp9snt5GiERP7ySs3wM8myLccbAAGejgMRC9rqnXuW3iA\
fZACm7djh",
).unwrap_err(),
BaseConvertionError::InvalidKeyLendth(67, 64)
BaseConvertionError::InvalidLength { found: 67, expected: 64 }
);
assert_eq!(
super::PrivateKey::from_base58(
"468Q1XtTq7h84NorZdWBZFJrGkB18CbmbHr9tkp9snt5GiERP7ySs3wM8myLccbAAGejgMRC9",
)
.unwrap_err(),
BaseConvertionError::InvalidKeyLendth(53, 64)
BaseConvertionError::InvalidLength {
found: 53,
expected: 64
}
);
assert_eq!(
super::PrivateKey::from_base58(
"468Q1XtTq7h84NorZdWBZFJrGkB18CbmbHr9tkp9snt5GiERP7ySs3wM8myLccbAAGejgMRC9<<",
)
.unwrap_err(),
BaseConvertionError::InvalidCharacter('<', 73)
BaseConvertionError::InvalidCharacter {
character: '<',
offset: 73
}
);
}
......@@ -464,17 +417,26 @@ mod tests {
assert_eq!(
super::PublicKey::from_base58("DNann1Lh55eZMEDXeYt59bzHbA3NJR46DeQYCS2qQdLVdjq")
.unwrap_err(),
BaseConvertionError::InvalidKeyLendth(35, 32)
BaseConvertionError::InvalidLength {
found: 35,
expected: 32
}
);
assert_eq!(
super::PublicKey::from_base58("DNann1Lh55eZMEDXeYt59bzHbA3NJR46DeQYCS2qQd")
.unwrap_err(),
BaseConvertionError::InvalidKeyLendth(31, 32)
BaseConvertionError::InvalidLength {
found: 31,
expected: 32
}
);
assert_eq!(
super::PublicKey::from_base58("DNann1Lh55eZMEDXeYt59bzHbA3NJR46DeQYCS2qQd<<")
.unwrap_err(),
BaseConvertionError::InvalidCharacter('<', 42)
BaseConvertionError::InvalidCharacter {
character: '<',
offset: 42
}
);
}
......@@ -491,7 +453,10 @@ mod tests {
assert_eq!(
super::Signature::from_base64("YmhlaW9iaHNlcGlvaGVvaXNlcGl2ZXBvdm5pc2U=").unwrap_err(),
BaseConvertionError::InvalidKeyLendth(29, 64)
BaseConvertionError::InvalidLength {
found: 29,
expected: 64
}
);
assert_eq!(
super::Signature::from_base64(
......@@ -499,7 +464,10 @@ mod tests {
2V2Z3BpaHNlamVwZ25qZXNqb2dwZWpnaW9zZXNkdnNic3JicmJyZGJyZGI=",
)
.unwrap_err(),
BaseConvertionError::InvalidKeyLendth(86, 64)
BaseConvertionError::InvalidLength {
found: 86,
expected: 64
}
);
assert_eq!(
super::Signature::from_base64(
......@@ -507,7 +475,10 @@ mod tests {
mQCRerlF/3pc4sAcsnexsxBseA/3lY03KlONqJBAgdha<<",
)
.unwrap_err(),
BaseConvertionError::InvalidCharacter('<', 89)
BaseConvertionError::InvalidCharacter {
character: '<',
offset: 89
}
);
}
......
......@@ -46,6 +46,7 @@
//! `ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`
//! with `=` as padding character.
use crate::bases::BaseConvertionError;
use base58::ToBase58;
use bincode;
use std::fmt::Debug;
......@@ -73,20 +74,6 @@ pub trait GetKeysAlgo: Clone + Debug + PartialEq + Eq {
fn algo(&self) -> KeysAlgo;
}
/// Errors enumeration for Base58/64 strings convertion.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Fail)]
pub enum BaseConvertionError {
#[fail(display = "Data have invalid key length.")]
/// Data have invalid key length (found, expected).
InvalidKeyLendth(usize, usize),
#[fail(display = "Invalid character.")]
/// Base58 have an invalid character.
InvalidCharacter(char, usize),
#[fail(display = "Invalid base converter length.")]
/// Base58 have invalid lendth
InvalidBaseConverterLength(),
}
/// Errors enumeration for signature verification.
#[derive(Debug)]
pub enum SigError {
......
......@@ -34,5 +34,6 @@ extern crate failure;
#[macro_use]
extern crate serde_derive;
pub mod bases;
pub mod hashs;
pub mod keys;
......@@ -17,6 +17,7 @@ use crate::documents::block::{BlockDocument, BlockV10Parameters, TxDocOrTxHash};
use crate::documents::membership::MembershipType;
use crate::parsers::DefaultHasher;
use crate::*;
use dup_crypto::bases::BaseConvertionError;
use dup_crypto::hashs::Hash;
use dup_crypto::keys::*;
use failure::Error;
......
......@@ -17,6 +17,7 @@ use crate::documents::transaction::*;
use crate::parsers::DefaultHasher;
use crate::TextDocumentParseError;
use crate::*;
use dup_crypto::bases::BaseConvertionError;
use dup_crypto::hashs::Hash;
use dup_crypto::keys::*;
use failure::Error;
......
......@@ -19,6 +19,7 @@ use crate::network_head_v2::*;
use crate::network_head_v3::*;
use crate::{NodeFullId, NodeId};
use dubp_documents::blockstamp::*;
use dup_crypto::bases::BaseConvertionError;
use dup_crypto::keys::*;
use serde_json;
use std::collections::HashMap;
......
......@@ -17,6 +17,7 @@
use crate::NodeId;
use dubp_documents::blockstamp::*;
use dup_crypto::bases::BaseConvertionError;
use dup_crypto::keys::*;
use std::cmp::Ordering;
use std::num::ParseIntError;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment