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

chore: make poseidon hasher thread safe #269

Merged
merged 1 commit into from
May 7, 2024
Merged
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 halo2-base/src/poseidon/hasher/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::{

use getset::{CopyGetters, Getters};
use num_bigint::BigUint;
use std::{cell::OnceCell, mem};
use std::{mem, sync::OnceLock};

#[cfg(test)]
mod tests;
Expand All @@ -28,7 +28,7 @@ pub struct PoseidonHasher<F: ScalarField, const T: usize, const RATE: usize> {
/// Spec, contains round constants and optimized matrices.
#[getset(get = "pub")]
spec: OptimizedPoseidonSpec<F, T, RATE>,
consts: OnceCell<PoseidonHasherConsts<F, T, RATE>>,
consts: OnceLock<PoseidonHasherConsts<F, T, RATE>>,
}
#[derive(Clone, Debug, Getters)]
struct PoseidonHasherConsts<F: ScalarField, const T: usize, const RATE: usize> {
Expand Down Expand Up @@ -123,7 +123,7 @@ pub struct PoseidonCompactOutput<F: ScalarField> {
impl<F: ScalarField, const T: usize, const RATE: usize> PoseidonHasher<F, T, RATE> {
/// Create a poseidon hasher from an existing spec.
pub fn new(spec: OptimizedPoseidonSpec<F, T, RATE>) -> Self {
Self { spec, consts: OnceCell::new() }
Self { spec, consts: OnceLock::new() }
}
/// Initialize necessary consts of hasher. Must be called before any computation.
pub fn initialize_consts(&mut self, ctx: &mut Context<F>, gate: &impl GateInstructions<F>) {
Expand Down
Loading