A Plug for integrating Snarkey ZKP authentication into Plug-based apps.
Usage
plug Snarkey.Plug,
param_key: "proof",
lookup: &MyApp.Accounts.get_by_blind_id/1,
fallback_handler: {MyApp.FallbackController, :challenge}Expects proof params under conn.body_params[param_key] containing "r", "s",
and optionally "timestamp". The :lookup function receives blind_identifier
and must return %{public_y: binary()} or nil.
Proof values ("r", "s", "timestamp") are expected as decimal strings and
are converted to raw binary-encoded integers before calling Snarkey.authenticate/3.
On success, assigns :snarkey_auth => {:ok, :authenticated} to conn.assigns.
On fallback, invokes the fallback handler with conn and the challenge, or
assigns :snarkey_auth => {:fallback, challenge} if no handler is configured.
On error, returns a 401 response.