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

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. Needs to be encoded as unpadded base64

  • device_key - The ed25519 key of the other device, encoded as unpadded base64.

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

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.

Example
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");
}

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Converts to this type from the input type.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more