From 81d8d7bfcc637cfac59cadd702c28abc34b14aa7 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Wed, 10 May 2023 19:00:08 +0200 Subject: [PATCH] reenable some features --- Cargo.toml | 7 +++---- src/buf/mod.rs | 6 +++--- src/crypto/mod.rs | 4 ++-- src/lib.rs | 4 +++- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c316a81..ac4c7f8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,9 +15,8 @@ base64 = "0.13" hex = "0.4" err-derive = "0.3" -dryoc = { version = "0.4", optional = true } -serde = { version = "1.0", optional = true, default-features = false, features = ["derive"] } +dryoc = { version = "0.5", optional = true } +serde = { version = "1.0", optional = true, features = ["derive"] } [features] -#default = [ "dryoc", "serde" ] -#default = [ "serde" ] +default = [ "dryoc", "serde" ] diff --git a/src/buf/mod.rs b/src/buf/mod.rs index ccfb755..24c4409 100644 --- a/src/buf/mod.rs +++ b/src/buf/mod.rs @@ -1,4 +1,4 @@ -pub mod decode; +mod decode; use std::borrow::Cow; @@ -6,9 +6,9 @@ use crate::is_string_char; pub use decode::*; -pub const STR_INLINE_MAX: usize = 18; +pub(crate) const STR_INLINE_MAX: usize = 18; -pub type Pos = u32; +pub(crate) type Pos = u32; #[derive(Clone, Copy, Debug)] pub struct ITerm(Pos); diff --git a/src/crypto/mod.rs b/src/crypto/mod.rs index a5bce00..9e1d98c 100644 --- a/src/crypto/mod.rs +++ b/src/crypto/mod.rs @@ -38,8 +38,8 @@ pub fn compute_signature(message: &[u8], secret_key: &sign::SecretKey) -> sign:: /// Verify the ed25519 signature of a message using a public key pub fn verify_signature( - signature: &sign::Signature, - message: &[u8], + signature: sign::Signature, + message: Vec, public_key: &sign::PublicKey, ) -> bool { sign::SignedMessage::from_parts(signature.clone(), message) diff --git a/src/lib.rs b/src/lib.rs index 589c2a8..10168e8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,7 @@ //! A text-based data format for cryptographic network protocols. //! //! ``` +//! #[cfg(feature = "dryoc")] { //! use nettext::enc::*; //! use nettext::dec::*; //! use nettext::crypto::*; @@ -46,10 +47,11 @@ //! //! let [verb, arg1, arg2, pubkey] = object2.seq_of().unwrap(); //! let pubkey = pubkey.public_key().unwrap(); -//! assert!(verify_signature(&signature, payload.raw(), &pubkey)); +//! assert!(verify_signature(signature, payload.raw().to_vec(), &pubkey)); //! //! assert_eq!(verb.string().unwrap(), "CALL"); //! assert_eq!(arg1.string().unwrap(), "myfunction"); +//! } //! ``` //! //! The value of `signed_payload` would be as follows: