Skip to content

Commit

Permalink
[chore] add getters to PoseidonCompactChunkInput (#196)
Browse files Browse the repository at this point in the history
chore: add getters to `PoseidonCompactChunkInput`
  • Loading branch information
jonathanpwang authored Oct 20, 2023
1 parent 582f671 commit eef553c
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions halo2-base/src/poseidon/hasher/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{
ScalarField,
};

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

Expand Down Expand Up @@ -53,13 +53,16 @@ impl<F: ScalarField, const T: usize, const RATE: usize> PoseidonHasherConsts<F,
}

/// 1 logical row of compact input for Poseidon hasher.
#[derive(Copy, Clone, Debug)]
#[derive(Copy, Clone, Debug, Getters, CopyGetters)]
pub struct PoseidonCompactInput<F: ScalarField, const RATE: usize> {
// Right padded inputs. No constrains on paddings.
#[getset(get = "pub")]
inputs: [AssignedValue<F>; RATE],
// is_final = 1 triggers squeeze.
#[getset(get_copy = "pub")]
is_final: SafeBool<F>,
// Length of `inputs`.
#[getset(get_copy = "pub")]
len: AssignedValue<F>,
}

Expand Down Expand Up @@ -89,11 +92,13 @@ impl<F: ScalarField, const RATE: usize> PoseidonCompactInput<F, RATE> {
}

/// A compact chunk input for Poseidon hasher. The end of a logical input could only be at the boundary of a chunk.
#[derive(Clone, Debug)]
#[derive(Clone, Debug, Getters, CopyGetters)]
pub struct PoseidonCompactChunkInput<F: ScalarField, const RATE: usize> {
// Inputs of a chunk. All witnesses will be absorbed.
#[getset(get = "pub")]
inputs: Vec<[AssignedValue<F>; RATE]>,
// is_final = 1 triggers squeeze.
#[getset(get_copy = "pub")]
is_final: SafeBool<F>,
}

Expand All @@ -105,13 +110,13 @@ impl<F: ScalarField, const RATE: usize> PoseidonCompactChunkInput<F, RATE> {
}

/// 1 logical row of compact output for Poseidon hasher.
#[derive(Copy, Clone, Debug, Getters)]
#[derive(Copy, Clone, Debug, CopyGetters)]
pub struct PoseidonCompactOutput<F: ScalarField> {
/// hash of 1 logical input.
#[getset(get = "pub")]
#[getset(get_copy = "pub")]
hash: AssignedValue<F>,
/// is_final = 1 ==> this is the end of a logical input.
#[getset(get = "pub")]
#[getset(get_copy = "pub")]
is_final: SafeBool<F>,
}

Expand Down

0 comments on commit eef553c

Please sign in to comment.