Skip to content
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

feat: change precomputation rc to arc #44

Merged
merged 1 commit into from
Jul 20, 2023
Merged
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
6 changes: 3 additions & 3 deletions src/generators/bulletproof_gens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use std::{
fmt::{Debug, Formatter},
rc::Rc,
sync::Arc,
};

use byteorder::{ByteOrder, LittleEndian};
Expand Down Expand Up @@ -48,7 +48,7 @@ pub struct BulletproofGens<P: Precomputable> {
/// Precomputed \\(\mathbf H\\) generators for each party.
pub(crate) h_vec: Vec<Vec<P>>,
/// Interleaved precomputed generators
pub(crate) precomp: Rc<P::Precomputation>,
pub(crate) precomp: Arc<P::Precomputation>,
}

impl<P: FromUniformBytes + Precomputable> BulletproofGens<P> {
Expand Down Expand Up @@ -82,7 +82,7 @@ impl<P: FromUniformBytes + Precomputable> BulletproofGens<P> {
let iter_g_vec = g_vec.iter().flat_map(move |g_j| g_j.iter());
let iter_h_vec = h_vec.iter().flat_map(move |h_j| h_j.iter());
let iter_interleaved = iter_g_vec.interleave(iter_h_vec);
let precomp = Rc::new(P::Precomputation::new(iter_interleaved));
let precomp = Arc::new(P::Precomputation::new(iter_interleaved));

BulletproofGens {
gens_capacity,
Expand Down
8 changes: 3 additions & 5 deletions src/range_parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

use std::{
fmt::{Debug, Formatter},
rc::Rc,
sync::Arc,
};

use crate::{
Expand Down Expand Up @@ -121,10 +121,8 @@ where P: FromUniformBytes + Compressable + Clone + Precomputable
}

/// Return the interleaved precomputation tables
pub fn precomp(&self) -> Rc<P::Precomputation> {
// We use shared ownership since precomputation evaluation is an instance method and we don't want to actually
// clone
Rc::clone(&self.bp_gens.precomp)
pub fn precomp(&self) -> Arc<P::Precomputation> {
self.bp_gens.precomp.clone()
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ pub trait Decompressable {
/// Abstraction for any type supporting multiscalar multiplication precomputation
pub trait Precomputable {
/// The type representing the precomputation instantiation
type Precomputation: Clone + VartimePrecomputedMultiscalarMul<Point = Self>;
type Precomputation: Send + Sync + Clone + VartimePrecomputedMultiscalarMul<Point = Self>;
}
Loading