Skip to main content

SignedPolicy

Struct SignedPolicy 

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

A NamespacePolicy together with the namespace root key’s composite signature over its canonical bytes (the signed, in-log artifact).

The signature is produced by the same single-source-of-truth composite primitive that backs the Slice-3 hybrid checkpoint line, under the versioned context label <namespace>/namespace-policy/v1. ML-DSA signing is hedged, so the signature bytes are not reproducible, but verification is deterministic.

Implementations§

Source§

impl SignedPolicy

Source

pub fn sign(policy: NamespacePolicy, secret_key_b64: &str) -> Result<Self>

Sign policy with a metamorphic-crypto hybrid composite secret key (base64), binding the signature to the <namespace>/namespace-policy/v1 context.

§Errors

Returns Error::HybridSignature if the secret key cannot be decoded/derived or the composite signature cannot be produced, and propagates NamespacePolicy::context_label errors.

Source

pub fn from_parts( policy: NamespacePolicy, signing_public_key: Vec<u8>, signature: Vec<u8>, ) -> Self

Build a signed policy from already-produced parts (e.g. parsed from the log). Does not verify the signature; call SignedPolicy::verify.

Source

pub fn policy(&self) -> &NamespacePolicy

The wrapped policy.

Source

pub fn signing_public_key(&self) -> &[u8]

The namespace root signing public key (metamorphic-crypto composite tag || classical_pk || ml_dsa_pk).

Source

pub fn signature(&self) -> &[u8]

The composite signature bytes over the canonical policy.

Source

pub fn verify(&self) -> Result<&NamespacePolicy>

Verify the policy’s own composite signature under the namespace’s <namespace>/namespace-policy/v1 context. On success returns the verified NamespacePolicy.

A relying party should additionally check that signing_public_key matches the TOFU-pinned namespace root key (this is the application’s first-contact trust decision, not this library’s).

§Errors

Returns Error::InvalidSignature if the signature does not verify, and propagates NamespacePolicy::context_label errors. A structurally malformed key/signature is treated as a verification failure, never a panic.

Source

pub fn canonical_bytes(&self) -> Vec<u8>

Build the canonical serialization of the signed envelope:

signed_canonical =
    u32_be(SIGNED_POLICY_FORMAT_VERSION = 1)
 || lp(policy_canonical_bytes)
 || lp(signing_public_key)
 || lp(signature)

This is the Layer-0 leaf placed in the log.

Source

pub fn parse(bytes: &[u8]) -> Result<Self>

Parse a signed envelope from its canonical bytes (does not verify the signature; call SignedPolicy::verify).

§Errors

Returns Error::MalformedPolicy for an unknown format version, a length-prefix overrun, an empty key/signature, or trailing bytes; and propagates NamespacePolicy::parse errors.

Trait Implementations§

Source§

impl Clone for SignedPolicy

Source§

fn clone(&self) -> SignedPolicy

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 SignedPolicy

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Eq for SignedPolicy

Source§

impl PartialEq for SignedPolicy

Source§

fn eq(&self, other: &SignedPolicy) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for SignedPolicy

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<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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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 = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.