-
Notifications
You must be signed in to change notification settings - Fork 128
feat: support zeroize codegen #100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
fdd6fc5
3b717a1
a6be620
a42c8b5
8248515
b8e716b
08afa04
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -16,9 +16,10 @@ edition = "2021" | |||||||||||||
| [dependencies] | ||||||||||||||
| bitvec = { version = "1", default-features = false, optional = true } | ||||||||||||||
| byteorder = { version = "1", default-features = false, optional = true } | ||||||||||||||
| ff_derive = { version = "0.13", path = "ff_derive", optional = true } | ||||||||||||||
| ff_derive = { version = "0.13.0", path = "ff_derive", optional = true } | ||||||||||||||
| rand_core = { version = "0.6", default-features = false } | ||||||||||||||
| subtle = { version = "2.2.1", default-features = false, features = ["i128"] } | ||||||||||||||
| zeroize = { version = "1", default-features = false, optional = true } | ||||||||||||||
|
Daniel-Aaron-Bloom marked this conversation as resolved.
Outdated
|
||||||||||||||
|
|
||||||||||||||
| [dev-dependencies] | ||||||||||||||
| blake2b_simd = "1" | ||||||||||||||
|
|
@@ -28,16 +29,22 @@ rand = "0.8" | |||||||||||||
| default = ["bits", "std"] | ||||||||||||||
| alloc = [] | ||||||||||||||
| bits = ["bitvec"] | ||||||||||||||
| zero = ["zeroize"] | ||||||||||||||
|
Daniel-Aaron-Bloom marked this conversation as resolved.
Outdated
|
||||||||||||||
| derive = ["byteorder", "ff_derive"] | ||||||||||||||
| std = ["alloc"] | ||||||||||||||
| # with MSRV 1.60 this could be merged into bits with ff_derive?/bits | ||||||||||||||
| # see PR#72 for more information. | ||||||||||||||
| derive_bits = ["bits", "ff_derive/bits"] | ||||||||||||||
| derive_bits = ["bits", "derive", "ff_derive/bits"] | ||||||||||||||
| derive_zero = ["zero", "derive", "ff_derive/zero"] | ||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unlike above, we do need the ability to enable the
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I went with |
||||||||||||||
|
|
||||||||||||||
| [[test]] | ||||||||||||||
| name = "derive" | ||||||||||||||
| required-features = ["derive"] | ||||||||||||||
|
|
||||||||||||||
| [[test]] | ||||||||||||||
| name = "derive_zero" | ||||||||||||||
| required-features = ["derive_zero"] | ||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
|
|
||||||||||||||
| [badges] | ||||||||||||||
| maintenance = { status = "actively-developed" } | ||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| //! This module exercises the `ff_derive` procedural macros, specifically to ensure | ||
| //! zeroize works | ||
|
|
||
| #[macro_use] | ||
| extern crate ff; | ||
|
|
||
| /// The BLS12-381 scalar field. | ||
| #[derive(PrimeField)] | ||
| #[PrimeFieldModulus = "52435875175126190479447740508185965837690552500527637822603658699938581184513"] | ||
| #[PrimeFieldGenerator = "7"] | ||
| #[PrimeFieldReprEndianness = "little"] | ||
| struct Bls381K12Scalar([u64; 4]); | ||
|
|
||
| #[test] | ||
| fn zeroize() { | ||
|
Daniel-Aaron-Bloom marked this conversation as resolved.
Outdated
|
||
| use ff::{Field, PrimeField}; | ||
| use rand::rngs::OsRng; | ||
| use zeroize::Zeroize; | ||
|
|
||
| let mut f = Bls381K12Scalar::random(OsRng); | ||
| let mut r = f.to_repr(); | ||
|
|
||
| f.zeroize(); | ||
| assert_eq!(f, Bls381K12Scalar::ZERO); | ||
|
|
||
| r.zeroize(); | ||
| assert_eq!(r, Default::default()); | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.