Skip to main content

AgentKey

Struct AgentKey 

Source
pub struct AgentKey {
    pub kid: String,
    /* private fields */
}
Expand description

A P-256 signing key: the agent’s key that L2 binds under cnf and that signs L3a and L3b.

Fields§

§kid: String

The key id the L2 mandate’s cnf.jwk.kid carries and every L3 header repeats. Chosen at generation; stable for the key’s life.

Implementations§

Source§

impl AgentKey

Source

pub fn generate() -> Self

Generate a fresh key. The kid is the first 16 hex characters of SHA-256 over the SEC1 compressed point, prefixed vik_.

Source

pub fn from_secret(d: &[u8], kid: impl Into<String>) -> Result<Self, ViError>

Rebuild from the 32-byte private scalar and an explicit kid.

Source

pub fn from_private_jwk(v: &Value) -> Result<Self, ViError>

Import a private JWK (d present). Keeps the JWK’s kid when it has one, else derives the same kid generate would.

Source

pub fn secret_bytes(&self) -> [u8; 32]

The 32-byte private scalar, for sealing at rest.

Source

pub fn public_jwk(&self) -> Jwk

The public JWK with this key’s kid, as a wallet binds it under cnf.

Source

pub fn private_jwk(&self) -> Value

The private JWK (d included). For export to a wallet or HSM only.

Source

pub fn sign(&self, signing_input: &[u8]) -> Vec<u8> ⓘ

ES256: raw r || s, 64 bytes, deterministic (RFC 6979).

Trait Implementations§

Source§

impl Clone for AgentKey

Source§

fn clone(&self) -> AgentKey

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 AgentKey

Source§

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

Formats the value using the given formatter. Read more

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

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