Skip to main content

AccountabilityStore

Struct AccountabilityStore 

Source
pub struct AccountabilityStore { /* private fields */ }
Expand description

On-disk store for the accountability fabric.

Implementations§

Source§

impl AccountabilityStore

Source

pub fn open(storage_root: impl AsRef<Path>) -> Result<Self>

Open (or prepare to create) the store under storage_root.

Source

pub fn load(&self) -> Result<AccountabilityState>

Load the whole set (empty default if the file does not yet exist).

Source

pub fn save(&self, state: &AccountabilityState) -> Result<()>

Persist the whole set (write-to-temp then rename, so a crash can’t leave a half-written chain).

Source

pub fn append_ledger( &self, kind: &str, payload_json: &str, signer: &SigningKey, time_unix: u64, ) -> Result<LedgerEntry>

Append a raw record to the tamper-evident ledger, signed by signer, and persist. Returns the entry.

Source

pub fn verify_ledger(&self) -> Result<Result<(), LedgerTamper>>

Verify the whole ledger chain. Ok(None) = intact; Ok(Some(tamper)) = a detected, named tamper.

Source

pub fn ledger_entries(&self, limit: usize) -> Result<Vec<LedgerEntry>>

The most-recent ledger entries (newest first), capped to limit.

Source

pub fn grant_credential( &self, cred: ConsentCredential, signer: &SigningKey, time_unix: u64, ) -> Result<ConsentCredential>

Grant a consent credential and log it into the ledger. The credential is stored; a "consent_granted" entry (subject → agent, scope, purpose) enters the signed chain.

Source

pub fn revoke_credential( &self, credential_id: &str, signer: &SigningKey, time_unix: u64, ) -> Result<bool>

Revoke a consent credential — crypto-enforced (the wrapped key is destroyed in ConsentCredential::revoke) — and log a "consent_revoked" entry. Returns true if a live credential was revoked. The credential row and every conduct record under it persist: revoking consent removes access, never accountability.

Source

pub fn list_credentials(&self) -> Result<Vec<ConsentCredential>>

All stored credentials (active and revoked — the revoked ones remain as the audit anchor).

Source

pub fn wrapped_key_for( &self, commitment: &PayloadCommitment, agent_did: &str, now_unix: u64, ) -> Result<Option<Vec<u8>>>

The still-live wrapped DEK held by agent_did’s credential for commitment (e.g. the owner’s own credential), so the DEK can be recovered and re-sealed on enactment. None if no such active credential.

Source

pub fn record_conduct( &self, agent_did: impl Into<String>, credential_id: impl Into<String>, action: impl Into<String>, reason: impl Into<String>, commitment: PayloadCommitment, signer: &SigningKey, time_unix: u64, ) -> Result<ConductRecord>

Record an agent’s conduct under a credential — signed by signer (an Attestation::Signature) — into both the durable conduct trail and the tamper-evident ledger. The record binds to the payload commitment (not the payload), so it proves what was acted on without holding the datum, and it survives the credential’s revocation.

Source

pub fn audit_trail(&self, credential_id: &str) -> Result<Vec<ConductRecord>>

The audit view — every conduct record taken under one credential, in order. Exactly the records that survive that credential’s revocation (the accountability the person cannot erase and the agent cannot withhold).

Source

pub fn seal_and_grant_credential( &self, credential_id: impl Into<String>, subject_did: impl Into<String>, agent_did: impl Into<String>, scope: impl Into<String>, purpose: impl Into<String>, plaintext: &[u8], recipient_public: &[u8; 32], storers: Vec<String>, expiry_unix: Option<u64>, signer: &SigningKey, time_unix: u64, ) -> Result<ConsentCredential>

Seal a plaintext payload and grant a consent credential over it — the real envelope-encryption path (as opposed to grant_credential, which takes an already-wrapped key). Generates a random DEK, AEAD-encrypts the plaintext, content-addresses the ciphertext, seals the DEK to recipient_public (the credential’s real wrapped_key), stores the ciphertext in the commons, grants the credential, and logs consent_granted. Returns the granted credential. Nothing is stored in the clear: the plaintext becomes ciphertext, and the DEK survives only sealed inside the credential.

Source

