-
Notifications
You must be signed in to change notification settings - Fork 158
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
304 field agnostic fiat shamir challenge names #308
304 field agnostic fiat shamir challenge names #308
Conversation
…ic-fiat-shamir-challenge-names
@@ -124,14 +123,14 @@ func (d *digest) checksum() fr.Element { | |||
// Write guarantees len(data) % BlockSize == 0 | |||
|
|||
// TODO @ThomasPiellard shouldn't Sum() returns an error if there is no data? | |||
if len(d.data) == 0 { | |||
// TODO: @Tabaie, @Thomas Piellard Now sure what to make of this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 solutions I guess;
- since
checksum
is called inSum
andSum
can return an error, we could do that if there is no data to hash. - refer to other Hash impl in Go std and see how Sum behaves with empty buffer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Took a look at SHA256, turns out for conventional hashes hashing nothing makes sense, and provides a valid input. I think our choice is between returning 0 or throwing an error.
@@ -98,23 +98,22 @@ func (d *digest) BlockSize() int { | |||
// If len(p) is not a multiple of BlockSize and any of the []byte in p represent an integer | |||
// larger than fr.Modulus, this function returns an error. | |||
// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add in godoc a warning to say that this method may error (whereas Hash interface{} say it may not)
This PR proposes a solution to #304 by introducing an interface called
ArithmeticHash
with aWriteString
function that decomposes its message before writing it. Used for long fiatshamir challenge names and signatures.THE ABOVE IS OUTDATED: We decided on a more lightweight solution: the idea of keeping the hash interface but returning error on non-field-element input is held on to, but the decompose method is replaced with hashes to field.