Skip to content

encryptVote and decryptVote are not tested as a matched pair #18

Description

@grantfox-oss

PR #11 adds implementations for encryptVote and
decryptVote but the test file has no roundtrip test
confirming that decryptVote correctly recovers what
encryptVote produced. The tests cover each function
in isolation but a broken IV handling or mismatched
authTag format between the two functions would pass
all existing tests and only fail at runtime when
core attempts to tally votes.

There is also no test confirming decryptVote throws
on a tampered ciphertext or auth tag. Silent wrong
output from decryptVote during a tally produces a
corrupted result with no error raised.

Scope:

  • Add a roundtrip test — encryptVote then decryptVote
    returns the original option string exactly
  • Add a tampered ciphertext test — modify one byte
    of the ciphertext and confirm decryptVote throws
  • Add a tampered authTag test — modify the authTag
    and confirm decryptVote throws
  • Add an IV uniqueness test — two calls to encryptVote
    with the same input produce different ciphertexts
  • Confirm all four tests pass against the current
    implementation in PR feat: align crypto primitives with @anonvote/crypto type spec #11 before it is merged

Acceptance Criteria:

  • Roundtrip test passes
  • Tampered ciphertext causes decryptVote to throw
  • Tampered authTag causes decryptVote to throw
  • Two encryptVote calls with the same input
    produce different ciphertexts
  • All four tests added to tests/crypto.test.ts
  • All tests pass against the PR feat: align crypto primitives with @anonvote/crypto type spec #11 implementation

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignCampaign: Official CampaignbugSomething isn't working

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions