Skip to main content

PublicKey

Struct PublicKey 

Source
#[non_exhaustive]
pub struct PublicKey { pub bytes: Vec<u8>, pub printed: Option<String>, pub encoding: Option<String>, pub content_type: Option<String>, pub shape: PublicKeyShape, }
Expand description

The public key a station claims signed a record.

§Two shapes, both conformant in practice

The OCA application note §3.2.2 specifies Base64 over a colon-separated envelope — oca:<encoding>:<content-type>:<printed public key> — where the last part is the key as printed on the certified meter, so that a customer can compare it against the label on the cabinet. For base16 it adds that non-hexadecimal characters and a leading 0x “SHALL be ignored”, because a printed key has spaces in it.

The same document’s example message (§5.2) then sends Base64 over plain uppercase hexadecimal with no envelope at all. A reader that implements only the specification rejects the whitepaper’s own example; one that implements only the example rejects every conformant station. Both are in the field, so both are read here, and shape says which arrived.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§bytes: Vec<u8>

The key bytes.

§printed: Option<String>

The key as it was written — what to show a customer comparing it with the meter’s label. None for PublicKeyShape::Opaque, where there was no text.

§encoding: Option<String>

The envelope’s encoding token (base16, base32, base64), when there was an envelope.

§content_type: Option<String>

The envelope’s content type — the key’s own format, such as a curve name — when there was an envelope.

§shape: PublicKeyShape

Which shape the field arrived in.

Trait Implementations§

Source§

impl Clone for PublicKey

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 PublicKey

Source§

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

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

impl Eq for PublicKey

Source§

impl PartialEq for PublicKey

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for PublicKey

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> 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.