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/3rejects expired challenges. The expiry check computedfalsefor an expired challenge but did not return it, so any solved V1 challenge verified after itsexpires, and could be replayed indefinitely unless used challenges were tracked.- V1
Payload.from_json/1,ServerSignaturePayload.from_json/1andServerSignatureVerificationData.from_json/1no longer create atoms from JSON keys, andalgorithm_from_binary/1no 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 toverify_solution/3orverify_server_signature/2. Unknown keys are ignored, and unknown algorithm names are returned unchanged as strings.
Fixed
Altcha.V1.verify_solution/3verifies a challenge whose salt has a query but noexpires, such as one created withparamsand withoutexpires. Before, it always returnedfalse. A presentexpiresthat is not a number is still rejected.ServerSignatureVerificationData.from_json/1, and soverify_server_signature/2, fill indetected_languageandip_addressfromdetectedLanguageandipAddress. They were alwaysnilbefore.ServerSignatureVerificationData.from_json/1, and soverify_server_signature/2, parsescoreas a float, as the other ALTCHA libraries do. Before, a fractional score such as0.5raisedArgumentError, and an integer score was returned as an integer.Altcha.V1.verify_server_signature/2returns{false, nil}for a malformed payload: invalid base64 or JSON, JSON that is not an object, a missingalgorithm, or anexpire,timeorscorethat is not a number. Before, it raised.verify_solution/3returnsfalsefor JSON that is not an object; before, it raisedProtocol.UndefinedError. The V1from_json/1functions raiseArgumentErrorfor JSON that is not an object.
[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.