Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust format of encrypted vote #42

Closed
arolle opened this issue Feb 3, 2023 · 4 comments · Fixed by #44 or #49
Closed

Adjust format of encrypted vote #42

arolle opened this issue Feb 3, 2023 · 4 comments · Fixed by #44 or #49

Comments

@arolle
Copy link
Collaborator

arolle commented Feb 3, 2023

The verified and unverified back-ends need to accept vote submissions in the same format. A submission from the client is a json object with the keys vote and signature.
The suggestion is to change the content of the signature field and the signed content to be based on the (binary) verificatum byte tree representation of the encrypted vote.
This representation is more compact (than its current json serialisation) and independent of any other than the Javascript byte tree implementation.

The hash that is signed should be the hash of the of the binary byte tree.
The vote field should contain a base64 encoding of the binary byte tree.

@algomaster99
Copy link
Collaborator

Currently, the encoded vote is printed as JSON and then hashed which might be inconsistent because the first step could introduce formatting information and that would interfere with hashing. It is more desirable to directly hash the byte tree.

@arolle
Copy link
Collaborator Author

arolle commented Feb 6, 2023

Here is some python code, that would print the suggested value, where first and second are the current first/second components of the json object currently in vote.

print("encrypted vote binary:")
enc_vote = ByteTree([ByteTree(first), ByteTree(second)]).to_byte_array()
pprint(enc_vote)

print("hash to sign:")
vote_hash = sha256(enc_vote).hexdigest()
print(vote_hash)

print("encrypted vote to submit:")
print(base64.b64encode(enc_vote).decode("ascii"))

Once received on the back-end, after base64 decoding the byte tree would have to be destructed to get back first and second.

@algomaster99
Copy link
Collaborator

That is helpful. I can make the changes in the master soon.

@algomaster99
Copy link
Collaborator

 enc_vote = ByteTree([ByteTree(first), ByteTree(second)]).to_byte_array()

This should happen on the client side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants