pub struct KeyQueryResponseTemplate { /* private fields */ }
Expand description
A test helper for building test data sets for /keys/query
response objects
([KeyQueryResponse
]).
§Examples
A simple case with no cross-signing identity and a single device:
// Note that (almost) any 32-byte sequence can be used as a private Ed25519 or Curve25519 key.
// You can also use an arbitrary 32-byte sequence as a *public* key though of course you will
// not know the private key it corresponds to (if indeed there is one).
let template = KeyQueryResponseTemplate::new(owned_user_id!("@alice:localhost"))
.with_device(
device_id!("TESTDEVICE"),
&Curve25519PublicKey::from(b"curvepubcurvepubcurvepubcurvepub".to_owned()),
&Ed25519SecretKey::from_slice(b"device12device12device12device12"),
KeyQueryResponseTemplateDeviceOptions::new(),
);
let response = template.build_response();
A more complex case, with cross-signing keys and a signed device:
let template = KeyQueryResponseTemplate::new(owned_user_id!("@me:localhost"))
// add cross-signing keys
.with_cross_signing_keys(
Ed25519SecretKey::from_slice(b"master12master12master12master12"),
Ed25519SecretKey::from_slice(b"self1234self1234self1234self1234"),
Ed25519SecretKey::from_slice(b"user1234user1234user1234user1234"),
)
// add verification from another user
.with_user_verification_signature(
user_id!("@them:localhost"),
&Ed25519SecretKey::from_slice(b"otheruser12otheruser12otheruser1"),
)
// add signed device
.with_device(
device_id!("SECUREDEVICE"),
&Curve25519PublicKey::from(b"curvepubcurvepubcurvepubcurvepub".to_owned()),
&Ed25519SecretKey::from_slice(b"device12device12device12device12"),
KeyQueryResponseTemplateDeviceOptions::new().verified(true),
);
let response = template.build_response();
Implementations§
Source§impl KeyQueryResponseTemplate
impl KeyQueryResponseTemplate
Sourcepub fn new(user_id: OwnedUserId) -> Self
pub fn new(user_id: OwnedUserId) -> Self
Create a new KeyQueryResponseTemplate
for the given user.
Sourcepub fn with_cross_signing_keys(
self,
master_cross_signing_key: Ed25519SecretKey,
self_signing_key: Ed25519SecretKey,
user_signing_key: Ed25519SecretKey,
) -> Self
pub fn with_cross_signing_keys( self, master_cross_signing_key: Ed25519SecretKey, self_signing_key: Ed25519SecretKey, user_signing_key: Ed25519SecretKey, ) -> Self
Add a set of cross-signing keys to the data to be returned.
The private keys must be provided here so that signatures can be correctly calculated.
Sourcepub fn with_device(
self,
device_id: &DeviceId,
curve25519_public_key: &Curve25519PublicKey,
ed25519_secret_key: &Ed25519SecretKey,
options: KeyQueryResponseTemplateDeviceOptions,
) -> Self
pub fn with_device( self, device_id: &DeviceId, curve25519_public_key: &Curve25519PublicKey, ed25519_secret_key: &Ed25519SecretKey, options: KeyQueryResponseTemplateDeviceOptions, ) -> Self
Add a device to the data to be returned.
As well as a device ID and public Curve25519 device key, the private Ed25519 device key must be provided so that the signature can be calculated.
The device can optionally be signed by the self-signing key by calling
[KeyResponseTemplateDeviceOptions::verified(true)
] on the options
object.
Sourcepub fn with_user_verification_signature(
self,
signing_user_id: &UserId,
signing_user_user_signing_key: &Ed25519SecretKey,
) -> Self
pub fn with_user_verification_signature( self, signing_user_id: &UserId, signing_user_user_signing_key: &Ed25519SecretKey, ) -> Self
Add the signature from another user to our master key, as would happen if that user had verified us.
Sourcepub fn build_response(&self) -> KeyQueryResponse
pub fn build_response(&self) -> KeyQueryResponse
Build a /keys/query
response containing this user’s data.
Auto Trait Implementations§
impl Freeze for KeyQueryResponseTemplate
impl RefUnwindSafe for KeyQueryResponseTemplate
impl Send for KeyQueryResponseTemplate
impl Sync for KeyQueryResponseTemplate
impl Unpin for KeyQueryResponseTemplate
impl UnwindSafe for KeyQueryResponseTemplate
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
§impl<T> CompatExt for T
impl<T> CompatExt for T
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<>