#[repr(C)]pub struct DeviceSpongeState {
pub state: [F; 16],
pub absorb_idx: u32,
pub sample_idx: u32,
}Expand description
Device-side sponge state, matching the CUDA DeviceSpongeState struct.
This struct is #[repr(C)] to ensure ABI compatibility with the CUDA kernel.
The state layout matches the Poseidon2 duplex sponge with overwrite mode.
This struct implements the same logic as DuplexSponge from openvm_stark_backend,
but with public fields so we can sync state to/from GPU.
Fields§
§state: [F; 16]Full Poseidon2 state (WIDTH = 16 elements)
absorb_idx: u32Current absorb position (0 <= absorb_idx < CHUNK)
sample_idx: u32Current sample position (0 <= sample_idx <= CHUNK)
Implementations§
Trait Implementations§
Source§impl Clone for DeviceSpongeState
impl Clone for DeviceSpongeState
Source§fn clone(&self) -> DeviceSpongeState
fn clone(&self) -> DeviceSpongeState
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for DeviceSpongeState
impl Debug for DeviceSpongeState
Source§impl Default for DeviceSpongeState
impl Default for DeviceSpongeState
Source§impl FiatShamirTranscript<BabyBearPoseidon2Config> for DeviceSpongeState
impl FiatShamirTranscript<BabyBearPoseidon2Config> for DeviceSpongeState
fn observe(&mut self, value: F)
fn sample(&mut self) -> F
Source§fn observe_commit(&mut self, digest: Digest)
fn observe_commit(&mut self, digest: Digest)
Implementations should pass through to Self::observe, but no default implementation is
provided since an explicit conversion from
Digest to array of F is required.fn observe_ext(&mut self, value: <SC as StarkProtocolConfig>::EF)
fn sample_ext(&mut self) -> <SC as StarkProtocolConfig>::EF
Source§fn sample_bits(&mut self, bits: usize) -> u64
fn sample_bits(&mut self, bits: usize) -> u64
Samples and returns an integer in the range [0, 2^bits). Read more
Source§fn check_witness(
&mut self,
bits: usize,
witness: <SC as StarkProtocolConfig>::F,
) -> bool
fn check_witness( &mut self, bits: usize, witness: <SC as StarkProtocolConfig>::F, ) -> bool
Checks a proof-of-work witness: observes
witness into the transcript and accepts iff the
next Self::sample_bits is zero (probability ≈ 2^{-bits} for a random witness, so
Self::grind tries ≈ 2^bits witnesses to find one). Read moreSource§fn grind(&mut self, bits: usize) -> <SC as StarkProtocolConfig>::F
fn grind(&mut self, bits: usize) -> <SC as StarkProtocolConfig>::F
Finds a proof-of-work witness
w such that Self::check_witness(bits, w) holds, by
brute force over the base field.Auto Trait Implementations§
impl Freeze for DeviceSpongeState
impl RefUnwindSafe for DeviceSpongeState
impl Send for DeviceSpongeState
impl Sync for DeviceSpongeState
impl Unpin for DeviceSpongeState
impl UnsafeUnpin for DeviceSpongeState
impl UnwindSafe for DeviceSpongeState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more