1#![doc = "Owner-bound HNS Chat identity and opaque HIP-78 mailbox values."]
2
3mod binding;
4mod owner;
5mod wire;
6
7pub use binding::{
8 ChatIdentityBindingV1, ChatKeyMode, encode_chat_binding, parse_chat_binding,
9 select_chat_binding, select_chat_binding_from_resource,
10};
11pub use owner::{
12 ChatIdentityTrust, VerifiedOwnerBindingV1, owner_authority_record,
13 resolve_compressed_owner_key, verify_current_owner_binding, xonly_from_compressed_public_key,
14};
15pub use wire::{
16 ChatAcknowledgementV1, ChatEnvelopeV1, HNS_CHAT_WIRE_VERSION, MAX_CHAT_ACKNOWLEDGEMENT_SIZE,
17 MAX_CHAT_ACKNOWLEDGEMENT_WIRE_SIZE, MAX_CHAT_CIPHERTEXT_SIZE, MAX_CHAT_ENVELOPE_SIZE,
18 MAX_CHAT_EXPIRATION_WINDOW, validate_unique_message_ids,
19};
20
21use hns_encoding::DecodeError;
22use thiserror::Error;
23
24pub const HNS_CHAT_PROFILE_NAME: &str = "hns.chat";
26pub const HNS_CHAT_SERVICE_NAME: &str = "chat";
28pub const HNS_CHAT_PROFILE_V1: u16 = 3;
30
31#[derive(Clone, Debug, Eq, Error, PartialEq)]
32pub enum ChatProtocolError {
33 #[error(transparent)]
34 Decode(#[from] DecodeError),
35 #[error("invalid HNS Chat value: {0}")]
36 Invalid(&'static str),
37 #[error("HNS Chat value is {actual} bytes; maximum is {maximum}")]
38 TooLarge { actual: usize, maximum: usize },
39 #[error("hnschat resource binding is missing")]
40 MissingBinding,
41 #[error("multiple hnschat resource bindings are ambiguous")]
42 AmbiguousBinding,
43 #[error("current owner output is not a supported version-0 single-key program")]
44 UnsupportedOwnerScript,
45 #[error("hnschat x-only key does not control the current owner output")]
46 StaleOwner,
47 #[error("both x-only public-key parities match the current owner output")]
48 AmbiguousOwnerKey,
49 #[error("duplicate HNS Chat message identifier")]
50 DuplicateMessageId,
51}