Skip to main content

Pointer

Struct Pointer 

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

A paid, mutable, owner-signed reference.

A value of this type has been through Pointer::from_bytes, so its signature covers exactly its body and its address derives from its owner.

Implementations§

Source§

impl Pointer

Source

pub fn sign( secret_key: &MlDsaSecretKey, owner: &MlDsaPublicKey, counter: u64, target: PointerTarget, ) -> Result<Self, PointerError>

Build and sign a pointer.

§Errors

Returns PointerError::SigningFailed if signing fails, or a parse error if the resulting record does not parse, which would be a bug here rather than bad input.

Source

pub fn create( secret_key: &MlDsaSecretKey, owner: &MlDsaPublicKey, target: PointerTarget, ) -> Result<Self, PointerError>

Create a pointer at counter 0.

§Errors

As Self::sign.

Source

pub fn update( &self, secret_key: &MlDsaSecretKey, target: PointerTarget, ) -> Result<Self, PointerError>

Sign the update that follows this one: counter + 1, new target.

One past this record is the smallest counter that replaces it, and so the natural next state. A larger one would replace it just as well.

§Errors

Returns PointerError::CounterExhausted at u64::MAX, otherwise as Self::sign.

Source

pub fn from_bytes(bytes: &[u8]) -> Result<Self, PointerError>

Parse and fully validate a record.

Checks, cheapest first: length, format version, structure, then the signature. A returned Pointer is structurally valid and correctly signed by the key it carries; it says nothing about payment, which is a separate external check.

§Errors

Returns PointerError for a malformed record or one whose signature does not verify.

Source

pub fn verify_parsed(parsed: ParsedPointer) -> Result<Self, PointerError>

Verify a record that has already been parsed.

Decoding an ML-DSA public key is not free, and the request path parses before it decides whether verification is worth doing at all. This lets it hand over what it already has instead of decoding a second time.

§Errors

As Self::from_bytes.

Source

pub fn to_bytes(&self) -> Vec<u8> ⓘ

The canonical encoding of this record.

Re-encoded from the fields rather than cached. Every field is fixed-width with no optionality, so there is exactly one encoding and this is always byte-identical to what was signed.

Source

pub const fn owner(&self) -> &MlDsaPublicKey

The owner’s public key. Fixed for the pointer’s life.

Source

pub fn state(&self) -> PointerState

The signed state this record carries.

Derived, not stored: the identifiers are hashes of fields already here.

Source

pub const fn counter(&self) -> u64

The update counter.

Source

pub const fn target(&self) -> PointerTarget

What this pointer points at.

Source

pub fn address(&self) -> XorName

The address this record belongs at, derived from the owner key.

Source

pub fn state_id(&self) -> XorName

The authenticated-state identifier, derived from the signed body.

Names the state rather than the encoding, so two records carrying different valid signatures over one state share a state_id. This is what sync hints carry and what a quote is paid against.

Source

pub fn next_counter(&self) -> Result<u64, PointerError>

The successor counter for an update to this pointer.

§Errors

Returns PointerError::CounterExhausted at u64::MAX.

A pointer that must outlive its counter has to be migrated by an earlier update — one that retargets it at a fresh pointer while a successor counter still exists. A migration written at u64::MAX is not final: the counter is spent, so the only thing that still decides the merge is the target, and any record with smaller target bytes displaces it. A strictly larger counter is the one move nothing can answer, so migration must spend a counter it still has.

Source

pub const fn is_terminal(&self) -> bool

Whether this pointer’s counter is spent.

true once the counter reaches u64::MAX. Note this does not mean the stored value can no longer change: a record at the same counter with smaller target bytes still wins. It means the counter can no longer answer such a record, which is why clients migrate before reaching this rather than on it.

Source

pub fn replaces(&self, other: &Self) -> bool

Whether self replaces other under the merge rule.

See PointerState::replaces, which is where the rule lives.

Trait Implementations§

Source§

impl Clone for Pointer

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Pointer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Shows what identifies the record, not its 5 KB of key and signature.

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
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
Source§

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

Source§

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

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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

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

Source§

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

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

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

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

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

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

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