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
impl SignedPolicy
Sourcepub fn sign(policy: NamespacePolicy, secret_key_b64: &str) -> Result<Self>
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.
Sourcepub fn from_parts(
policy: NamespacePolicy,
signing_public_key: Vec<u8>,
signature: Vec<u8>,
) -> Self
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.
Sourcepub fn policy(&self) -> &NamespacePolicy
pub fn policy(&self) -> &NamespacePolicy
The wrapped policy.
Sourcepub fn signing_public_key(&self) -> &[u8] ⓘ
pub fn signing_public_key(&self) -> &[u8] ⓘ
The namespace root signing public key (metamorphic-crypto composite
tag || classical_pk || ml_dsa_pk).
Sourcepub fn verify(&self) -> Result<&NamespacePolicy>
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.
Sourcepub fn canonical_bytes(&self) -> Vec<u8> ⓘ
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.
Sourcepub fn parse(bytes: &[u8]) -> Result<Self>
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
impl Clone for SignedPolicy
Source§fn clone(&self) -> SignedPolicy
fn clone(&self) -> SignedPolicy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SignedPolicy
impl Debug for SignedPolicy
impl Eq for SignedPolicy
Source§impl PartialEq for SignedPolicy
impl PartialEq for SignedPolicy
Source§fn eq(&self, other: &SignedPolicy) -> bool
fn eq(&self, other: &SignedPolicy) -> bool
self and other values to be equal, and is used by ==.