Struct matrix_sdk_qrcode::VerificationData
source · pub struct VerificationData { /* private fields */ }
Expand description
The non-encoded data for the first mode of QR code verification.
This mode is used for verification between two users using their master cross signing keys.
Implementations§
source§impl VerificationData
impl VerificationData
sourcepub fn new(
flow_id: String,
first_master_key: Ed25519PublicKey,
second_master_key: Ed25519PublicKey,
shared_secret: Base64,
) -> Self
pub fn new( flow_id: String, first_master_key: Ed25519PublicKey, second_master_key: Ed25519PublicKey, shared_secret: Base64, ) -> Self
Create a new VerificationData
struct that can be encoded as a QR code.
§Arguments
-
flow_id
- The event ID or transaction ID of them.key.verification.request
event that initiated the verification flow this QR code should be part of. -
first_master_key
- Our own cross signing master key. -
second_master_key
- The cross signing master key of the other user. -
shared_secret
- A random bytestring encoded as unpadded base64, needs to be at least 8 bytes long.
sourcepub fn to_bytes(&self) -> Result<Vec<u8>, EncodingError>
pub fn to_bytes(&self) -> Result<Vec<u8>, EncodingError>
Encode the VerificationData
into a vector of bytes that can be
encoded as a QR code.
The encoding can fail if the master keys that should be encoded are not valid base64.
§Examples
let data = b"MATRIX\
\x02\x00\x00\x0f\
$test:localhost\
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::Verification(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");
}
sourcepub fn to_qr_code(&self) -> Result<QrCode, EncodingError>
pub fn to_qr_code(&self) -> Result<QrCode, EncodingError>
Encode the VerificationData
into a QrCode
.
This method turns the VerificationData
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 VerificationData
impl Clone for VerificationData
source§fn clone(&self) -> VerificationData
fn clone(&self) -> VerificationData
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for VerificationData
impl Debug for VerificationData
source§impl From<VerificationData> for QrVerificationData
impl From<VerificationData> for QrVerificationData
source§fn from(data: VerificationData) -> Self
fn from(data: VerificationData) -> Self
source§impl PartialEq for VerificationData
impl PartialEq for VerificationData
source§fn eq(&self, other: &VerificationData) -> bool
fn eq(&self, other: &VerificationData) -> bool
self
and other
values to be equal, and is used
by ==
.impl Eq for VerificationData
impl StructuralPartialEq for VerificationData
Auto Trait Implementations§
impl Freeze for VerificationData
impl RefUnwindSafe for VerificationData
impl Send for VerificationData
impl Sync for VerificationData
impl Unpin for VerificationData
impl UnwindSafe for VerificationData
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.