pub struct AuthMessage {
pub version: String,
pub message_type: MessageType,
pub identity_key: PublicKey,
pub nonce: Option<String>,
pub initial_nonce: Option<String>,
pub your_nonce: Option<String>,
pub certificates: Option<Vec<VerifiableCertificate>>,
pub requested_certificates: Option<RequestedCertificateSet>,
pub payload: Option<Vec<u8>>,
pub signature: Option<Vec<u8>>,
}Expand description
Authentication message structure (BRC-31).
This structure represents all message types in the authentication protocol. Different fields are used depending on the message type.
Fields§
§version: StringProtocol version (e.g., “0.1”).
message_type: MessageTypeType of message.
identity_key: PublicKeySender’s identity key (33-byte compressed public key).
nonce: Option<String>Sender’s nonce for this message (base64, 32 bytes: 16 random + 16 HMAC).
initial_nonce: Option<String>Session nonce from initial handshake (for InitialResponse).
your_nonce: Option<String>Recipient’s nonce from previous message.
certificates: Option<Vec<VerifiableCertificate>>Attached certificates (for CertificateResponse).
requested_certificates: Option<RequestedCertificateSet>Requested certificate specifications (for InitialRequest, CertificateRequest).
payload: Option<Vec<u8>>Message payload (for General messages).
signature: Option<Vec<u8>>DER-encoded signature over message contents.
Implementations§
Source§impl AuthMessage
impl AuthMessage
Sourcepub fn new(message_type: MessageType, identity_key: PublicKey) -> Self
pub fn new(message_type: MessageType, identity_key: PublicKey) -> Self
Creates a new message with required fields.
Sourcepub fn signing_data(&self) -> Vec<u8> ⓘ
pub fn signing_data(&self) -> Vec<u8> ⓘ
Returns the bytes to sign for this message.
The signing data varies by message type:
- InitialResponse: yourNonce || initialNonce (initiator’s nonce || responder’s session nonce, decoded from base64)
- General/CertificateRequest/CertificateResponse: payload or serialized requested_certificates
Sourcepub fn get_key_id(&self, peer_session_nonce: Option<&str>) -> String
pub fn get_key_id(&self, peer_session_nonce: Option<&str>) -> String
Returns the key ID to use for signing/verification.
Format: “{nonce} {peer_nonce}” for most messages.