Removed 'lazy_static' dependency.

master
Peter van Nostrand 6 years ago committed by Andreas Fackler
parent 0ed0806f50
commit 295e42954a
  1. 1
      Cargo.toml
  2. 7
      src/lib.rs
  3. 8
      src/secret.rs

@ -23,7 +23,6 @@ byteorder = "1.2.7"
errno = "0.2.4" errno = "0.2.4"
failure = "0.1.5" failure = "0.1.5"
hex_fmt = "0.3.0" hex_fmt = "0.3.0"
lazy_static = "1.1.0"
log = "0.4.6" log = "0.4.6"
memsec = "0.5.4" memsec = "0.5.4"
pairing = { version = "0.14.2", features = ["u128-support"] } pairing = { version = "0.14.2", features = ["u128-support"] }

@ -327,9 +327,10 @@ impl fmt::Debug for SecretKey {
impl ContainsSecret for SecretKey { impl ContainsSecret for SecretKey {
fn secret_memory(&self) -> MemRange { fn secret_memory(&self) -> MemRange {
let ptr = &*self.0 as *const Fr as *mut u8; MemRange {
let n_bytes = *FR_SIZE; ptr: &*self.0 as *const Fr as *mut u8,
MemRange { ptr, n_bytes } n_bytes: FR_SIZE,
}
} }
} }

@ -4,19 +4,15 @@
use std::mem::{size_of, size_of_val}; use std::mem::{size_of, size_of_val};
use std::ops::{Deref, DerefMut}; use std::ops::{Deref, DerefMut};
use lazy_static::lazy_static;
use memsec::memzero; use memsec::memzero;
use crate::Fr; use crate::Fr;
lazy_static! { pub(crate) const FR_SIZE: usize = size_of::<Fr>();
/// The size in bytes of a single field element.
pub(crate) static ref FR_SIZE: usize = size_of::<Fr>();
}
/// Overwrites a single field element with zeros. /// Overwrites a single field element with zeros.
pub(crate) fn clear_fr(fr_ptr: *const Fr) { pub(crate) fn clear_fr(fr_ptr: *const Fr) {
unsafe { memzero(fr_ptr as *mut u8, *FR_SIZE) }; unsafe { memzero(fr_ptr as *mut u8, FR_SIZE) };
} }
pub(crate) struct MemRange { pub(crate) struct MemRange {

Loading…
Cancel
Save