-
Notifications
You must be signed in to change notification settings - Fork 192
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
Feat/fiat shamir #42
Feat/fiat shamir #42
Conversation
fiat-shamir/transcript_test.go
Outdated
return fs | ||
} | ||
|
||
func eq(a, b []byte) bool { |
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.
use bytes.Equal(...)
here
@@ -32,6 +32,7 @@ type Polynomial interface { | |||
type Digest interface { | |||
io.WriterTo |
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.
are these two interfaces used? (io.WriterTo, io.ReaderFrom) on Digest?
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.
Currently there are not used, but they will be eventually (the commitments need to be passed to the rollup operator/blockchain at some point).
// are added is important. Once a challenge is computed, it cannot be | ||
// binded to other values. | ||
func (m *Transcript) Bind(challenge string, value []byte) 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.
cleaner to deal with error first ("idiomatic go"):
challengeNumber, ok := m.challengeOrder[challenge]
if !ok {
return err
}
// deal with nominal case. Same remark in ComputeChallenge
fiat-shamir/transcript.go
Outdated
} | ||
|
||
// write the binded values in the order they were added | ||
m.h.Write(m.bindings[challengeNumber]) |
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.
handle returned error
This PR adds a transcript object to apply Fiat Shamir transform.
API breaking change
Addition of method
Bytes() []byte
on Digest struct:Transcript
To apply Fiat Shamir one needs to create a transcript while providing the hash function used for challenges derivation as well as a list of names for the challenges. No challenges can be added afterwards:
func NewTranscript(h HashFS, challenges ...string) Transcript
Transcript object offers the following API:
(m *Transcript) Bind(challenge string, value []byte) error
: binds a challenge (referred to by its name) to a value. An error is returned when the challenge has already been computed or if the name is not recorded(m *Transcript) ComputeChallenge(challenge string) ([]byte, error)
: computes the challenge linked to the name. It returns an error if the previous challenge (in the order defined during the Transcript creation) is not computed.