"""Mesh — gossip / membership layer for federated aborist trees.

Off by default. Loaded only when the user explicitly opts in via
`aborist mesh init` (creates this peer's identity) and
`aborist mesh enable` (flips the gating flag in the meta table).

The cryptographic substrate:
    - Ed25519 (signing)  — every gossip message and every membership
      mutation event is signed by the sender's pubkey.
    - X25519 (ECDH)      — used to wrap each epoch's symmetric mesh
      secret to every current member's DH pubkey, so the new secret
      is reconstructible only by the post-rotation roster.

Membership state is per-epoch:
    epoch 0 = group genesis  (just the founder)
    epoch N = the N-th roster mutation (add member, kick, scheduled rotate)

Eviction is a rotate where the kicked member's pubkey isn't in the
new envelope. Their previously-signed events stay verifiable forever
(historical roster preserved in mesh_roster), but they no longer have
the new secret, so any AEAD-protected gossip for epoch N+1 is opaque
to them.

This module deliberately avoids networking. The wire layer (HTTP/TLS
gossip server + sync client) lives in `aborist.mesh.wire` and is also
opt-in.
"""

from aborist.mesh.crypto import (
    aead_decrypt,
    aead_encrypt,
    ecdh_shared_secret,
    generate_dh_keypair,
    generate_signing_keypair,
    sign,
    verify,
)
from aborist.mesh.state import (
    MESH_ENABLED_KEY,
    MeshIdentity,
    MeshRosterEntry,
    current_epoch,
    init_identity,
    is_enabled,
    load_identity,
    set_enabled,
)

__all__ = [
    "MESH_ENABLED_KEY",
    "MeshIdentity",
    "MeshRosterEntry",
    "aead_decrypt",
    "aead_encrypt",
    "current_epoch",
    "ecdh_shared_secret",
    "generate_dh_keypair",
    "generate_signing_keypair",
    "init_identity",
    "is_enabled",
    "load_identity",
    "set_enabled",
    "sign",
    "verify",
]
