pub trait Sha256Instructions<F: Field>: Chip<F> {
    type State: Clone + Debug;
    type BlockWord: Copy + Debug + Default;

    // Required methods
    fn initialization_vector(
        &self,
        layouter: &mut impl Layouter<F>
    ) -> Result<Self::State, Error>;
    fn initialization(
        &self,
        layouter: &mut impl Layouter<F>,
        init_state: &Self::State
    ) -> Result<Self::State, Error>;
    fn compress(
        &self,
        layouter: &mut impl Layouter<F>,
        initialized_state: &Self::State,
        input: [Self::BlockWord; 16]
    ) -> Result<Self::State, Error>;
    fn digest(
        &self,
        layouter: &mut impl Layouter<F>,
        state: &Self::State
    ) -> Result<[Self::BlockWord; 8], Error>;
}
Available on crate feature unstable-sha256-gadget only.
Expand description

The set of circuit instructions required to use the Sha256 gadget.

Required Associated Types§

source

type State: Clone + Debug

Variable representing the SHA-256 internal state.

source

type BlockWord: Copy + Debug + Default

Variable representing a 32-bit word of the input block to the SHA-256 compression function.

Required Methods§

source

fn initialization_vector( &self, layouter: &mut impl Layouter<F> ) -> Result<Self::State, Error>

Places the SHA-256 IV in the circuit, returning the initial state variable.

source

fn initialization( &self, layouter: &mut impl Layouter<F>, init_state: &Self::State ) -> Result<Self::State, Error>

Creates an initial state from the output state of a previous block

source

fn compress( &self, layouter: &mut impl Layouter<F>, initialized_state: &Self::State, input: [Self::BlockWord; 16] ) -> Result<Self::State, Error>

Starting from the given initialized state, processes a block of input and returns the final state.

source

fn digest( &self, layouter: &mut impl Layouter<F>, state: &Self::State ) -> Result<[Self::BlockWord; 8], Error>

Converts the given state into a message digest.

Implementors§