|
@@ -11,6 +11,7 @@ use serde_big_array::BigArray;
|
|
|
mod serde_tests;
|
|
|
|
|
|
mod crypto;
|
|
|
+use crypto::{Hash, Signature, Key};
|
|
|
|
|
|
/// A Block tagged with its version number.
|
|
|
#[allow(dead_code)]
|
|
@@ -136,30 +137,6 @@ struct Epoch(i64);
|
|
|
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Hashable)]
|
|
|
struct FragmentSerial(u32);
|
|
|
|
|
|
-/// A cryptographic hash.
|
|
|
-#[allow(dead_code)]
|
|
|
-#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Hashable)]
|
|
|
-enum Hash {
|
|
|
- Sha2_256([u8; 32]),
|
|
|
- #[serde(with = "BigArray")]
|
|
|
- Sha2_512([u8; 64]),
|
|
|
-}
|
|
|
-
|
|
|
-/// A cryptographic signature.
|
|
|
-#[allow(dead_code)]
|
|
|
-#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
|
|
-enum Signature {
|
|
|
- #[serde(with = "BigArray")]
|
|
|
- Ed25519([u8; 64]),
|
|
|
-}
|
|
|
-
|
|
|
-/// A cryptographic key.
|
|
|
-#[allow(dead_code)]
|
|
|
-#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
|
|
-enum Key {
|
|
|
- Xsalsa20Poly1305([u8; 32]),
|
|
|
-}
|
|
|
-
|
|
|
fn main() {
|
|
|
println!("Hello, world!");
|
|
|
}
|
|
@@ -298,32 +275,6 @@ impl<'s> TryFrom<&'s str> for Path {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-impl Key {
|
|
|
- /// Returns the data in the key as a slice.
|
|
|
- fn as_slice(&self) -> &[u8] {
|
|
|
- let Key::Xsalsa20Poly1305(array) = self;
|
|
|
- array
|
|
|
- }
|
|
|
-
|
|
|
- /// Returns the data in the key as a mutable slice.
|
|
|
- fn as_mut_slice(&mut self) -> &mut [u8] {
|
|
|
- let Key::Xsalsa20Poly1305(array) = self;
|
|
|
- array
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-impl AsRef<[u8]> for Key {
|
|
|
- fn as_ref(&self) -> &[u8] {
|
|
|
- self.as_slice()
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-impl AsMut<[u8]> for Key {
|
|
|
- fn as_mut(&mut self) -> &mut [u8] {
|
|
|
- self.as_mut_slice()
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
#[cfg(test)]
|
|
|
mod tests {
|
|
|
use super::*;
|