pub struct StateIntegrity {
pub current_hash: [u8; 32],
pub sequence_number: u64,
pub genesis_validators_root: Option<[u8; 32]>,
}Expand description
State integrity tracker
Maintains a hash chain of all signing decisions to detect rollback attacks
Fields§
§current_hash: [u8; 32]Current state hash (hash of all decisions up to now)
sequence_number: u64Sequence number of the last recorded decision
genesis_validators_root: Option<[u8; 32]>Genesis validators root (locked on first signing request)
Implementations§
Source§impl StateIntegrity
impl StateIntegrity
Sourcepub fn from_checkpoint(
hash: [u8; 32],
sequence: u64,
genesis_root: Option<[u8; 32]>,
) -> Self
pub fn from_checkpoint( hash: [u8; 32], sequence: u64, genesis_root: Option<[u8; 32]>, ) -> Self
Create from a checkpoint
Sourcepub fn set_genesis_validators_root(
&mut self,
root: [u8; 32],
) -> Result<(), IntegrityError>
pub fn set_genesis_validators_root( &mut self, root: [u8; 32], ) -> Result<(), IntegrityError>
Lock the genesis validators root (can only be set once)
Sourcepub fn record_decision(
&mut self,
record: &DecisionRecord,
) -> Result<[u8; 32], IntegrityError>
pub fn record_decision( &mut self, record: &DecisionRecord, ) -> Result<[u8; 32], IntegrityError>
Record a new decision and update the hash chain
Returns the new state hash after recording
Sourcepub fn prepare_record(
&self,
validator_pubkey: [u8; 48],
request_type: SigningType,
decision: PolicyDecision,
signing_root: [u8; 32],
) -> DecisionRecord
pub fn prepare_record( &self, validator_pubkey: [u8; 48], request_type: SigningType, decision: PolicyDecision, signing_root: [u8; 32], ) -> DecisionRecord
Create a decision record with proper sequencing
Sourcepub fn prepare_record_with_context(
&self,
validator_pubkey: [u8; 48],
request_type: SigningType,
decision: PolicyDecision,
signing_root: [u8; 32],
signing_context: SigningContext,
) -> DecisionRecord
pub fn prepare_record_with_context( &self, validator_pubkey: [u8; 48], request_type: SigningType, decision: PolicyDecision, signing_root: [u8; 32], signing_context: SigningContext, ) -> DecisionRecord
Create a decision record with proper sequencing and signing context
Sourcepub fn verify_records<'a, I>(&self, records: I) -> Result<(), IntegrityError>where
I: IntoIterator<Item = &'a DecisionRecord>,
pub fn verify_records<'a, I>(&self, records: I) -> Result<(), IntegrityError>where
I: IntoIterator<Item = &'a DecisionRecord>,
Verify a sequence of records against expected hash chain
Trait Implementations§
Source§impl Clone for StateIntegrity
impl Clone for StateIntegrity
Source§fn clone(&self) -> StateIntegrity
fn clone(&self) -> StateIntegrity
Returns a duplicate of the value. Read more
1.0.0 · 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 StateIntegrity
impl Debug for StateIntegrity
Source§impl Default for StateIntegrity
impl Default for StateIntegrity
Source§impl<'de> Deserialize<'de> for StateIntegrity
impl<'de> Deserialize<'de> for StateIntegrity
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for StateIntegrity
impl RefUnwindSafe for StateIntegrity
impl Send for StateIntegrity
impl Sync for StateIntegrity
impl Unpin for StateIntegrity
impl UnwindSafe for StateIntegrity
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