pub struct McAuthorisationToken<const MCL: usize, const MCC: usize, const MPL: usize, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature, UserKeypair> { /* private fields */ }Expand description
The Willow authorisation token provided by Meadowcap.
There are two main ways of creating these: if you yourself want to authorise an entry, you can use the new_for_entry method. If you want to verify incoming data, use the McAuthorisationToken::new method.
§Examples
Authorising an entry of your own:
use willow_data_model::{prelude::*, test_parameters::*};
use meadowcap::*;
let alfies_entry = Entry::builder()
.namespace_id(Family)
.subspace_id(Alfie)
.path(Path::<4, 4, 4>::new())
.timestamp(12345)
.payload_digest(Spades)
.payload_length(2)
.build().unwrap();
let cap = WriteCapability::<
4, 4, 4,
TestNamespace,
TestNamespaceSignature,
TestSubspace,
TestSubspaceSignature,
>::new_communal(Family, Alfie);
let ingredients = McIngredients::new(cap, AlfieSecret).unwrap();
let auth_token = McAuthorisationToken::new_for_entry(&alfies_entry, &ingredients).unwrap();
assert!(auth_token.does_authorise(&alfies_entry));Verifying an untrusted entry:
use willow_data_model::{prelude::*, test_parameters::*};
use meadowcap::*;
let alfies_entry = Entry::builder()
.namespace_id(Family)
.subspace_id(Alfie)
.path(Path::<4, 4, 4>::new())
.timestamp(12345)
.payload_digest(Spades)
.payload_length(2)
.build().unwrap();
let alfies_cap = WriteCapability::<
4, 4, 4,
TestNamespace,
TestNamespaceSignature,
TestSubspace,
TestSubspaceSignature,
>::new_communal(Family, Alfie);
let auth_token = McAuthorisationToken::<4, 4, 4, _, _, _, _, TestSubspaceSecret>::new(alfies_cap, AlfieSignature);
assert!(auth_token.does_authorise(&alfies_entry));Implementations§
Source§impl<const MCL: usize, const MCC: usize, const MPL: usize, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature, UserKeypair> McAuthorisationToken<MCL, MCC, MPL, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature, UserKeypair>
impl<const MCL: usize, const MCC: usize, const MPL: usize, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature, UserKeypair> McAuthorisationToken<MCL, MCC, MPL, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature, UserKeypair>
Sourcepub fn new(
capability: WriteCapability<MCL, MCC, MPL, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature>,
signature: UserSignature,
) -> Self
pub fn new( capability: WriteCapability<MCL, MCC, MPL, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature>, signature: UserSignature, ) -> Self
Manually creates a new McAuthorisationToken (as opposed to using AuthorisationToken::new_for_entry).
use willow_data_model::{prelude::*, test_parameters::*};
use meadowcap::*;
let alfies_entry = Entry::builder()
.namespace_id(Family)
.subspace_id(Alfie)
.path(Path::<4, 4, 4>::new())
.timestamp(12345)
.payload_digest(Spades)
.payload_length(2)
.build().unwrap();
let alfies_cap = WriteCapability::<
4, 4, 4,
TestNamespace,
TestNamespaceSignature,
TestSubspace,
TestSubspaceSignature,
>::new_communal(Family, Alfie);
let auth_token = McAuthorisationToken::<4, 4, 4, _, _, _, _, TestSubspaceSecret>::new(alfies_cap, AlfieSignature);
assert!(auth_token.does_authorise(&alfies_entry));Sourcepub fn capability(
&self,
) -> &WriteCapability<MCL, MCC, MPL, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature>
pub fn capability( &self, ) -> &WriteCapability<MCL, MCC, MPL, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature>
Returns a reference to the write capability.
Sourcepub fn signature(&self) -> &UserSignature
pub fn signature(&self) -> &UserSignature
Returns a reference to the signature.
Sourcepub fn into_parts(
self,
) -> (WriteCapability<MCL, MCC, MPL, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature>, UserSignature)
pub fn into_parts( self, ) -> (WriteCapability<MCL, MCC, MPL, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature>, UserSignature)
Takes ownership of the authorisation token and returns its capability and signature by value.
Trait Implementations§
Source§impl<const MCL: usize, const MCC: usize, const MPL: usize, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature, UserKeypair, PD> AuthorisationToken<MCL, MCC, MPL, NamespacePublicKey, UserPublicKey, PD> for McAuthorisationToken<MCL, MCC, MPL, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature, UserKeypair>where
NamespacePublicKey: Clone + PartialEq + EncodableKnownLength,
NamespaceSignature: Clone,
UserPublicKey: Clone + PartialEq + EncodableKnownLength + Verifier<UserSignature>,
UserSignature: Clone,
PD: EncodableKnownLength,
UserKeypair: Signer<UserSignature>,
impl<const MCL: usize, const MCC: usize, const MPL: usize, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature, UserKeypair, PD> AuthorisationToken<MCL, MCC, MPL, NamespacePublicKey, UserPublicKey, PD> for McAuthorisationToken<MCL, MCC, MPL, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature, UserKeypair>where
NamespacePublicKey: Clone + PartialEq + EncodableKnownLength,
NamespaceSignature: Clone,
UserPublicKey: Clone + PartialEq + EncodableKnownLength + Verifier<UserSignature>,
UserSignature: Clone,
PD: EncodableKnownLength,
UserKeypair: Signer<UserSignature>,
Source§type Ingredients = McIngredients<MCL, MCC, MPL, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature, UserKeypair>
type Ingredients = McIngredients<MCL, MCC, MPL, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature, UserKeypair>
The type of the information you need in order to authorise an entry. For example, in Meadowcap, this would be a pair of a capability and a secret key.
Source§type CreationError = DoesNotAuthorise
type CreationError = DoesNotAuthorise
Everything that can go wrong when trying to create a new authorisation token from some
Ingredients for some entry.Source§fn new_for_entry<E>(
entry: &E,
ingredients: &Self::Ingredients,
) -> Result<Self, Self::CreationError>where
E: EntrylikeExt<MCL, MCC, MPL, NamespacePublicKey, UserPublicKey, PD> + ?Sized,
fn new_for_entry<E>(
entry: &E,
ingredients: &Self::Ingredients,
) -> Result<Self, Self::CreationError>where
E: EntrylikeExt<MCL, MCC, MPL, NamespacePublicKey, UserPublicKey, PD> + ?Sized,
Creates an authorisation token for the given entry, if possible.
Determines whether
self authorises the given entry.Source§impl<const MCL: usize, const MCC: usize, const MPL: usize, NamespacePublicKey: Clone, NamespaceSignature: Clone, UserPublicKey: Clone, UserSignature: Clone, UserKeypair: Clone> Clone for McAuthorisationToken<MCL, MCC, MPL, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature, UserKeypair>
impl<const MCL: usize, const MCC: usize, const MPL: usize, NamespacePublicKey: Clone, NamespaceSignature: Clone, UserPublicKey: Clone, UserSignature: Clone, UserKeypair: Clone> Clone for McAuthorisationToken<MCL, MCC, MPL, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature, UserKeypair>
Source§fn clone(
&self,
) -> McAuthorisationToken<MCL, MCC, MPL, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature, UserKeypair>
fn clone( &self, ) -> McAuthorisationToken<MCL, MCC, MPL, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature, UserKeypair>
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<const MCL: usize, const MCC: usize, const MPL: usize, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature, UserKeypair> Debug for McAuthorisationToken<MCL, MCC, MPL, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature, UserKeypair>
impl<const MCL: usize, const MCC: usize, const MPL: usize, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature, UserKeypair> Debug for McAuthorisationToken<MCL, MCC, MPL, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature, UserKeypair>
Source§impl<const MCL: usize, const MCC: usize, const MPL: usize, NamespacePublicKey: Hash, NamespaceSignature: Hash, UserPublicKey: Hash, UserSignature: Hash, UserKeypair: Hash> Hash for McAuthorisationToken<MCL, MCC, MPL, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature, UserKeypair>
impl<const MCL: usize, const MCC: usize, const MPL: usize, NamespacePublicKey: Hash, NamespaceSignature: Hash, UserPublicKey: Hash, UserSignature: Hash, UserKeypair: Hash> Hash for McAuthorisationToken<MCL, MCC, MPL, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature, UserKeypair>
Source§impl<const MCL: usize, const MCC: usize, const MPL: usize, NamespacePublicKey: PartialEq, NamespaceSignature: PartialEq, UserPublicKey: PartialEq, UserSignature: PartialEq, UserKeypair: PartialEq> PartialEq for McAuthorisationToken<MCL, MCC, MPL, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature, UserKeypair>
impl<const MCL: usize, const MCC: usize, const MPL: usize, NamespacePublicKey: PartialEq, NamespaceSignature: PartialEq, UserPublicKey: PartialEq, UserSignature: PartialEq, UserKeypair: PartialEq> PartialEq for McAuthorisationToken<MCL, MCC, MPL, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature, UserKeypair>
Source§fn eq(
&self,
other: &McAuthorisationToken<MCL, MCC, MPL, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature, UserKeypair>,
) -> bool
fn eq( &self, other: &McAuthorisationToken<MCL, MCC, MPL, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature, UserKeypair>, ) -> bool
Tests for
self and other values to be equal, and is used by ==.impl<const MCL: usize, const MCC: usize, const MPL: usize, NamespacePublicKey: Eq, NamespaceSignature: Eq, UserPublicKey: Eq, UserSignature: Eq, UserKeypair: Eq> Eq for McAuthorisationToken<MCL, MCC, MPL, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature, UserKeypair>
impl<const MCL: usize, const MCC: usize, const MPL: usize, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature, UserKeypair> StructuralPartialEq for McAuthorisationToken<MCL, MCC, MPL, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature, UserKeypair>
Auto Trait Implementations§
impl<const MCL: usize, const MCC: usize, const MPL: usize, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature, UserKeypair> Freeze for McAuthorisationToken<MCL, MCC, MPL, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature, UserKeypair>
impl<const MCL: usize, const MCC: usize, const MPL: usize, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature, UserKeypair> RefUnwindSafe for McAuthorisationToken<MCL, MCC, MPL, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature, UserKeypair>where
UserSignature: RefUnwindSafe,
UserKeypair: RefUnwindSafe,
NamespacePublicKey: RefUnwindSafe,
UserPublicKey: RefUnwindSafe,
NamespaceSignature: RefUnwindSafe,
impl<const MCL: usize, const MCC: usize, const MPL: usize, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature, UserKeypair> Send for McAuthorisationToken<MCL, MCC, MPL, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature, UserKeypair>
impl<const MCL: usize, const MCC: usize, const MPL: usize, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature, UserKeypair> Sync for McAuthorisationToken<MCL, MCC, MPL, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature, UserKeypair>
impl<const MCL: usize, const MCC: usize, const MPL: usize, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature, UserKeypair> Unpin for McAuthorisationToken<MCL, MCC, MPL, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature, UserKeypair>
impl<const MCL: usize, const MCC: usize, const MPL: usize, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature, UserKeypair> UnwindSafe for McAuthorisationToken<MCL, MCC, MPL, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature, UserKeypair>where
UserSignature: UnwindSafe,
UserKeypair: UnwindSafe,
NamespacePublicKey: UnwindSafe,
UserPublicKey: UnwindSafe,
NamespaceSignature: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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 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>
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