You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use cyphr::Action;let action = Action::new("cyphr.me/action".to_string(),
signer_tmb,1700000000,
action_czd,
raw_coz_json,);
principal.record_action(action)?;// principal.level() is now Level::L4// principal.data_root() contains action digest
API Reference
Genesis
Function
Description
Principal::implicit(key)
Single-key genesis, PR = key thumbprint
Principal::explicit(keys)
Multi-key genesis, PR = H(sorted thumbprints)
State Accessors
Method
Returns
Description
pg()
Option<&PrincipalGenesis>
Permanent identity (None for L1/L2)
pr()
&PrincipalRoot
Current principal root (evolves)
sr()
Option<&StateRoot>
State root = MR(AR, DR?)
auth_root()
&AuthRoot
Auth root = MR(KR, RR?)
key_root()
&KeyRoot
Key root = MR(thumbprints)
data_root()
Option<&DataRoot>
Data root = H(action czds), None if L<4
cr()
Option<&CommitRoot>
Commit root (MALT of TRs)
current_tr()
Option<&TransactionRoot>
Transaction root of latest commit
level()
Level
Current feature level (L1-L4)
hash_alg()
HashAlg
Primary hash algorithm
active_algs()
&[HashAlg]
Hash algorithms from active keyset
Cozies
Function / Method
Description
verify_coz(pay, sig, key, czd, new_key)
Verify signature, return VerifiedCoz
apply_transaction(vtx)
Apply verified coz as atomic commit
begin_commit()
Start multi-coz commit scope
Keys
Method
Description
get_key(tmb)
Get key by thumbprint
is_key_active(tmb)
Check if key is active
active_keys()
Iterator over active keys
active_key_count()
Number of active keys
Error Handling
use cyphr::Error;match principal.apply_transaction(vtx){Ok(_) => {/* success */}Err(Error::InvalidPrior) => {/* pre doesn't match current PR */}Err(Error::TimestampPast) => {/* timestamp too old */}Err(Error::DuplicateKey) => {/* key already in KR */}Err(Error::NoActiveKeys) => {/* would leave 0 keys */}Err(Error::EmptyCommit) => {/* finalized with no cozies */}Err(Error::CommitMismatch) => {/* arrow doesn't match computed state */}Err(e) => {/* other error */}}