Struct matrix_sdk_qrcode::SelfVerificationData

source ·
pub struct SelfVerificationData { /* private fields */ }
Expand description

The non-encoded data for the second mode of QR code verification.

This mode is used for verification between two devices of the same user where this device, that is creating this QR code, is trusting or owning the cross signing master key.

Implementations§

source§

impl SelfVerificationData

source

pub fn new( transaction_id: String, master_key: Ed25519PublicKey, device_key: Ed25519PublicKey, shared_secret: Base64 ) -> Self

Create a new SelfVerificationData struct that can be encoded as a QR code.

§Arguments
  • transaction_id - The transaction id of this verification flow, the transaction id was sent by the m.key.verification.request event that initiated the verification flow this QR code should be part of.

  • master_key - Our own cross signing master key.

  • device_key - The ed25519 key of the other device.

  • shared_secret - A random bytestring encoded as unpadded base64, needs to be at least 8 bytes long.

source

pub fn to_bytes(&self) -> Result<Vec<u8>, EncodingError>

Encode the SelfVerificationData into a vector of bytes that can be encoded as a QR code.

The encoding can fail if the keys that should be encoded are not valid base64.

§Examples
let data = b"MATRIX\
             \x02\x01\x00\x06\
             FLOWID\
             kS /\x92i\x1e6\xcd'g\xf9#\x11\xd8\x8a\xa2\xf61\x05\x1b6\xef\xfc\xa4%\x80\x1a\x0c\xd2\xe8\x04\
             \xbdR|\xf8n\x07\xa4\x1f\xb4\xcc3\x0eBT\xe7[~\xfd\x87\xd06B\xdfoVv%\x9b\x86\xae\xbcM\
             SHARED_SECRET";

let result = QrVerificationData::from_bytes(data)?;
if let QrVerificationData::SelfVerification(decoded) = result {
    let encoded = decoded.to_bytes().unwrap();
    assert_eq!(data.as_ref(), encoded.as_slice());
} else {
    panic!("Data was encoded as an incorrect mode");
}
source

pub fn to_qr_code(&self) -> Result<QrCode, EncodingError>

Encode the SelfVerificationData into a QrCode.

This method turns the SelfVerificationData into a QR code that can be rendered and presented to be scanned.

The encoding can fail if the data doesn’t fit into a QR code or if the keys that should be encoded into the QR code are not valid base64.

Trait Implementations§

source§

impl Clone for SelfVerificationData

source§

fn clone(&self) -> SelfVerificationData

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for SelfVerificationData

source§

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

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

impl From<SelfVerificationData> for QrVerificationData

source§

fn from(data: SelfVerificationData) -> Self

Converts to this type from the input type.
source§

impl PartialEq for SelfVerificationData

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for SelfVerificationData

source§

impl StructuralPartialEq for SelfVerificationData

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, W> HasTypeWitness<W> for T
where W: MakeTypeWitness<Arg = T>, T: ?Sized,

source§

const WITNESS: W = W::MAKE

A constant of the type witness
source§

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

§

type Type = T

The same type as Self, used to emulate type equality bounds (T == U) with associated type equality constraints (T: Identity<Type = U>).
source§

const TYPE_EQ: TypeEq<T, <T as Identity>::Type> = TypeEq::NEW

Proof that Self is the same type as Self::Type, provides methods for casting between Self and Self::Type.
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> Same for T

§

type Output = T

Should always be Self
source§

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

§

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

§

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

§

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