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

304 field agnostic fiat shamir challenge names #308

Merged
merged 34 commits into from
Feb 10, 2023

Conversation

Tabaie
Copy link
Contributor

@Tabaie Tabaie commented Jan 16, 2023

This PR proposes a solution to #304 by introducing an interface called ArithmeticHash with a WriteString 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.

@Tabaie Tabaie linked an issue Jan 16, 2023 that may be closed by this pull request
@gbotrel gbotrel changed the base branch from master to develop January 19, 2023 20:12
@@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

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

2 solutions I guess;

  1. since checksum is called in Sum and Sum can return an error, we could do that if there is no data to hash.
  2. refer to other Hash impl in Go std and see how Sum behaves with empty buffer.

Copy link
Contributor Author

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.
//
Copy link
Collaborator

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)

hash/to_field.go Outdated Show resolved Hide resolved
@Tabaie Tabaie merged commit a3a667b into develop Feb 10, 2023
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.

Field-agnostic Fiat-Shamir Challenge Names
2 participants