Packages

WhatsApp Web API client for Elixir. Full-featured port of Baileys with end-to-end Signal Protocol encryption, multi-device support, groups, communities, media, newsletters, and native BEAM fault tolerance.

Current section

Files

Jump to
baileys_ex lib baileys_ex native xeddsa.ex
Raw

lib/baileys_ex/native/xeddsa.ex

defmodule BaileysEx.Native.XEdDSA do
@moduledoc """
XEdDSA signing/verification via curve25519-dalek NIF.
Required for WhatsApp wire compatibility: identity keys are Curve25519
(Montgomery form) but must produce Ed25519-compatible signatures for
signed pre-keys and sender key messages.
"""
alias BaileysEx.Native
@doc "Signs a message using the XEdDSA signature scheme."
@spec sign(binary(), binary()) :: {:ok, binary()}
def sign(private_key, message), do: {:ok, Native.xeddsa_sign(private_key, message)}
@doc "Verifies an XEdDSA signature over a given message."
@spec verify(binary(), binary(), binary()) :: boolean()
def verify(public_key, message, signature),
do: Native.xeddsa_verify(public_key, message, signature)
end