pub struct SubspaceId(/* private fields */);Expand description
The type of SubspaceIds used by Willow’25.
Subspaces group Willow data within the same namespace into independent collections — entries with nonequal subspace ids cannot overwrite each other. Subspaces further play a role in access control for Willow: subspace ids are public keys of a digital signature system, and knowledge of the corresponding secret key allow you to issue write entries to a subspace, and to delegate access to other users — see the meadowcap module for more details.
That all said, you can also simply think of subspace ids as glorified [u8; 32] arrays. That perspective should be sufficient as long as you do not need to care about cryptographic details.
You will typically obtain a subspace id either by randomly generating a key pair, by cloning an existing subspace id, or by creating it from raw bytes via SubspaceId::from_bytes. See the Willow25 specification if you want to work with raw bytes — while every [u8; 32] can be converted into a SubspaceId, some of these do not correspond to canonic public key encodings and thus always fail signature verification.
use rand::rngs::OsRng;
use willow25::prelude::*;
let mut csprng = OsRng; // cryptographically secure pseudo-random number generator
let (_subspace_id, _secret) = randomly_generate_subspace(&mut csprng);
let subspace_id2 = SubspaceId::from_bytes(&[17; SUBSPACE_ID_WIDTH]);
assert_eq!(subspace_id2.as_bytes(), &[17; 32]);Implementations§
Source§impl SubspaceId
impl SubspaceId
Sourcepub fn from_bytes(bytes: &[u8; 32]) -> Self
pub fn from_bytes(bytes: &[u8; 32]) -> Self
Returns a new SubspaceId corresponding to the supplied bytes.
use willow25::prelude::*;
let subspace_id = SubspaceId::from_bytes(&[17; SUBSPACE_ID_WIDTH]);
assert_eq!(subspace_id.as_bytes(), &[17; SUBSPACE_ID_WIDTH]);Sourcepub fn as_bytes(&self) -> &[u8; 32]
pub fn as_bytes(&self) -> &[u8; 32]
Returns a reference to the raw bytes that make up this subspace id.
use willow25::prelude::*;
let subspace_id = SubspaceId::from_bytes(&[17; SUBSPACE_ID_WIDTH]);
assert_eq!(subspace_id.as_bytes(), &[17; SUBSPACE_ID_WIDTH]);Sourcepub fn to_bytes(&self) -> [u8; 32]
pub fn to_bytes(&self) -> [u8; 32]
Returns the raw bytes that make up this subspace id.
use willow25::prelude::*;
let subspace_id = SubspaceId::from_bytes(&[17; SUBSPACE_ID_WIDTH]);
assert_eq!(subspace_id.to_bytes(), [17; SUBSPACE_ID_WIDTH]);Sourcepub fn from_ed25519_verifying_key(verifying_key: VerifyingKey) -> Self
pub fn from_ed25519_verifying_key(verifying_key: VerifyingKey) -> Self
Creates a subspace id from an ed25519 verifying key.
use willow25::prelude::*;
let from_key = SubspaceId::from_ed25519_verifying_key(
ed25519_dalek::VerifyingKey::from_bytes(&[17; 32]).unwrap(),
);
let from_bytes = SubspaceId::from_bytes(&[17; SUBSPACE_ID_WIDTH]);
assert_eq!(from_key, from_bytes);Trait Implementations§
Source§impl AuthorisationToken<MCL, MCC, MPL, NamespaceId, SubspaceId, PayloadDigest> for AuthorisationToken
You only need this trait impl if you work with fully generic code from the willow_data_model crate.
impl AuthorisationToken<MCL, MCC, MPL, NamespaceId, SubspaceId, PayloadDigest> for AuthorisationToken
You only need this trait impl if you work with fully generic code from the willow_data_model crate.
Source§type Ingredients = McIngredients
type Ingredients = McIngredients
Source§type CreationError = DoesNotAuthorise
type CreationError = DoesNotAuthorise
Ingredients for some entry.Source§fn new_for_entry<E>(
entry: &E,
ingredients: &Self::Ingredients,
) -> Result<Self, Self::CreationError>
fn new_for_entry<E>( entry: &E, ingredients: &Self::Ingredients, ) -> Result<Self, Self::CreationError>
self authorises the given entry.Source§impl Clone for SubspaceId
impl Clone for SubspaceId
Source§fn clone(&self) -> SubspaceId
fn clone(&self) -> SubspaceId
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Coordinatelike<MCL, MCC, MPL, SubspaceId> for (Path, SubspaceId, Timestamp)
impl Coordinatelike<MCL, MCC, MPL, SubspaceId> for (Path, SubspaceId, Timestamp)
Source§fn wdm_timestamp(&self) -> Timestamp
fn wdm_timestamp(&self) -> Timestamp
self.Source§impl Coordinatelike<MCL, MCC, MPL, SubspaceId> for (Path, Timestamp, SubspaceId)
impl Coordinatelike<MCL, MCC, MPL, SubspaceId> for (Path, Timestamp, SubspaceId)
Source§fn wdm_timestamp(&self) -> Timestamp
fn wdm_timestamp(&self) -> Timestamp
self.Source§impl Coordinatelike<MCL, MCC, MPL, SubspaceId> for (SubspaceId, Path, Timestamp)
impl Coordinatelike<MCL, MCC, MPL, SubspaceId> for (SubspaceId, Path, Timestamp)
Source§fn wdm_timestamp(&self) -> Timestamp
fn wdm_timestamp(&self) -> Timestamp
self.Source§impl Coordinatelike<MCL, MCC, MPL, SubspaceId> for (SubspaceId, Timestamp, Path)
impl Coordinatelike<MCL, MCC, MPL, SubspaceId> for (SubspaceId, Timestamp, Path)
Source§fn wdm_timestamp(&self) -> Timestamp
fn wdm_timestamp(&self) -> Timestamp
self.Source§impl Coordinatelike<MCL, MCC, MPL, SubspaceId> for (Timestamp, Path, SubspaceId)
impl Coordinatelike<MCL, MCC, MPL, SubspaceId> for (Timestamp, Path, SubspaceId)
Source§fn wdm_timestamp(&self) -> Timestamp
fn wdm_timestamp(&self) -> Timestamp
self.Source§impl Coordinatelike<MCL, MCC, MPL, SubspaceId> for (Timestamp, SubspaceId, Path)
impl Coordinatelike<MCL, MCC, MPL, SubspaceId> for (Timestamp, SubspaceId, Path)
Source§fn wdm_timestamp(&self) -> Timestamp
fn wdm_timestamp(&self) -> Timestamp
self.Source§impl Coordinatelike<MCL, MCC, MPL, SubspaceId> for AuthorisedEntry
impl Coordinatelike<MCL, MCC, MPL, SubspaceId> for AuthorisedEntry
Source§fn wdm_timestamp(&self) -> Timestamp
fn wdm_timestamp(&self) -> Timestamp
self.Source§impl Coordinatelike<MCL, MCC, MPL, SubspaceId> for Entry
impl Coordinatelike<MCL, MCC, MPL, SubspaceId> for Entry
Source§fn wdm_timestamp(&self) -> Timestamp
fn wdm_timestamp(&self) -> Timestamp
self.Source§impl Coordinatelike<MCL, MCC, MPL, SubspaceId> for PossiblyAuthorisedEntry
impl Coordinatelike<MCL, MCC, MPL, SubspaceId> for PossiblyAuthorisedEntry
Source§fn wdm_timestamp(&self) -> Timestamp
fn wdm_timestamp(&self) -> Timestamp
self.Source§impl Debug for SubspaceId
impl Debug for SubspaceId
Source§impl Decodable for SubspaceId
impl Decodable for SubspaceId
Source§type ErrorReason = Infallible
type ErrorReason = Infallible
Source§async fn decode<P>(
producer: &mut P,
) -> Result<Self, DecodeError<P::Final, P::Error, Self::ErrorReason>>
async fn decode<P>( producer: &mut P, ) -> Result<Self, DecodeError<P::Final, P::Error, Self::ErrorReason>>
Self, or yields an error if the producer does not produce a valid encoding. Read moreSource§impl DecodableCanonic for SubspaceId
impl DecodableCanonic for SubspaceId
Source§type ErrorCanonic = Infallible
type ErrorCanonic = Infallible
Self. Read moreSource§async fn decode_canonic<P>(
producer: &mut P,
) -> Result<Self, DecodeError<P::Final, P::Error, Self::ErrorCanonic>>
async fn decode_canonic<P>( producer: &mut P, ) -> Result<Self, DecodeError<P::Final, P::Error, Self::ErrorCanonic>>
Self, and errors if the input encoding is not the canonical one.Source§impl Encodable for SubspaceId
impl Encodable for SubspaceId
Source§impl EncodableKnownLength for SubspaceId
impl EncodableKnownLength for SubspaceId
Source§fn len_of_encoding(&self) -> usize
fn len_of_encoding(&self) -> usize
self. A successful call to encode must feed exactly that many symbols into the bulk consumer.Source§impl Entrylike<MCL, MCC, MPL, NamespaceId, SubspaceId, PayloadDigest> for AuthorisedEntry
impl Entrylike<MCL, MCC, MPL, NamespaceId, SubspaceId, PayloadDigest> for AuthorisedEntry
Source§fn wdm_payload_length(&self) -> u64
fn wdm_payload_length(&self) -> u64
self.Source§fn wdm_payload_digest(&self) -> &PayloadDigest
fn wdm_payload_digest(&self) -> &PayloadDigest
self.Source§impl Entrylike<MCL, MCC, MPL, NamespaceId, SubspaceId, PayloadDigest> for Entry
impl Entrylike<MCL, MCC, MPL, NamespaceId, SubspaceId, PayloadDigest> for Entry
Source§fn wdm_payload_length(&self) -> u64
fn wdm_payload_length(&self) -> u64
self.Source§fn wdm_payload_digest(&self) -> &PayloadDigest
fn wdm_payload_digest(&self) -> &PayloadDigest
self.Source§impl Entrylike<MCL, MCC, MPL, NamespaceId, SubspaceId, PayloadDigest> for PossiblyAuthorisedEntry
impl Entrylike<MCL, MCC, MPL, NamespaceId, SubspaceId, PayloadDigest> for PossiblyAuthorisedEntry
Source§fn wdm_payload_length(&self) -> u64
fn wdm_payload_length(&self) -> u64
self.Source§fn wdm_payload_digest(&self) -> &PayloadDigest
fn wdm_payload_digest(&self) -> &PayloadDigest
self.Source§impl GreatestElement for SubspaceId
impl GreatestElement for SubspaceId
Source§impl Hash for SubspaceId
impl Hash for SubspaceId
Source§impl Keylike<MCL, MCC, MPL, SubspaceId> for (Path, SubspaceId)
impl Keylike<MCL, MCC, MPL, SubspaceId> for (Path, SubspaceId)
Source§fn wdm_subspace_id(&self) -> &SubspaceId
fn wdm_subspace_id(&self) -> &SubspaceId
self.Source§impl Keylike<MCL, MCC, MPL, SubspaceId> for (Path, SubspaceId, Timestamp)
impl Keylike<MCL, MCC, MPL, SubspaceId> for (Path, SubspaceId, Timestamp)
Source§fn wdm_subspace_id(&self) -> &SubspaceId
fn wdm_subspace_id(&self) -> &SubspaceId
self.Source§impl Keylike<MCL, MCC, MPL, SubspaceId> for (Path, Timestamp, SubspaceId)
impl Keylike<MCL, MCC, MPL, SubspaceId> for (Path, Timestamp, SubspaceId)
Source§fn wdm_subspace_id(&self) -> &SubspaceId
fn wdm_subspace_id(&self) -> &SubspaceId
self.Source§impl Keylike<MCL, MCC, MPL, SubspaceId> for (SubspaceId, Path)
impl Keylike<MCL, MCC, MPL, SubspaceId> for (SubspaceId, Path)
Source§fn wdm_subspace_id(&self) -> &SubspaceId
fn wdm_subspace_id(&self) -> &SubspaceId
self.Source§impl Keylike<MCL, MCC, MPL, SubspaceId> for (SubspaceId, Path, Timestamp)
impl Keylike<MCL, MCC, MPL, SubspaceId> for (SubspaceId, Path, Timestamp)
Source§fn wdm_subspace_id(&self) -> &SubspaceId
fn wdm_subspace_id(&self) -> &SubspaceId
self.Source§impl Keylike<MCL, MCC, MPL, SubspaceId> for (SubspaceId, Timestamp, Path)
impl Keylike<MCL, MCC, MPL, SubspaceId> for (SubspaceId, Timestamp, Path)
Source§fn wdm_subspace_id(&self) -> &SubspaceId
fn wdm_subspace_id(&self) -> &SubspaceId
self.Source§impl Keylike<MCL, MCC, MPL, SubspaceId> for (Timestamp, Path, SubspaceId)
impl Keylike<MCL, MCC, MPL, SubspaceId> for (Timestamp, Path, SubspaceId)
Source§fn wdm_subspace_id(&self) -> &SubspaceId
fn wdm_subspace_id(&self) -> &SubspaceId
self.Source§impl Keylike<MCL, MCC, MPL, SubspaceId> for (Timestamp, SubspaceId, Path)
impl Keylike<MCL, MCC, MPL, SubspaceId> for (Timestamp, SubspaceId, Path)
Source§fn wdm_subspace_id(&self) -> &SubspaceId
fn wdm_subspace_id(&self) -> &SubspaceId
self.Source§impl Keylike<MCL, MCC, MPL, SubspaceId> for AuthorisedEntry
impl Keylike<MCL, MCC, MPL, SubspaceId> for AuthorisedEntry
Source§fn wdm_subspace_id(&self) -> &SubspaceId
fn wdm_subspace_id(&self) -> &SubspaceId
self.Source§impl Keylike<MCL, MCC, MPL, SubspaceId> for Entry
impl Keylike<MCL, MCC, MPL, SubspaceId> for Entry
Source§fn wdm_subspace_id(&self) -> &SubspaceId
fn wdm_subspace_id(&self) -> &SubspaceId
self.Source§impl Keylike<MCL, MCC, MPL, SubspaceId> for PossiblyAuthorisedEntry
impl Keylike<MCL, MCC, MPL, SubspaceId> for PossiblyAuthorisedEntry
Source§fn wdm_subspace_id(&self) -> &SubspaceId
fn wdm_subspace_id(&self) -> &SubspaceId
self.Source§impl LeastElement for SubspaceId
impl LeastElement for SubspaceId
Source§impl LowerSemilattice for SubspaceId
impl LowerSemilattice for SubspaceId
Source§fn greatest_lower_bound(&self, other: &Self) -> Self
fn greatest_lower_bound(&self, other: &Self) -> Self
self and other, i.e., the unique greatest element in the type which is less than or equal to both self and other.Source§impl Ord for SubspaceId
Implemented lexicographically on the compressed Edwards y coordinate encoding.
impl Ord for SubspaceId
Implemented lexicographically on the compressed Edwards y coordinate encoding.
Source§impl PartialEq for SubspaceId
impl PartialEq for SubspaceId
Source§impl PartialOrd for SubspaceId
Implemented lexicographically on the compressed Edwards y coordinate encoding.
impl PartialOrd for SubspaceId
Implemented lexicographically on the compressed Edwards y coordinate encoding.
Source§impl RangeBounds<SubspaceId> for Area
impl RangeBounds<SubspaceId> for Area
Source§impl RangeBounds<SubspaceId> for Range3d
impl RangeBounds<SubspaceId> for Range3d
Source§impl TryPredecessor for SubspaceId
impl TryPredecessor for SubspaceId
Source§fn try_predecessor(&self) -> Option<Self>
fn try_predecessor(&self) -> Option<Self>
self has a predecessor, i.e., a unique greatest value which is strictly less than self, returns it. If there is no unique predecessor, returns None.Source§fn is_predecessor_of(&self, other: &Self) -> bool
fn is_predecessor_of(&self, other: &Self) -> bool
true iff self is the predecessor of other.Source§fn is_not_predecessor_of(&self, other: &Self) -> bool
fn is_not_predecessor_of(&self, other: &Self) -> bool
true iff self is not the predecessor of other.Source§impl TrySuccessor for SubspaceId
impl TrySuccessor for SubspaceId
Source§fn try_successor(&self) -> Option<Self>
fn try_successor(&self) -> Option<Self>
self has a successor, i.e., a unique least value which is strictly greater than self, returns it. If there is no unique successor, returns None.Source§fn is_successor_of(&self, other: &Self) -> bool
fn is_successor_of(&self, other: &Self) -> bool
true iff self is the successor of other.Source§fn is_not_successor_of(&self, other: &Self) -> bool
fn is_not_successor_of(&self, other: &Self) -> bool
true iff self is not the successor of other.Source§impl UpperSemilattice for SubspaceId
impl UpperSemilattice for SubspaceId
Source§fn least_upper_bound(&self, other: &Self) -> Self
fn least_upper_bound(&self, other: &Self) -> Self
self and other, i.e., the unique least element in the type which is greater than or equal to both self and other.Source§impl Verifier<SubspaceSignature> for SubspaceId
impl Verifier<SubspaceSignature> for SubspaceId
impl Eq for SubspaceId
impl PredecessorExceptForLeast for SubspaceId
impl StructuralPartialEq for SubspaceId
impl SuccessorExceptForGreatest for SubspaceId
Auto Trait Implementations§
impl Freeze for SubspaceId
impl RefUnwindSafe for SubspaceId
impl Send for SubspaceId
impl Sync for SubspaceId
impl Unpin for SubspaceId
impl UnwindSafe for SubspaceId
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
Source§impl<T> BoundedLowerSemilattice for Twhere
T: LowerSemilattice + LeastElement,
impl<T> BoundedLowerSemilattice for Twhere
T: LowerSemilattice + LeastElement,
Source§fn greatest_lower_bound_slice(values: &[Self]) -> Self
fn greatest_lower_bound_slice(values: &[Self]) -> Self
Source§impl<T> BoundedUpperSemilattice for Twhere
T: UpperSemilattice + GreatestElement,
impl<T> BoundedUpperSemilattice for Twhere
T: UpperSemilattice + GreatestElement,
Source§fn least_upper_bound_slice(values: &[Self]) -> Self
fn least_upper_bound_slice(values: &[Self]) -> Self
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, S> EncodableExt<S> for Twhere
T: Encodable<S>,
impl<T, S> EncodableExt<S> for Twhere
T: Encodable<S>,
Source§impl<T, S> EncodableKnownLengthExt<S> for Twhere
T: EncodableKnownLength<S>,
impl<T, S> EncodableKnownLengthExt<S> for Twhere
T: EncodableKnownLength<S>,
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