Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still not sure that we want to have a required dependency on zeroize for the ff crate, especially as Zeroize is not part of any bound on the Field or PrimeField traits. I think I would prefer that we make this crate optional, and instead of using zeroize_derive we manually add an impl Zeroize for #repr if the zeroize feature is enabled.

This would require adding a zeroize feature flag to ff_derive, and then here:

[dependencies]
...
zeroize_crate = { package = "zeroize", version = "1.1", optional = true }

[features]
...
zeroize = ["ff_derive/zeroize", "zeroize_crate"]

(Crates that use namespaced-features can't be published, so we can't have a feature with the same name as a crate.)

cc @tarcieri.

@tarcieri tarcieri Sep 4, 2020

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We make zeroize optional in most of the RustCrypto crates, FWIW.

I think it may be possible to avoid adding a zeroize feature to ff_derive, but I'd have to double check what I have in mind: amely there's already a zeroize_derive crate, so it might be possible to use that rather than modifying ff_derive to have custom zeroize support?


[features]
default = []
Expand Down
2 changes: 1 addition & 1 deletion ff_derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ fn fetch_attr(name: &str, attrs: &[syn::Attribute]) -> Option<String> {
// 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
Expand Down
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ extern crate ff_derive;
#[cfg(feature = "derive")]
pub use ff_derive::*;

#[macro_use]
extern crate zeroize;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could then be removed.


use rand_core::RngCore;
use std::error::Error;
use std::fmt;
Expand Down