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§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>,
impl Eq for ConsentCredential
Source§impl PartialEq for ConsentCredential
impl PartialEq for ConsentCredential
Source§impl Serialize for ConsentCredential
impl Serialize 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<U> As for U
impl<U> As for U
§fn as_<T>(self) -> Twhere
T: CastFrom<U>,
U: Sized,
fn as_<T>(self) -> Twhere
T: CastFrom<U>,
U: Sized,
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 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Conv for T
impl<T> Conv for T
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§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
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§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<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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§impl<T> OptionalSet for T
impl<T> OptionalSet for T
§fn with_optional<F, T>(self, f: F, val: Option<T>) -> Self
fn with_optional<F, T>(self, f: F, val: Option<T>) -> Self
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>
fn with_validated_optional<F, T, V, E>( self, f: F, value: Option<T>, validate: V, ) -> Result<Self, 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
fn with_optional_env<F, T>(self, f: F, val: Option<T>, env_var: &str) -> Self
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
fn with_optional_custom_env<F, T, G>( self, f: F, val: Option<T>, env_var: &str, parser: G, ) -> Self
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 Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
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) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
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
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
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
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
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
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.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
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.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
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.