Skip to content

Commit

Permalink
Rename RescueStateVarGen -> SpongeStateVar
Browse files Browse the repository at this point in the history
as per PR review suggestion
  • Loading branch information
tessico committed Dec 15, 2022
1 parent 87802f5 commit 726be00
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
9 changes: 4 additions & 5 deletions primitives/src/circuit/rescue/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ pub use non_native::RescueNonNativeStateVar;

use crate::rescue::{RescueMatrix, RescueVector, PRP};

/// Generic ResuceStateVar. Both RescueStateVar and RescueNonNativeStateVar
/// should implement it.
pub trait RescueStateVarGen<T, F> {
/// Variable to represent the state of the sponge.
pub trait SpongeStateVar<T, F> {
/// The native field.
type Native;
/// Non-native field.
Expand All @@ -32,7 +31,7 @@ pub trait RescueStateVarGen<T, F> {
/// Trait for rescue circuit over native field.
pub trait RescueGadget<R, T, F>
where
R: RescueStateVarGen<T, F>,
R: SpongeStateVar<T, F>,
{
/// Given an input state st_0 and an output state st_1, ensure that st_1 =
/// rescue_permutation(st_0) where rescue_permutation is the instance
Expand Down Expand Up @@ -115,7 +114,7 @@ where

pub(crate) trait PermutationGadget<R, T, F>: Circuit<F>
where
R: RescueStateVarGen<T, F>,
R: SpongeStateVar<T, F>,
F: PrimeField,
{
fn check_var_bound_rescue_state(&self, rescue_state: &R) -> Result<(), CircuitError>;
Expand Down
4 changes: 2 additions & 2 deletions primitives/src/circuit/rescue/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ use jf_relation::{
};
use jf_utils::compute_len_to_next_multiple;

use super::{PermutationGadget, RescueGadget, RescueStateVarGen};
use super::{PermutationGadget, RescueGadget, SpongeStateVar};

#[derive(Clone, Debug)]
/// Array of variables representing a Rescue state (4 field elements).
pub struct RescueStateVar(pub(crate) [Variable; STATE_SIZE]);

/// For the native field, there is only really one field `F`.
impl<F> RescueStateVarGen<F, F> for RescueStateVar {
impl<F> SpongeStateVar<F, F> for RescueStateVar {
type Native = F;
type NonNative = F;
type Var = Variable;
Expand Down
4 changes: 2 additions & 2 deletions primitives/src/circuit/rescue/non_native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use jf_relation::{
};
use jf_utils::{compute_len_to_next_multiple, field_switching};

use super::{PermutationGadget, RescueGadget, RescueStateVarGen};
use super::{PermutationGadget, RescueGadget, SpongeStateVar};

/// Array of variables representing a Rescue state (4 field elements), and also
/// the modulus of the non-native evaluating field.
Expand All @@ -32,7 +32,7 @@ pub struct RescueNonNativeStateVar<F: PrimeField> {
pub(crate) modulus: FpElem<F>,
}

impl<T, F: PrimeField> RescueStateVarGen<T, F> for RescueNonNativeStateVar<F> {
impl<T, F: PrimeField> SpongeStateVar<T, F> for RescueNonNativeStateVar<F> {
type Native = T;
type NonNative = F;
type Var = FpElemVar<F>;
Expand Down

0 comments on commit 726be00

Please sign in to comment.