pub fn open_payload_via_credential( &self, credential_id: &str, recipient_secret: &[u8; 32], now_unix: u64, ) -> Result<Vec<u8>>

Open a sealed payload through a credential — the end-to-end decrypt path. Reads the credential’s wrapped_key (present only while active — revocation destroys it), unwraps the DEK with the recipient’s X25519 secret, verifies the content-address commitment, and AEAD-decrypts. Err if the credential is unknown, revoked/expired (no key ⇒ payload unavailable), or its ciphertext is missing.

Source

pub fn arm_dead_mans_switch( &self, switch: DeadMansSwitch, signer: &SigningKey, time_unix: u64, ) -> Result<()>

Arm a dead-man switch over a payload and log it. The owner sets the liveness grace + the gamified trigger (parties + threshold) + the disposition; it fires only when the heartbeat lapses AND a quorum of distinct parties attest.

Source

pub fn dead_mans_alive( &self, commitment: &PayloadCommitment, signer: &SigningKey, time_unix: u64, ) -> Result<bool>

The principal is alive — touch the heartbeat and un-fire a not-yet-enacted switch (the reversibility). Returns whether a switch for commitment was found.

Source

pub fn attest_dead_mans( &self, commitment: &PayloadCommitment, attestation: PartyAttestation, signer: &SigningKey, time_unix: u64, ) -> Result<bool>

Record a party attestation toward a switch’s trigger (the friend-side accumulation). Returns whether the switch was found.

Source

pub fn enact_dead_mans( &self, commitment: &PayloadCommitment, signer: &SigningKey, time_unix: u64, ) -> Result<Option<Disposition>>

Enact the switch if the gamified rule is satisfied (heartbeat lapsed + quorum attested). Records it fired, logs it, and returns the Disposition to carry out (key-release is a separate compose step).

Source

pub fn list_dead_mans_switches(&self) -> Result<Vec<DeadMansSwitchRecord>>

All armed dead-man switch records (with their accumulated attestations).

Source

pub fn enact_dead_mans_release( &self, commitment: &PayloadCommitment, dek: &[u8; 32], party_keys: &[(String, [u8; 32])], subject_did: &str, signer: &SigningKey, time_unix: u64, ) -> Result<Option<Disposition>>

Enact a dead-man switch AND perform the key-release — the composition that makes the disposition real. If the switch fires with Disposition::ReleaseTo, the caller-supplied dek (recovered by unwrapping an owner credential) is re-sealed to each disposition party’s X25519 key and a consent credential is granted to them, so they can now decrypt the payload they previously could not. Each grant is logged. MakePublic / SelfDefinedRules are returned but not key-released here (MakePublic’s irreversibility is a deferred values decision). Returns the disposition (or None if not triggerable).

Source

pub fn reconstruct_and_release( &self, commitment: &PayloadCommitment, recovery_shares: &[Share], party_keys: &[(String, [u8; 32])], subject_did: &str, signer: &SigningKey, time_unix: u64, ) -> Result<Option<Disposition>>

Social-recovery enactment (no owner key): reconstruct the payload DEK from a quorum of friends’ Shamir shares, then enact + release to the disposition parties. This is the true post-death / incapacity path — a quorum of chosen trustees recovers the key without the owner, closing the gap enact_dead_mans_release left (which needed the owner’s derived key).

Source

pub fn arm_incapacity_switch( &self, switch: IncapacitySwitch, signer: &SigningKey, time_unix: u64, ) -> Result<()>

Arm an incapacity switch and log it. Replaces any existing switch for the same principal.

Source

pub fn activate_incapacity( &self, principal_did: &str, attesting_parties: &[String], official_instrument: Option<&str>, signer: &SigningKey, time_unix: u64, ) -> Result<bool>

Activate advocacy if the corroborated trigger is satisfied (quorum + optional official instrument). Returns whether it activated.

Source

pub fn regain_capacity( &self, principal_did: &str, signer: &SigningKey, time_unix: u64, ) -> Result<bool>

Regain capacity — the advocate stands down, control reverts to the principal (the reversibility). Returns whether a switch for the principal was found.

Source

pub fn list_incapacity_switches(&self) -> Result<Vec<IncapacitySwitch>>

All armed incapacity switches.

Source

