All notable changes to this project are documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

[2.4.0] - 2026-11-21

Security

  • Altcha.V1.verify_solution/3 rejects expired challenges. The expiry check computed false for an expired challenge but did not return it, so any solved V1 challenge verified after its expires, and could be replayed indefinitely unless used challenges were tracked.
  • V1 Payload.from_json/1, ServerSignaturePayload.from_json/1 and ServerSignatureVerificationData.from_json/1 no longer create atoms from JSON keys, and algorithm_from_binary/1 no longer creates atoms from unknown algorithm names. Atoms are never garbage-collected, so a client could exhaust the atom table and crash the VM by sending payloads with many distinct keys to verify_solution/3 or verify_server_signature/2. Unknown keys are ignored, and unknown algorithm names are returned unchanged as strings.

Fixed

  • Altcha.V1.verify_solution/3 verifies a challenge whose salt has a query but no expires, such as one created with params and without expires. Before, it always returned false. A present expires that is not a number is still rejected.
  • ServerSignatureVerificationData.from_json/1, and so verify_server_signature/2, fill in detected_language and ip_address from detectedLanguage and ipAddress. They were always nil before.
  • ServerSignatureVerificationData.from_json/1, and so verify_server_signature/2, parse score as a float, as the other ALTCHA libraries do. Before, a fractional score such as 0.5 raised ArgumentError, and an integer score was returned as an integer.
  • Altcha.V1.verify_server_signature/2 returns {false, nil} for a malformed payload: invalid base64 or JSON, JSON that is not an object, a missing algorithm, or an expire, time or score that is not a number. Before, it raised. verify_solution/3 returns false for JSON that is not an object; before, it raised Protocol.UndefinedError. The V1 from_json/1 functions raise ArgumentError for JSON that is not an object.

[2.3.0] - 2026-11-05

Added

  • JSON.Encoder implementations (Elixir 1.18+) for the structs that implement Jason.Encoder: V1 Challenge, Payload, ServerSignaturePayload, ServerSignatureVerificationData and V2 ChallengeParameters, Challenge, Solution, Payload.
  • Public to_map/1 on the same structs, returning the wire format as plain maps for use with any JSON encoder. V2 Payload.to_map/1 converts the nested challenge and solution.

Changed

Fixed

  • Jason.Encoder implementations pass encoder options (e.g. escape:) through to nested values instead of ignoring them.

[2.2.0] - 2026-10-03

Changed

Fixed

  • Altcha.V2.verify_solution/1 returns invalid_solution: true instead of raising when the client-submitted derivedKey is not valid hex (non-hex characters, odd length) or is missing / not a string, on both the key-signature and re-derivation paths.
  • key_prefix is always lowercase: Altcha.V2.create_challenge/1 lowercases the key_prefix option, and solve_challenge/1 / verify_solution/1 match a signed prefix case-insensitively, for even and odd lengths alike. Previously verify compared even-length prefixes case-sensitively, so an uppercase prefix such as "0A" rejected the solver's own solution.
  • Altcha.V2.verify_solution/1 expiry matches the JS reference: the challenge expires once expiresAt is earlier than the current time with fractional seconds (previously floored, granting up to 1 s of grace), and expiresAt: 0 means no expiry (previously treated as expired).
  • Altcha.V2.verify_server_signature/2 expiry matches the JS reference: expire=0 means no expiry (previously treated as expired), and a decimal expire is checked (previously ignored).
  • The canonical JSON signed by Altcha.V2 is byte-identical to the JS reference (JSON.stringify(sortKeys(parameters))): JS number formatting (1.0 → 1, 1e21 → 1e+21, integers beyond 2^53 rounded to the nearest double), array-index keys ("9", "10") first in numeric order followed by UTF-16 key order, and lowercase \u00xx control-character escapes. Previously a challenge whose data held a float such as 1.0 failed invalid_signature after the widget re-serialized it, and JS-signed challenges with such data did not verify.
  • Altcha.V2 treats an empty-string secret or keySignature as unset, like the JS reference: create_challenge/1 with hmac_signature_secret: "" returns an unsigned challenge, hmac_key_signature_secret: "" adds no keySignature, and verify_solution/1 re-derives the key when either is "". Previously "" was used as an empty HMAC key.
  • Altcha.V2.verify_solution/1 and verify_server_signature/2 no longer raise on malformed client input. A numeric counter follows JS number semantics (a JSON 7.0 verifies like 7; uint32 mode truncates and wraps modulo 2^32, like setUint32), a non-numeric counter is invalid_solution: true, and a non-string signature is invalid_signature: true.
  • Altcha.V2.create_challenge/1 caps key_prefix_length at half the key length (key_length / 2, also the default), so the deterministic prefix never reveals more than half the key. Previously a larger value raised ArgumentError.
  • Altcha.V2.solve_challenge/1 returns nil for a challenge whose key_prefix is not hex, instead of raising (even length) or running until the timeout (odd length).
  • Altcha.V2.solve_challenge/1 treats timeout: 0 as no timeout, like the JS reference, and also accepts timeout: :infinity. Previously 0 returned nil at once.
  • Altcha.V2.verify_server_signature/2 returns a failed result with nil verification data instead of raising when the client payload is missing, not JSON, not a JSON object, or has a missing / non-string verificationData. Altcha.V2.decode_payload/1 returns nil for a missing (nil) or non-string payload.
  • Altcha.V2.verify_server_signature/2 keeps a verificationData value with a trailing newline (e.g. "5\n") as a string, like the JS reference. Previously it was mistaken for a number, and the failed conversion discarded all verification data, so a valid payload did not verify.

[2.1.0] - 2026-08-26

Added

  • Altcha.Plug.Challenge — a Plug that serves a freshly signed ALTCHA v2 proof-of-work challenge as JSON, so the widget's challenge attribute can point straight at your app. Requires the new optional :plug dependency; nothing changes for non-Plug users.
  • A Phoenix integration guide covering widget loading, the challenge endpoint, the LiveView statechange hook, and solution verification.

[2.0.1] — 2026-07-30

Fixed

  • Enforce key_prefix in the proof-of-work fallback verification path.

[2.0.0] — 2026-04-07

Added

  • Altcha.V2 — key-derivation-based challenges (PBKDF2, iterative SHA) with tunable cost, for the ALTCHA widget v3.

Changed