Closed arolle closed 1 year ago
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.
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
.
That is helpful. I can make the changes in the master
soon.
enc_vote = ByteTree([ByteTree(first), ByteTree(second)]).to_byte_array()
This should happen on the client side.
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
andsignature
. The suggestion is to change the content of thesignature
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.