pub struct ConsentCredential {
pub id: String,
pub subject_did: String,
pub agent_did: String,
pub scope: String,
pub purpose: String,
pub payload_commitment: PayloadCommitment,
pub granted_unix: u64,
pub expiry_unix: Option<u64>,
pub revoked_unix: Option<u64>,
pub authority: CredentialAuthority,
pub authorization: Authorization,
/* private fields */
}Expand description
A consent credential — grants an agent scoped access to an encrypted payload; revocable, with the
revocation crypto-enforced (the wrapped key is destroyed). Its authority may be self-consent, a court,
or another authority (CredentialAuthority); its exercise may require multi-sig
(Authorization).
Fields§
§id: String§subject_did: StringThe person granting consent (the data-subject).
agent_did: StringThe granted agent (e.g. the social worker — a human, by identifier).
scope: StringWhat is granted, purpose-bound (minimal-disclosure scope).
purpose: String§payload_commitment: PayloadCommitmentA commitment to the granted payload — durable, binds the conduct trail.
granted_unix: u64§expiry_unix: Option<u64>Optional expiry — access ceases at/after this time even without an explicit revoke.
revoked_unix: Option<u64>Set on revoke — the moment after which the payload is unavailable.
Where this credential’s authority derives from (subject / court / authority).
How it may be exercised (alone, or multi-sig requiring party instigation + threshold).
Implementations§
Source§impl ConsentCredential
impl ConsentCredential
Sourcepub fn grant(
id: impl Into<String>,
subject_did: impl Into<String>,
agent_did: impl Into<String>,
scope: impl Into<String>,
purpose: impl Into<String>,
payload_commitment: PayloadCommitment,
wrapped_key: Vec<u8>,
granted_unix: u64,
expiry_unix: Option<u64>,
) -> Self
pub fn grant( id: impl Into<String>, subject_did: impl Into<String>, agent_did: impl Into<String>, scope: impl Into<String>, purpose: impl Into<String>, payload_commitment: PayloadCommitment, wrapped_key: Vec<u8>, granted_unix: u64, expiry_unix: Option<u64>, ) -> Self
Grant a credential. wrapped_key is the data key wrapped for the agent (from the vault’s envelope
encryption) — the thing revocation destroys.
Set the credential’s authority basis (a court order / another authority). Builder-style.
Sourcepub fn requiring_multisig(self, parties: Vec<Party>, threshold: usize) -> Self
pub fn requiring_multisig(self, parties: Vec<Party>, threshold: usize) -> Self
Require multi-sig exercise: instigation by a participating party + threshold party signatures.
Builder-style. This is what makes the credential unable to act without a participating party.
Sourcepub fn is_active(&self, now_unix: u64) -> bool
pub fn is_active(&self, now_unix: u64) -> bool
Whether the credential is currently active (not revoked, not past expiry).
Sourcepub fn revoke(&mut self, now_unix: u64)
pub fn revoke(&mut self, now_unix: u64)
Revoke the credential — crypto-enforced: records the moment and destroys the wrapped key, so the payload can no longer be decrypted (it returns to the person). Idempotent.
Sourcepub fn payload_key(&self, now_unix: u64) -> Option<&[u8]>
pub fn payload_key(&self, now_unix: u64) -> Option<&[u8]>
The wrapped data key iff access is currently permitted — None once revoked or expired. A None
here is “the payload is unavailable to the agent”: with no key there is nothing to decrypt with.
Sourcepub fn payload_accessible(&self, now_unix: u64) -> bool
pub fn payload_accessible(&self, now_unix: u64) -> bool
Whether the encrypted payload is technically accessible right now (active + key present) —
ignoring any multi-sig requirement. For a multi-sig credential use can_exercise /
exercise, which enforce party-instigation + threshold.
Sourcepub fn can_exercise(&self, req: &ExerciseRequest, now_unix: u64) -> bool
pub fn can_exercise(&self, req: &ExerciseRequest, now_unix: u64) -> bool
Whether a specific exercise is permitted: the credential is active and the request satisfies the
Authorization (for multi-sig: instigated by a participating party + threshold signatures). This is
the gate that stops an authority acting unilaterally.
Sourcepub fn exercise(&self, req: &ExerciseRequest, now_unix: u64) -> Option<&[u8]>
pub fn exercise(&self, req: &ExerciseRequest, now_unix: u64) -> Option<&[u8]>
The wrapped data key iff this exercise is authorised (active + authorization satisfied). The
authorization-aware counterpart to payload_key: a multi-sig
credential yields a key only when a participating party instigated it and the threshold has signed.
Trait Implementations§
Source§impl Clone for ConsentCredential
impl Clone for ConsentCredential
Source§fn clone(&self) -> ConsentCredential
fn clone(&self) -> ConsentCredential
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ConsentCredential
impl Debug for ConsentCredential
Source§impl<'de> Deserialize<'de> for ConsentCredential
impl<'de> Deserialize<'de> for ConsentCredential
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>,
Source§impl PartialEq for ConsentCredential
impl PartialEq for ConsentCredential
Source§fn eq(&self, other: &ConsentCredential) -> bool
fn eq(&self, other: &ConsentCredential) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for ConsentCredential
impl Serialize for ConsentCredential
impl Eq for ConsentCredential
impl StructuralPartialEq for ConsentCredential
Auto Trait Implementations§
impl Freeze for ConsentCredential
impl RefUnwindSafe for ConsentCredential
impl Send for ConsentCredential
impl Sync for ConsentCredential
impl Unpin for ConsentCredential
impl UnsafeUnpin for ConsentCredential
impl UnwindSafe for ConsentCredential
Blanket Implementations§
§impl<S, A> Aggregate<Result<S, Error>> for Awhere
A: Aggregate<S>,
impl<S, A> Aggregate<Result<S, Error>> for Awhere
A: Aggregate<S>,
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§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>
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>
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