mirror of https://github.com/poanetwork/hbbft.git
Merge pull request #140 from poanetwork/clear-secret-key-set
Clear 'SecretKeySet' on drop.
This commit is contained in:
commit
4b35a8666a
|
@ -14,7 +14,7 @@ before_install:
|
|||
- rustup toolchain install ${RUST_NEXT}
|
||||
- rustup component add --toolchain=${RUST_NEXT} rustfmt-preview clippy-preview
|
||||
# Some symlinking is still necessary for clippy to function properly.
|
||||
- ln -s ${HOME}/.rustup/toolchains/${RUST_NEXT}-x86_64-unknown-linux-gnu/bin/clippy-driver ${HOME}/.rustup/toolchains/${RUST_NEXT}-x86_64-unknown-linux-gnu/bin/cargo-clippy $HOME/.cargo/bin/
|
||||
- ln -sf ${HOME}/.rustup/toolchains/${RUST_NEXT}-x86_64-unknown-linux-gnu/bin/clippy-driver ${HOME}/.rustup/toolchains/${RUST_NEXT}-x86_64-unknown-linux-gnu/bin/cargo-clippy $HOME/.cargo/bin/
|
||||
env:
|
||||
global:
|
||||
- RUST_BACKTRACE=1
|
||||
|
|
|
@ -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