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.3.0] - 2026-11-05
Added
JSON.Encoderimplementations (Elixir 1.18+) for the structs that implementJason.Encoder: V1Challenge,Payload,ServerSignaturePayload,ServerSignatureVerificationDataand V2ChallengeParameters,Challenge,Solution,Payload.- Public
to_map/1on the same structs, returning the wire format as plain maps for use with any JSON encoder. V2Payload.to_map/1converts the nested challenge and solution.
Changed
- Removed the undocumented
Altcha.V2.parameters_to_map/1; useAltcha.V2.ChallengeParameters.to_map/1.
Fixed
Jason.Encoderimplementations pass encoder options (e.g.escape:) through to nested values instead of ignoring them.
[2.2.0] - 2026-10-03
Changed
Altcha.V2.verify_solution/1andAltcha.V2.verify_server_signature/2raiseArgumentErrorwhen the HMAC secret isnilor"", like the JS reference (Web Crypto rejects zero-length HMAC keys). Previously""returnedinvalid_signature: trueandnilraised an unclear:cryptoerror.Altcha.Plug.ChallengeraisesArgumentErrorfor anilor empty:hmac_signature_secret: ininit/1for a string, and per request for a function or MFA tuple (e.g. an empty environment variable). Previously it served unsigned challenges that could never verify.Altcha.V2.create_challenge/1raisesArgumentErrorfor a non-hexkey_prefix, which previously produced a challenge no solver could match.
Fixed
Altcha.V2.verify_solution/1returnsinvalid_solution: trueinstead of raising when the client-submittedderivedKeyis not valid hex (non-hex characters, odd length) or is missing / not a string, on both the key-signature and re-derivation paths.key_prefixis always lowercase:Altcha.V2.create_challenge/1lowercases thekey_prefixoption, andsolve_challenge/1/verify_solution/1match 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/1expiry matches the JS reference: the challenge expires onceexpiresAtis earlier than the current time with fractional seconds (previously floored, granting up to 1 s of grace), andexpiresAt: 0means no expiry (previously treated as expired).Altcha.V2.verify_server_signature/2expiry matches the JS reference:expire=0means no expiry (previously treated as expired), and a decimalexpireis checked (previously ignored).- The canonical JSON signed by
Altcha.V2is 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\u00xxcontrol-character escapes. Previously a challenge whosedataheld a float such as1.0failedinvalid_signatureafter the widget re-serialized it, and JS-signed challenges with such data did not verify. Altcha.V2treats an empty-string secret orkeySignatureas unset, like the JS reference:create_challenge/1withhmac_signature_secret: ""returns an unsigned challenge,hmac_key_signature_secret: ""adds nokeySignature, andverify_solution/1re-derives the key when either is"". Previously""was used as an empty HMAC key.Altcha.V2.verify_solution/1andverify_server_signature/2no longer raise on malformed client input. A numericcounterfollows JS number semantics (a JSON7.0verifies like7; uint32 mode truncates and wraps modulo 2^32, likesetUint32), a non-numericcounterisinvalid_solution: true, and a non-string signature isinvalid_signature: true.Altcha.V2.create_challenge/1capskey_prefix_lengthat 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 raisedArgumentError.Altcha.V2.solve_challenge/1returnsnilfor a challenge whosekey_prefixis not hex, instead of raising (even length) or running until the timeout (odd length).Altcha.V2.solve_challenge/1treatstimeout: 0as no timeout, like the JS reference, and also acceptstimeout: :infinity. Previously0returnednilat once.Altcha.V2.verify_server_signature/2returns a failed result withnilverification data instead of raising when the client payload is missing, not JSON, not a JSON object, or has a missing / non-stringverificationData.Altcha.V2.decode_payload/1returnsnilfor a missing (nil) or non-string payload.Altcha.V2.verify_server_signature/2keeps averificationDatavalue 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— aPlugthat serves a freshly signed ALTCHA v2 proof-of-work challenge as JSON, so the widget'schallengeattribute can point straight at your app. Requires the new optional:plugdependency; nothing changes for non-Plug users.- A Phoenix integration guide covering widget loading, the
challenge endpoint, the LiveView
statechangehook, and solution verification.
[2.0.1] — 2026-07-30
Fixed
- Enforce
key_prefixin the proof-of-work fallback verification path.
[2.0.0] — 2026-04-07
Added
Altcha.V2— key-derivation-based challenges (PBKDF2, iterativeSHA) with tunable cost, for the ALTCHA widget v3.