/**
 * §4.4 E2E crypto — FROZEN SIGNATURES ONLY. The AEAD/ECDH/HKDF implementations live in P4
 * `relay-e2e/` (which re-exports these exact signatures); relay-contracts owns the SHAPE so
 * P2/P4/P6 type-check against one surface. Calling any of these from relay-contracts throws.
 *
 * Per PLAN_RELAY_INDEX §2.1: "Crypto implementations of the §4.4 functions live in P4's
 * relay-e2e/ … relay-contracts owns the shapes."
 */
import { NotImplementedInContractsError } from '../errors.js'
import type {
  AeadKey,
  AuthorizedDeviceContext,
  AeadAlg,
  ClientHandshake,
  E2EEnvelope,
  E2ESession,
  HandshakeResult,
  ReplayKeyParams,
  SessionRole,
} from './types.js'

const OWNER = 'P4 relay-e2e'

/** SYNCHRONOUS AEAD seal — aad = directionLabel‖seq (§4.4). Impl: P4. */
export function sealFrame(_key: AeadKey, _seq: bigint, _plaintext: Uint8Array): E2EEnvelope {
  throw new NotImplementedInContractsError('sealFrame', OWNER)
}

/** SYNCHRONOUS AEAD open — verifies tag + seq, returns plaintext (§4.4). Impl: P4. */
export function openFrame(_key: AeadKey, _env: E2EEnvelope, _expectedSeq: bigint): Uint8Array {
  throw new NotImplementedInContractsError('openFrame', OWNER)
}

/** Build a stateful directional session from a handshake result (§4.4). Impl: P4. */
export function createE2ESession(_role: SessionRole, _result: HandshakeResult): E2ESession {
  throw new NotImplementedInContractsError('createE2ESession', OWNER)
}

/** Client-side handshake factory P6 calls (§4.4). Impl: P4. */
export function buildClientHandshake(
  _ctx: AuthorizedDeviceContext,
  _hostId: string,
  _aeadOffer: readonly AeadAlg[],
): ClientHandshake {
  throw new NotImplementedInContractsError('buildClientHandshake', OWNER)
}

/** FIX 3 recoverable replay content-key: HKDF(hostContentSecret, salt=sessionId, REPLAY_KDF_INFO). Impl: P4. */
export function deriveContentKey(_p: ReplayKeyParams): AeadKey {
  throw new NotImplementedInContractsError('deriveContentKey', OWNER)
}

/** FIX 3 agent seals replay-bound output under K_content (§4.4, P2 uses). Impl: P4. */
export function sealReplayFrame(_k: AeadKey, _seq: bigint, _plaintext: Uint8Array): E2EEnvelope {
  throw new NotImplementedInContractsError('sealReplayFrame', OWNER)
}

/** FIX 3 browser client-side replay/preview decrypt under K_content (§4.4, P6 uses). Impl: P4. */
export function openReplayCiphertext(_k: AeadKey, _dataPayload: Uint8Array): Uint8Array {
  throw new NotImplementedInContractsError('openReplayCiphertext', OWNER)
}
