fix(crypto): implement crypto primitives, hex wire format, and full test suite - #48
Merged
Just-Bamford merged 2 commits intoJul 29, 2026
Merged
Conversation
…est suite (AnonVote#39) - Add DECISIONS.md documenting ADR-001: hex output format for encryptVote - Implement encryptVote returning EncryptedPayload object with hex-encoded ciphertext, iv, and authTag (fixes base64/hex mismatch with AnonVote/core) - Implement decryptVote accepting EncryptedPayload; auth tag failure throws AnonVoteCryptoError(DECRYPTION_FAILED) — never swallowed silently - Validate key as exactly 64 hex chars; throw AnonVoteCryptoError(INVALID_KEY) before any cipher op - Validate payload fields in decryptVote; throw INVALID_PAYLOAD if missing/empty - hashIdentifier: trim + lowercase normalisation enforced - generateToken: 32-byte CSPRNG, hex output, JSDoc @warning against reuse - hashToken: separate export from hashIdentifier for independent testability - Add EncryptedPayload, Token, Vote, ElectionResult, BallotEvent interfaces and AnonVoteCryptoError class to src/types.ts - Export all canonical types and AnonVoteCryptoError from src/index.ts - Rewrite tests/crypto.test.ts with all 25 cases per issue spec - Update src/client.ts and tests/client.test.ts to use new EncryptedPayload object (serialised as JSON string in VoteReceipt.encryptedPayload) - All 73 tests pass; clean tsc build with no errors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #39