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
impl SelfVerificationData
Sourcepub fn new(
transaction_id: String,
master_key: Ed25519PublicKey,
device_key: Ed25519PublicKey,
shared_secret: Base64,
) -> Self
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 them.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.
Sourcepub fn to_bytes(&self) -> Result<Vec<u8>, EncodingError>
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");
}
Sourcepub fn to_qr_code(&self) -> Result<QrCode, EncodingError>
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
impl Clone for SelfVerificationData
Source§fn clone(&self) -> SelfVerificationData
fn clone(&self) -> SelfVerificationData
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for SelfVerificationData
impl Debug for SelfVerificationData
Source§impl From<SelfVerificationData> for QrVerificationData
impl From<SelfVerificationData> for QrVerificationData
Source§fn from(data: SelfVerificationData) -> Self
fn from(data: SelfVerificationData) -> Self
Source§impl PartialEq for SelfVerificationData
impl PartialEq for SelfVerificationData
impl Eq for SelfVerificationData
impl StructuralPartialEq for SelfVerificationData
Auto Trait Implementations§
impl Freeze for SelfVerificationData
impl RefUnwindSafe for SelfVerificationData
impl Send for SelfVerificationData
impl Sync for SelfVerificationData
impl Unpin for SelfVerificationData
impl UnwindSafe for SelfVerificationData
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
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§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.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,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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