pub enum RootKey {
Phrase([u8; 32]),
SecurityKey {
public_key: [u8; 65],
credential_id: Vec<u8>,
},
}Expand description
A key that may act for an identity.
Variants§
Phrase([u8; 32])
An Ed25519 key derived from a recovery phrase.
SecurityKey
A FIDO2 security key’s credential: its P-256 public key (SEC1
uncompressed) and its credential id, at most
MAX_CREDENTIAL_ID bytes.
Implementations§
Source§impl RootKey
impl RootKey
Sourcepub fn phrase_of(user: &PortableUserId) -> Self
pub fn phrase_of(user: &PortableUserId) -> Self
The phrase root of a phrase identity: the Ed25519 key its id is.
Sourcepub fn bytes(&self) -> Vec<u8> ⓘ
pub fn bytes(&self) -> Vec<u8> ⓘ
How a root is laid out in what roots sign: 01 ‖ key (32) for a
phrase root; 02 ‖ public key (65) ‖ id length (u8) ‖ id for a
security key. Each layout says its own length.
Sourcepub fn is_valid(&self) -> bool
pub fn is_valid(&self) -> bool
Whether it is a key a root could be: an Ed25519 point, or a P-256
point with a credential id within MAX_CREDENTIAL_ID.
Sourcepub fn verify(&self, message: &[u8], signature: &RootSignature) -> bool
pub fn verify(&self, message: &[u8], signature: &RootSignature) -> bool
Whether signature is this root’s over message: a strict
Ed25519 signature from a phrase root; a CTAP2 assertion from a
security key, under PORTABLE_RP, with the user present and
verified, over authenticatorData ‖ SHA-256(message); or the same
key’s WebAuthn assertion whose challenge is SHA-256(message)
(RootSignature::WebAuthn). The
signature counter is not looked at: a key may report 0, and a
cloned key is not what this guards against.
Sourcepub fn fingerprint(&self) -> String
pub fn fingerprint(&self) -> String
The short code a person compares between screens, in an
identity’s format (crate::fingerprint): of the phrase root’s
key, or of the BLAKE3 of a security key’s Self::bytes.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for RootKey
impl<'de> Deserialize<'de> for RootKey
Source§fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>
Sizes are checked here; whether the keys are points is
RootKey::is_valid’s, asked wherever a root is taken in.