Struct matrix_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
sourceimpl VerificationData
impl VerificationData
sourcepub fn new(
event_id: OwnedEventId,
first_key: Ed25519PublicKey,
second_key: Ed25519PublicKey,
shared_secret: Base64<Standard, Vec<u8, Global>>
) -> VerificationData
pub fn new(
event_id: OwnedEventId,
first_key: Ed25519PublicKey,
second_key: Ed25519PublicKey,
shared_secret: Base64<Standard, Vec<u8, Global>>
) -> VerificationData
Create a new VerificationData
struct that can be encoded as a QR code.
Arguments
-
event_id
- The event id of them.key.verification.request
event that initiated the verification flow this QR code should be part of. -
first_key
- Our own cross signing master key. Needs to be encoded as unpadded base64 -
second_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, Global>, EncodingError>
pub fn to_bytes(&self) -> Result<Vec<u8, Global>, 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.
Example
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
sourceimpl Clone for VerificationData
impl Clone for VerificationData
sourcefn clone(&self) -> VerificationData
fn clone(&self) -> VerificationData
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for VerificationData
impl Debug for VerificationData
sourceimpl From<VerificationData> for QrVerificationData
impl From<VerificationData> for QrVerificationData
sourcefn from(data: VerificationData) -> QrVerificationData
fn from(data: VerificationData) -> QrVerificationData
Converts to this type from the input type.
sourceimpl PartialEq<VerificationData> for VerificationData
impl PartialEq<VerificationData> for VerificationData
sourcefn eq(&self, other: &VerificationData) -> bool
fn eq(&self, other: &VerificationData) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &VerificationData) -> bool
fn ne(&self, other: &VerificationData) -> bool
This method tests for !=
.
impl StructuralPartialEq for VerificationData
Auto Trait Implementations
impl RefUnwindSafe for VerificationData
impl Send for VerificationData
impl Sync for VerificationData
impl Unpin for VerificationData
impl UnwindSafe for VerificationData
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more