Clear 'Poly' and 'BivarPoly' coeffs on drop.
This commit is contained in:
parent
77a5829c1d
commit
bd10494d5d
25
poly.rs
25
poly.rs
|
@ -18,6 +18,7 @@
|
|||
|
||||
use std::borrow::Borrow;
|
||||
use std::hash::{Hash, Hasher};
|
||||
use std::ptr::write_volatile;
|
||||
use std::{cmp, iter, ops};
|
||||
|
||||
use pairing::bls12_381::{Fr, FrRepr, G1, G1Affine};
|
||||
|
@ -123,6 +124,18 @@ impl<B: Borrow<Self>> ops::MulAssign<B> for Poly {
|
|||
}
|
||||
}
|
||||
|
||||
impl Drop for Poly {
|
||||
fn drop(&mut self) {
|
||||
let start = self.coeff.as_mut_ptr();
|
||||
unsafe {
|
||||
for i in 0..self.coeff.len() {
|
||||
let ptr = start.offset(i as isize);
|
||||
write_volatile(ptr, Fr::zero());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Poly {
|
||||
/// Creates a random polynomial.
|
||||
pub fn random<R: Rng>(degree: usize, rng: &mut R) -> Self {
|
||||
|
@ -327,6 +340,18 @@ pub struct BivarPoly {
|
|||
coeff: Vec<Fr>,
|
||||
}
|
||||
|
||||
impl Drop for BivarPoly {
|
||||
fn drop(&mut self) {
|
||||
let start = self.coeff.as_mut_ptr();
|
||||
unsafe {
|
||||
for i in 0..self.coeff.len() {
|
||||
let ptr = start.offset(i as isize);
|
||||
write_volatile(ptr, Fr::zero());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl BivarPoly {
|
||||
/// Creates a random polynomial.
|
||||
pub fn random<R: Rng>(degree: usize, rng: &mut R) -> Self {
|
||||
|
|
Loading…
Reference in New Issue