pub enum QrVerificationData {
Verification(VerificationData),
SelfVerification(SelfVerificationData),
SelfVerificationNoMasterKey(SelfVerificationNoMasterKey),
}
e2e-encryption
and qrcode
only.Expand description
An enum representing the different modes for a QR verification code.
Variants§
Verification(VerificationData)
The QR verification is verifying another user.
It relies on both devices already trusting or owning the master cross-signing key for the corresponding user.
In this case, the QR code data includes:
- The master cross-signing key of the displaying device’s user.
- What the displaying device believes is the master cross-signing key of the scanning device’s user.
After a successful verification, each device will trust the cross-signing key of the other user, and will upload a cross-signature of that key.
SelfVerification(SelfVerificationData)
The QR verification is self-verifying and the device displaying the QR code trusts or owns the master cross-signing key.
This normally happens when the displaying device is an existing device, and the scanning device is new.
In this case, the QR code data includes:
- The master cross-signing key (which is trusted by the displaying device).
- What the displaying device believes is the device key of the scanning device.
After a successful verification, the scanning device will be able to trust the master key, and the displaying device will be able to trust the scanning device’s device key.
Since the displaying device should be cross-signed already, this means that the scanning device will now trust the displaying device.
The displaying device will then upload a cross-signature of the scanning device (assuming it has the private key), and will send the secret keys to the scanning device.
SelfVerificationNoMasterKey(SelfVerificationNoMasterKey)
The QR verification is self-verifying in which the current device does not yet trust the master key.
This normally happens when the displaying device is new, and the scanning device is an existing device.
In this case, the QR code data includes:
- The displaying device’s device key.
- What the displaying device believes is the master cross-signing key.
If the verification is successful, the scanning device will be able to trust the displaying device’s device key, and the displaying device will be able to trust the master key.
Since the scanning device should be cross-signed already, this means that the displaying device will now trust the scanning device.
The scanning device will then upload a cross-signature of the displaying device (assuming it has the private key), and will send the secret keys to the displaying device.
Implementations§
source§impl QrVerificationData
impl QrVerificationData
sourcepub fn from_bytes(
bytes: impl AsRef<[u8]>,
) -> Result<QrVerificationData, DecodingError>
pub fn from_bytes( bytes: impl AsRef<[u8]>, ) -> Result<QrVerificationData, DecodingError>
Parse the decoded payload of a QR code in byte slice form as a
QrVerificationData
This method is useful if you would like to do your own custom QR code decoding.
§Arguments
bytes
- The raw bytes of a decoded QR code.
§Examples
let data = b"MATRIX\
\x02\x02\x00\x07\
FLOW_ID\
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)?;
sourcepub fn to_qr_code(&self) -> Result<QrCode, EncodingError>
pub fn to_qr_code(&self) -> Result<QrCode, EncodingError>
Encode the QrVerificationData
into a QrCode
.
This method turns the QrVerificationData
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 identity keys that should be encoded into the QR code are not valid base64.
§Examples
let data = b"MATRIX\
\x02\x02\x00\x07\
FLOW_ID\
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)?;
let encoded = result.to_qr_code().unwrap();
sourcepub fn to_bytes(&self) -> Result<Vec<u8>, EncodingError>
pub fn to_bytes(&self) -> Result<Vec<u8>, EncodingError>
Encode the QrVerificationData
into a vector of bytes that can be
encoded as a QR code.
The encoding can fail if the identity keys that should be encoded are not valid base64.
§Examples
let data = b"MATRIX\
\x02\x02\x00\x07\
FLOW_ID\
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)?;
let encoded = result.to_bytes().unwrap();
assert_eq!(data.as_ref(), encoded.as_slice());
sourcepub fn flow_id(&self) -> &str
pub fn flow_id(&self) -> &str
Get the flow id for this QrVerificationData
.
This represents the ID as a string even if it is a EventId
.
sourcepub fn first_key(&self) -> Ed25519PublicKey
pub fn first_key(&self) -> Ed25519PublicKey
Get the first key of this QrVerificationData
.
sourcepub fn second_key(&self) -> Ed25519PublicKey
pub fn second_key(&self) -> Ed25519PublicKey
Get the second key of this QrVerificationData
.
Trait Implementations§
source§impl Clone for QrVerificationData
impl Clone for QrVerificationData
source§fn clone(&self) -> QrVerificationData
fn clone(&self) -> QrVerificationData
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for QrVerificationData
impl Debug for QrVerificationData
source§impl From<SelfVerificationData> for QrVerificationData
impl From<SelfVerificationData> for QrVerificationData
source§fn from(data: SelfVerificationData) -> QrVerificationData
fn from(data: SelfVerificationData) -> QrVerificationData
source§impl From<SelfVerificationNoMasterKey> for QrVerificationData
impl From<SelfVerificationNoMasterKey> for QrVerificationData
source§fn from(data: SelfVerificationNoMasterKey) -> QrVerificationData
fn from(data: SelfVerificationNoMasterKey) -> QrVerificationData
source§impl From<VerificationData> for QrVerificationData
impl From<VerificationData> for QrVerificationData
source§fn from(data: VerificationData) -> QrVerificationData
fn from(data: VerificationData) -> QrVerificationData
source§impl PartialEq for QrVerificationData
impl PartialEq for QrVerificationData
source§fn eq(&self, other: &QrVerificationData) -> bool
fn eq(&self, other: &QrVerificationData) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl TryFrom<&[u8]> for QrVerificationData
impl TryFrom<&[u8]> for QrVerificationData
§type Error = DecodingError
type Error = DecodingError
source§fn try_from(
value: &[u8],
) -> Result<QrVerificationData, <QrVerificationData as TryFrom<&[u8]>>::Error>
fn try_from( value: &[u8], ) -> Result<QrVerificationData, <QrVerificationData as TryFrom<&[u8]>>::Error>
source§impl TryFrom<Vec<u8>> for QrVerificationData
impl TryFrom<Vec<u8>> for QrVerificationData
§type Error = DecodingError
type Error = DecodingError
impl Eq for QrVerificationData
impl StructuralPartialEq for QrVerificationData
Auto Trait Implementations§
impl Freeze for QrVerificationData
impl RefUnwindSafe for QrVerificationData
impl Send for QrVerificationData
impl Sync for QrVerificationData
impl Unpin for QrVerificationData
impl UnwindSafe for QrVerificationData
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
)§impl<T> CompatExt for T
impl<T> CompatExt for T
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.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.source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<T> FutureExt for T
impl<T> FutureExt for T
source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
source§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
source§fn consume_handle(handle: Handle) -> Arc<T>
fn consume_handle(handle: Handle) -> Arc<T>
Arc<>
source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more