Repository navigation
v2.4.0
This release fixes several verification bugs, including two that could let VerifySolution accept solutions it never checked. All v2 users should upgrade. Versions v2.0.0–v2.3.0 are retracted.
Security fixes
VerifySolutionreturnedVerified: truewithout checking the solution whenDeriveKeywas not set and the key-signature check didn't apply. A validly signed challenge with anyderivedKeywas accepted.VerifySolutionskipped the signature check entirely whenHMACSignatureSecretwas empty, so unsigned or forged challenges (e.g. with an attacker-chosenkeyPrefixorcost) were accepted.CreateChallengewithCounterset but noDeriveKeyproduced a challenge with an emptykeyPrefix, which any counter solves.
Breaking changes
VerifySolutionrequiresHMACSignatureSecret. It returns an error if the secret is empty.VerifySolutionrequiresDeriveKeyunless the challenge has akeySignatureandHMACKeySignatureSecretis set. Otherwise it returns an error.CreateChallengereturns an error when:Counteris set withoutDeriveKey;KeyPrefixis not valid hex;CounterModeis unknown.
SolveChallengetimes out after 90 seconds by default and returnsnil, nil, the same as whenStopChanfires. SetTimeout: -1to restore unlimited solving.- Expiry is enforced exactly:
VerifySolutioncomparesexpiresAtwith sub-second precision; previously it allowed up to ~1 s past expiry.- Negative
expiresAtvalues now count as expired. VerifyServerSignaturelikewise treats a negativeexpireas expired.
KeyPrefixis lowercased before the challenge is signed. Prefix matching ignores case.- No
keySignatureon unsigned challenges. WhenCreateChallengegets noHMACSignatureSecret, it no longer adds akeySignature. - Zero-valued parameters are part of the signature.
memoryCost,parallelismandexpiresAtsent as0ornullare now included when the signature is checked, as in altcha-lib (JS). Adding such keys to a Go-signed challenge now makes verification fail; previously they were silently dropped. - Go 1.25 or newer is required (
go 1.25.0ingo.mod, as required bygolang.org/x/crypto).
Fixes
- Challenges created by altcha-lib (JS) with
memoryCost,parallelismorexpiresAtset to0ornullnow verify. - A malformed
solution.derivedKey(non-hex or odd length) on the key-signature path now givesInvalidSolution: trueinstead of an error, so a bad client payload no longer causes a server error. KeyPrefixLengthlarger than the derived key no longer panics. The prefix is capped at the full key.- Nonce and salt are now 16 random bytes, matching altcha-lib. Challenges issued with 12-byte values still verify.
New features
CounterModeoption onCreateChallengeOptions,SolveChallengeOptionsandVerifySolutionOptions:CounterModeUint32: the default, unchanged behaviour.CounterModeString: appends the counter as a decimal string; compatible with altcha-lib'scounterMode: 'string'.
Timeoutoption onSolveChallengeOptions: zero means the 90 s default; a negative value disables it.
Versioning
- v2 releases are now tagged
v2.x.y(previouslyv2/v2.x.y), sogo getand the Go module proxy can resolve them:
go get github.com/altcha-org/altcha-lib-go/v2@v2.4.0 - Plain tags added for v2.0.0–v2.3.0, and those versions are retracted because of the verification bypasses above.
go getwarns if you request one, and@latestwill not select them.
Upgrading
- Pass
HMACSignatureSecretto everyVerifySolutioncall. You should already be passing it; without it, older versions skipped the signature check. - Pass
DeriveKeytoVerifySolutionunless every challenge uses the key-signature check. - Handle errors from
VerifySolutionas server errors. TreatVerified: falseas a rejected submission. - If you call
SolveChallengeon challenges that may take longer than 90 s, setTimeout(or-1). - If you use
CounterinCreateChallenge, make sureDeriveKeyis set. - Set
ExpiresAton your challenges if you don't already; the example server now does (10 minutes).