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

Feat/fiat shamir #42

Merged
merged 8 commits into from
Apr 23, 2021
Merged

Feat/fiat shamir #42

merged 8 commits into from
Apr 23, 2021

Conversation

ThomasPiellard
Copy link
Contributor

This PR adds a transcript object to apply Fiat Shamir transform.

API breaking change

Addition of method Bytes() []byte on Digest struct:

type Digest interface {
	io.WriterTo
	io.ReaderFrom
	Bytes() []byte
}

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.

@CLAassistant
Copy link

CLAassistant commented Apr 21, 2021

CLA assistant check
All committers have signed the CLA.

return fs
}

func eq(a, b []byte) bool {
Copy link
Collaborator

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

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?

Copy link
Contributor Author

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 {

Copy link
Collaborator

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 Show resolved Hide resolved
}

// write the binded values in the order they were added
m.h.Write(m.bindings[challengeNumber])
Copy link
Collaborator

Choose a reason for hiding this comment

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

handle returned error

@gbotrel gbotrel merged commit 01dadd0 into develop Apr 23, 2021
@gbotrel gbotrel deleted the feat/fiat_shamir branch April 23, 2021 20:19
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.

None yet

3 participants