Struct SpongeBlob
pub struct SpongeBlob {
pub sponge: Poseidon2Sponge,
pub num_absorbed_fields: u32,
}
Fields
sponge: Poseidon2Spongenum_absorbed_fields: u32Implementations
impl SpongeBlob
pub fn init() -> Self
Initialize the sponge with the maximum number of fields allowed in a checkpoint. This allows proposers to start creating blocks and signing block headers (which contain the hash squeezed from the this sponge) before receiving all txs in a checkpoint slot.
pub fn absorb_tx_blob_data(
&mut self,
tx_effect: TxEffect,
array_lengths: TxEffectArrayLengths,
)
pub fn absorb_block_end_data(
&mut self,
global_variables: GlobalVariables,
last_archive: AppendOnlyTreeSnapshot,
state: StateReference,
num_txs: u16,
total_mana_used: Field,
is_first_block_in_checkpoint: bool,
)
pub fn absorb_checkpoint_end_marker(&mut self)
pub fn absorb<let N: u32>(&mut self, input: [Field; N], in_len: u32)
Absorb the first in_len fields of the input to the sponge. Fields beyond in_len are ignored.
pub fn squeeze(&mut self) -> Field
Finalize the sponge and output the non-standard poseidon2 hash of all fields absorbed.
Trait implementations
impl Deserialize for SpongeBlob
pub fn deserialize(serialized: [Field; 10]) -> Self
impl Empty for SpongeBlob
pub fn empty() -> Self
pub fn is_empty(self) -> bool
pub fn assert_empty<let S: u32>(self, msg: str<S>)
impl Eq for SpongeBlob
pub fn eq(_self: Self, _other: Self) -> bool
impl Serialize for SpongeBlob
pub fn serialize(self) -> [Field; 10]
A Poseidon2 sponge used to accumulate data that will be added to blob(s). (More accurately called BlobSponge, but that's not as fun).
The journey of a SpongeBlob:
Tx base: each tx absorbs its effects into the given "start" SpongeBlob and outputs it as the "end" SpongeBlob.
Tx merge or block root checks that the start SpongeBlob of a tx matches the end SpongeBlob of the previous tx.
Block root: the end SpongeBlob of the last tx absorbs a special block end marker indicating the number of txs in the block, along with the end state of the block. The block header commits to the value squeezed from this SpongeBlob. This updated SpongeBlob is then output as the end SpongeBlob of the block root.
In block merge or checkpoint root, the start SpongeBlob is checked against the end SpongeBlob of the previous block.
Checkpoint root: receives all fields as private inputs and checks that hashing them matches the final hash squeezed from the end SpongeBlob of the last block, after absorbing a checkpoint end marker indicating the number of fields absorbed. It also checks that the start SpongeBlob of the first tx in the block does not have any fields absorbed.
The final hash is used as part of the blob challenge, proving that all fields of the blob(s) are included.
Note: The hash squeezed from the SpongeBlob is NOT a standard poseidon2 hash.