from __future__ import annotations
import enum
from typing import FrozenSet, List, Mapping, NamedTuple, Optional, TypeAlias, Union
__all__ = [
"Bundle",
"IdentityKeyFormat",
"Header",
"JSONType",
"JSONObject",
"SecretType"
]
################
# Type Aliases #
################
JSONType: TypeAlias = Union[Mapping[str, "JSONType"], List["JSONType"], str, int, float, bool, None]
JSONObject: TypeAlias = Mapping[str, "JSONType"]
############################
# Structures (NamedTuples) #
############################
[docs]
class Bundle(NamedTuple):
"""
The bundle is a collection of public keys and signatures used by the X3DH protocol to achieve asynchronous
key agreements while providing forward secrecy and cryptographic deniability. Parties that want to be
available for X3DH key agreements have to publish their bundle somehow. Other parties can then use that
bundle to perform a key agreement.
"""
identity_key: bytes
signed_pre_key: bytes
signed_pre_key_sig: bytes
pre_keys: FrozenSet[bytes]
################
# Enumerations #
################
[docs]
@enum.unique
class SecretType(enum.Enum):
"""
The two types of secrets that an :class:`~x3dh.identity_key_pair.IdentityKeyPair` can use internally: a
seed or a private key.
"""
SEED = "SEED"
PRIV = "PRIV"