From b13801825649e884c3335498f92b7e0ca7887abd Mon Sep 17 00:00:00 2001 From: zhenfei Date: Fri, 3 Jan 2020 11:49:40 -0500 Subject: [PATCH 1/9] enable zeroized --- Cargo.toml | 1 + ff_derive/src/lib.rs | 2 +- src/lib.rs | 7 ++++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index eeab765..d181a8b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,6 +14,7 @@ edition = "2018" byteorder = "1" ff_derive = { version = "0.4.0", path = "ff_derive", optional = true } rand_core = "0.5" +zeroize = {version = "1.1", features = ["zeroize_derive"]} [features] default = [] diff --git a/ff_derive/src/lib.rs b/ff_derive/src/lib.rs index 5e56e74..92213cb 100644 --- a/ff_derive/src/lib.rs +++ b/ff_derive/src/lib.rs @@ -116,7 +116,7 @@ fn fetch_attr(name: &str, attrs: &[syn::Attribute]) -> Option { // Implement PrimeFieldRepr for the wrapped ident `repr` with `limbs` limbs. fn prime_field_repr_impl(repr: &syn::Ident, limbs: usize) -> proc_macro2::TokenStream { quote! { - #[derive(Copy, Clone, PartialEq, Eq, Default)] + #[derive(Copy, Clone, PartialEq, Eq, Default, Zeroize)] pub struct #repr(pub [u64; #limbs]); impl ::std::fmt::Debug for #repr diff --git a/src/lib.rs b/src/lib.rs index c66163d..9518dba 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -11,14 +11,18 @@ extern crate ff_derive; #[cfg(feature = "derive")] pub use ff_derive::*; +#[macro_use] +extern crate zeroize; + use rand_core::RngCore; use std::error::Error; use std::fmt; use std::io::{self, Read, Write}; +use zeroize::Zeroize; /// This trait represents an element of a field. pub trait Field: - Sized + Eq + Copy + Clone + Send + Sync + fmt::Debug + fmt::Display + 'static + Sized + Eq + Copy + Clone + Send + Sync + fmt::Debug + fmt::Display + 'static + Zeroize { /// Returns an element chosen uniformly at random using a user-provided RNG. fn random(rng: &mut R) -> Self; @@ -108,6 +112,7 @@ pub trait PrimeFieldRepr: + AsRef<[u64]> + AsMut<[u64]> + From + + Zeroize { /// Subtract another represetation from this one. fn sub_noborrow(&mut self, other: &Self); From 28a245188d1ecd037493ff2169bac60bb6f91d73 Mon Sep 17 00:00:00 2001 From: zhenfei Date: Fri, 3 Jan 2020 11:53:39 -0500 Subject: [PATCH 2/9] Update src/lib.rs --- src/lib.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 9518dba..5d630e2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -18,11 +18,10 @@ use rand_core::RngCore; use std::error::Error; use std::fmt; use std::io::{self, Read, Write}; -use zeroize::Zeroize; /// This trait represents an element of a field. pub trait Field: - Sized + Eq + Copy + Clone + Send + Sync + fmt::Debug + fmt::Display + 'static + Zeroize + Sized + Eq + Copy + Clone + Send + Sync + fmt::Debug + fmt::Display + 'static { /// Returns an element chosen uniformly at random using a user-provided RNG. fn random(rng: &mut R) -> Self; @@ -112,7 +111,6 @@ pub trait PrimeFieldRepr: + AsRef<[u64]> + AsMut<[u64]> + From - + Zeroize { /// Subtract another represetation from this one. fn sub_noborrow(&mut self, other: &Self); From 3be85399c0afd43ee057eb690b67ba62c87a0e75 Mon Sep 17 00:00:00 2001 From: zhenfei Date: Thu, 26 Mar 2020 16:12:54 -0400 Subject: [PATCH 3/9] temporarily creating a new crate for publishing --- Cargo.toml | 10 +++++----- README.md | 9 +++++---- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d181a8b..f90d03d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,13 +1,13 @@ [package] -name = "ff" -version = "0.5.1" +name = "ff-zeroize" +version = "0.6.1" authors = ["Sean Bowe "] description = "Library for building and interfacing with finite fields" readme = "README.md" -documentation = "https://docs.rs/ff/" -homepage = "https://github.com/ebfull/ff" +documentation = "https://docs.rs/ff-zeroize/" +homepage = "https://github.com/algorand/ff-zeroize" license = "MIT/Apache-2.0" -repository = "https://github.com/ebfull/ff" +repository = "https://github.com/algorand/ff-zeroize" edition = "2018" [dependencies] diff --git a/README.md b/README.md index 57ef693..c9e87be 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ -# ff +# ff-zeroize -`ff` is a finite field library written in pure Rust, with no `unsafe{}` code. +* `ff-zeroize` is a temporary crate that enables `zeroize` features for `ff`crate +* `ff` is a finite field library written in pure Rust, with no `unsafe{}` code. ## Disclaimers @@ -12,7 +13,7 @@ Add the `ff` crate to your `Cargo.toml`: ```toml [dependencies] -ff = "0.5" +ff_zeroize = "0.6.1" ``` The `ff` crate contains `Field`, `PrimeField`, `PrimeFieldRepr` and `SqrtField` traits. @@ -29,7 +30,7 @@ First, enable the `derive` crate feature: ```toml [dependencies] -ff = { version = "0.4", features = ["derive"] } +ff_zeroize = { version = "0.6.1", features = ["derive"] } ``` And then use the macro like so: From e37550f0eeb7cef5b487774e923ab37f95470376 Mon Sep 17 00:00:00 2001 From: zhenfei Date: Thu, 26 Mar 2020 16:28:21 -0400 Subject: [PATCH 4/9] Update src/lib.rs --- src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib.rs b/src/lib.rs index 5d630e2..b85ccd1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -111,6 +111,7 @@ pub trait PrimeFieldRepr: + AsRef<[u64]> + AsMut<[u64]> + From + + zeroize::Zeroize { /// Subtract another represetation from this one. fn sub_noborrow(&mut self, other: &Self); From dd82917a1a07d5a3964cadc5919dd55a111de4ac Mon Sep 17 00:00:00 2001 From: zhenfei Date: Thu, 26 Mar 2020 16:29:09 -0400 Subject: [PATCH 5/9] bump up version number --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index f90d03d..d00d1c9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ff-zeroize" -version = "0.6.1" +version = "0.6.2" authors = ["Sean Bowe "] description = "Library for building and interfacing with finite fields" readme = "README.md" From b05e3fc3e2e2f48a402ec640a57a3c3f00deffa1 Mon Sep 17 00:00:00 2001 From: zhenfei Date: Thu, 26 Mar 2020 16:42:14 -0400 Subject: [PATCH 6/9] bump-up version number for ff-derive --- Cargo.toml | 4 ++-- ff_derive/Cargo.toml | 4 ++-- src/lib.rs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d00d1c9..6aa8a15 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,13 +12,13 @@ edition = "2018" [dependencies] byteorder = "1" -ff_derive = { version = "0.4.0", path = "ff_derive", optional = true } +ff_derive-zeroize = { version = "0.6.2", path = "ff_derive", optional = true } rand_core = "0.5" zeroize = {version = "1.1", features = ["zeroize_derive"]} [features] default = [] -derive = ["ff_derive"] +derive = ["ff_derive-zeroize"] [badges] maintenance = { status = "actively-developed" } diff --git a/ff_derive/Cargo.toml b/ff_derive/Cargo.toml index 88ba23e..27569cf 100644 --- a/ff_derive/Cargo.toml +++ b/ff_derive/Cargo.toml @@ -1,6 +1,6 @@ [package] -name = "ff_derive" -version = "0.4.0" +name = "ff_derive-zeroize" +version = "0.6.2" authors = ["Sean Bowe "] description = "Procedural macro library used to build custom prime field implementations" documentation = "https://docs.rs/ff/" diff --git a/src/lib.rs b/src/lib.rs index b85ccd1..3eb1a36 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,7 +6,7 @@ #[cfg(feature = "derive")] #[macro_use] -extern crate ff_derive; +extern crate ff_derive-zeroize as ff_derive; #[cfg(feature = "derive")] pub use ff_derive::*; From 37d457d7cecfbdc31c101897d1056838ac2aaa86 Mon Sep 17 00:00:00 2001 From: zhenfei Date: Thu, 26 Mar 2020 16:43:57 -0400 Subject: [PATCH 7/9] Update src/lib.rs --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 3eb1a36..67e14cb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,7 +6,7 @@ #[cfg(feature = "derive")] #[macro_use] -extern crate ff_derive-zeroize as ff_derive; +extern crate ff_derive_zeroize as ff_derive; #[cfg(feature = "derive")] pub use ff_derive::*; From bc40255b1eb6f71b374271236992d17b84100a51 Mon Sep 17 00:00:00 2001 From: zhenfei Date: Thu, 26 Mar 2020 16:54:17 -0400 Subject: [PATCH 8/9] Update Cargo.toml --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 6aa8a15..4166dbd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ff-zeroize" -version = "0.6.2" +version = "0.6.3" authors = ["Sean Bowe "] description = "Library for building and interfacing with finite fields" readme = "README.md" From 6560b8846b3077c45a87259ca91257fd03173c95 Mon Sep 17 00:00:00 2001 From: zhenfei Date: Mon, 6 Apr 2020 11:18:19 -0400 Subject: [PATCH 9/9] rewind ff-zeroize to ff --- Cargo.toml | 6 +++--- ff_derive/Cargo.toml | 2 +- src/lib.rs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 4166dbd..922dec3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "ff-zeroize" +name = "ff" version = "0.6.3" authors = ["Sean Bowe "] description = "Library for building and interfacing with finite fields" @@ -12,13 +12,13 @@ edition = "2018" [dependencies] byteorder = "1" -ff_derive-zeroize = { version = "0.6.2", path = "ff_derive", optional = true } +ff_derive = { version = "0.6.2", path = "ff_derive", optional = true } rand_core = "0.5" zeroize = {version = "1.1", features = ["zeroize_derive"]} [features] default = [] -derive = ["ff_derive-zeroize"] +derive = ["ff_derive"] [badges] maintenance = { status = "actively-developed" } diff --git a/ff_derive/Cargo.toml b/ff_derive/Cargo.toml index 27569cf..32d7e46 100644 --- a/ff_derive/Cargo.toml +++ b/ff_derive/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "ff_derive-zeroize" +name = "ff_derive" version = "0.6.2" authors = ["Sean Bowe "] description = "Procedural macro library used to build custom prime field implementations" diff --git a/src/lib.rs b/src/lib.rs index 67e14cb..b85ccd1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,7 +6,7 @@ #[cfg(feature = "derive")] #[macro_use] -extern crate ff_derive_zeroize as ff_derive; +extern crate ff_derive; #[cfg(feature = "derive")] pub use ff_derive::*;