Noise.Crypto.DH behaviour (Noise Protocol v0.3.0)

View Source

Behaviour for Diffie-Hellman functions (spec §4.1).

dh/2 returns {:error, :invalid_public_key} for a remote public key that the underlying library rejects (wrong encoding, point not on the curve, or a low-order point producing an all-zero shared secret). Signalling this as an error is explicitly permitted by spec §12.1/§12.2.

Summary

Types

keypair()

@type keypair() :: {seckey(), pubkey()}

pubkey()

@type pubkey() :: binary()

seckey()

@type seckey() :: binary()

shared_secret()

@type shared_secret() :: binary()

Callbacks

dh(keypair, pubkey)

@callback dh(keypair(), pubkey()) ::
  {:ok, shared_secret()} | {:error, :invalid_public_key}

dhlen()

@callback dhlen() :: pos_integer()

generate_keypair()

@callback generate_keypair() :: keypair()