pub fn record_transparency_cc( &self, cc: TransparencyCc, signer: &SigningKey, time_unix: u64, ) -> Result<()>

Record a transparency cc — the protective “I informed authority X on date Y for purpose Z” note — and log it. Durable: if the authority later betrays or fails to act, that is knowable against this.

Source

pub fn record_disclosure_event( &self, event: DisclosureEvent, signer: &SigningKey, time_unix: u64, ) -> Result<()>

Record a disclosure event (an access or onward-share) and log it — the attributable trail. The event’s accountable_actor (a staffer if a delegate acted, else the recipient) is what a traced leak points to.

Source

pub fn disclosure_chain( &self, commitment: &PayloadCommitment, ) -> Result<Vec<DisclosureEvent>>

The full disclosure chain for a payload — who saw it, via which route, in order.

Source

pub fn actors_with_access( &self, commitment: &PayloadCommitment, ) -> Result<Vec<String>>

The distinct actors who had access to a payload — the set a leak must be within.

Source

pub fn trace_leak( &self, fingerprint: &DisclosureFingerprint, ) -> Result<Option<DisclosureEvent>>

Trace a leak by its per-recipient fingerprint → the disclosure it came from (and thence the accountable actor). Returns the matching event, if any.

Source

pub fn list_transparency_ccs(&self) -> Result<Vec<TransparencyCc>>

All transparency cc records.

Auto Trait Implementations§

Blanket Implementations§

§

impl<S, A> Aggregate<Result<S, Error>> for A
where A: Aggregate<S>,

§

fn from_shares<T>(iter: T) -> Result<A, Error>
where T: IntoIterator<Item = Result<S, Error>>,

Aggregate shares in an MPC protocol.
Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<U> As for U

§

fn as_<T>(self) -> T
where T: CastFrom<U>, U: Sized,

Casts self to type T. The semantics of numeric casting with the as operator are followed, so <T as As>::as_::<U> can be used in the same way as T as U for numeric conversions. Read more
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Conv for T

§

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. Read more
§

impl<T> Deprecatable for T

§

fn deprecate(self) -> Deprecated<Self>
where Self: Sized,

§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
§

impl<T> OptionalSet for T

§

fn with_optional<F, T>(self, f: F, val: Option<T>) -> Self
where F: Fn(Self, T) -> Self, Self: Sized,

If the value is available (i.e. Some), the provided closure is applied. Otherwise self is returned with no modifications.
§

fn with_validated_optional<F, T, V, E>( self, f: F, value: Option<T>, validate: V, ) -> Result<Self, E>
where F: Fn(Self, T) -> Self, V: Fn(&T) -> Result<(), E>, Self: Sized,

If the value is available (i.e. Some) it is validated and then the provided closure is applied. Otherwise self is returned with no modifications.
§

fn with_optional_env<F, T>(self, f: F, val: Option<T>, env_var: &str) -> Self
where F: Fn(Self, T) -> Self, T: FromStr, <T as FromStr>::Err: Debug, Self: Sized,

If the value is available (i.e. Some), the provided closure is applied. Otherwise, if the environment was configured and the corresponding variable was set, the value is parsed using the FromStr implementation and the closure is applied on that instead. Finally, if none of those were available, self is returned with no modifications.
§

fn with_optional_custom_env<F, T, G>( self, f: F, val: Option<T>, env_var: &str, parser: G, ) -> Self
where F: Fn(Self, T) -> Self, G: Fn(&str) -> T, Self: Sized,

If the value is available (i.e. Some), the provided closure is applied. Otherwise, if the environment was configured and the corresponding variable was set, the value is parsed using the provided parser and the closure is applied on that instead. Finally, if none of those were available, self is returned with no modifications.
§

impl<T> Pipe for T
where T: ?Sized,

§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows self, then passes self.as_ref() into the pipe function.
§

fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.as_mut() into the pipe function.
§

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R, ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T> Tap for T

§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Calls .tap_borrow() only in debug builds, and is erased in release builds.
§

fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
§

fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Calls .tap_ref() only in debug builds, and is erased in release builds.
§

fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
§

fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
§

impl<T> TryConv for T

§

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSendSync for T
where T: WasmNotSend + WasmNotSync,

§

impl<T> WasmNotSync for T
where T: Sync,

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more