Skip to content

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

// 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.

//
// 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)

@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

3 participants