Skip to content

added check to suppress unnecessary log warning#123

Closed
danwallach wants to merge 4 commits intomainfrom
fix/hashed_ballot_nonce_logging
Closed

added check to suppress unnecessary log warning#123
danwallach wants to merge 4 commits intomainfrom
fix/hashed_ballot_nonce_logging

Conversation

@danwallach
Copy link
Copy Markdown
Collaborator

@danwallach danwallach commented Jul 24, 2020

Issue

Fixes #122

Description

Makes the warning conditional on the instance type of the CiphertextBallot. If it's a CiphertextAcceptedBallot, then no warning is generated. Otherwise, behavior is identical.

(This patch is only relevant to the fix/deserialization-issues branch, where it's -3+4 lines. If you compare it to main, it's much bigger.)

Testing

In regular use, should have no effect on testing. But logs will be cleaner, easier to read.

Checklist

🚨Please review the guidelines for contributing to this repository.

  • 🤔 CONSIDER adding a unit test if your PR resolves an issue.
  • DO check open PR's to avoid duplicates.
  • DO keep pull requests small so they can be easily reviewed.
  • DO build locally before pushing.
  • DO make sure tests pass.
  • DO make sure any new changes are documented.
  • DO make sure not to introduce any compiler warnings.
  • AVOID breaking the continuous integration build.
  • AVOID making significant changes to the overall architecture.

💚Thank you!

keithrfung and others added 3 commits July 23, 2020 13:02
- Add make_ methods to reduce constructor issues - - Remove InitVar 
- Add deserialization for ElementModP and ElementModQ
Remove the camelcase (and accompanying snakecase) conversion due to issues with jsons library
Comment thread src/electionguard/ballot.py Outdated
log_warning(
f"missing nonce for ballot {self.object_id} could not derive from null nonce"
)
if not isinstance(self, CiphertextAcceptedBallot):
Copy link
Copy Markdown
Contributor

@AddressXception AddressXception Jul 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why dont we just get rid of the error message entirely? or change it to log_debug? i think that's preferable over checking the subclassed type, right?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with nuking this entirely. If you're going to keep any sort of logging here, it should only happen with dealing with CiphertextBallots in other states. A CiphertextAcceptedBallot will never have a nonce in it.

Base automatically changed from fix/deserialization-issues to main July 28, 2020 18:57
@danwallach
Copy link
Copy Markdown
Collaborator Author

So I had an a-ha moment. This particular method doesn't actually care if the nonce is absent. We're computing a hash value over various things. If the nonce isn't there, we can still compute a hash value. hash_elems doesn't care. The only issue is whether we want this particular hash value to be the same for a CiphertextBallot (with nonce) and an otherwise equal CiphertextAcceptedBallot (without nonce).

Anyway, I pushed a change that gets rid of the warning check altogether. I think this is fine.

@danwallach
Copy link
Copy Markdown
Collaborator Author

Food for thought: should the nonce actually be included in this particular computation? I don't know exactly where we're calling this method, but if we want the same result for a CiphertextBallot and its corresopnding CiphertextAcceptedBallot, then the nonce should not be included in what's being passed to hash_elems.

@danwallach danwallach closed this Aug 3, 2020
@keithrfung keithrfung mentioned this pull request Aug 5, 2020
9 tasks
@keithrfung keithrfung deleted the fix/hashed_ballot_nonce_logging branch August 5, 2020 20:14
@danwallach danwallach restored the fix/hashed_ballot_nonce_logging branch September 18, 2020 14:31
@keithrfung keithrfung deleted the fix/hashed_ballot_nonce_logging branch September 22, 2020 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unnecessary / incorrect log warning when serializing a CiphertextAcceptedBallot

3 participants