Struct matrix_qrcode::SelfVerificationData
source · [−]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
sourceimpl SelfVerificationData
impl SelfVerificationData
sourcepub fn new(
transaction_id: String,
master_key: Ed25519PublicKey,
device_key: Ed25519PublicKey,
shared_secret: Base64<Standard, Vec<u8, Global>>
) -> SelfVerificationData
pub fn new(
transaction_id: String,
master_key: Ed25519PublicKey,
device_key: Ed25519PublicKey,
shared_secret: Base64<Standard, Vec<u8, Global>>
) -> SelfVerificationData
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. 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.
sourcepub fn to_bytes(&self) -> Result<Vec<u8, Global>, EncodingError>
pub fn to_bytes(&self) -> Result<Vec<u8, Global>, 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.
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");
}
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
sourceimpl Clone for SelfVerificationData
impl Clone for SelfVerificationData
sourcefn clone(&self) -> SelfVerificationData
fn clone(&self) -> SelfVerificationData
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 SelfVerificationData
impl Debug for SelfVerificationData
sourceimpl From<SelfVerificationData> for QrVerificationData
impl From<SelfVerificationData> for QrVerificationData
sourcefn from(data: SelfVerificationData) -> QrVerificationData
fn from(data: SelfVerificationData) -> QrVerificationData
Converts to this type from the input type.
sourceimpl PartialEq<SelfVerificationData> for SelfVerificationData
impl PartialEq<SelfVerificationData> for SelfVerificationData
sourcefn eq(&self, other: &SelfVerificationData) -> bool
fn eq(&self, other: &SelfVerificationData) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &SelfVerificationData) -> bool
fn ne(&self, other: &SelfVerificationData) -> bool
This method tests for !=
.
impl StructuralPartialEq for SelfVerificationData
Auto Trait Implementations
impl RefUnwindSafe for SelfVerificationData
impl Send for SelfVerificationData
impl Sync for SelfVerificationData
impl Unpin for SelfVerificationData
impl UnwindSafe for SelfVerificationData
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