Skip to content

Feat/fiat shamir#42

Merged
gbotrel merged 8 commits intodevelopfrom
feat/fiat_shamir
Apr 23, 2021
Merged

Feat/fiat shamir#42
gbotrel merged 8 commits intodevelopfrom
feat/fiat_shamir

Conversation

@ThomasPiellard
Copy link
Copy Markdown
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
Copy Markdown

CLAassistant commented Apr 21, 2021

CLA assistant check
All committers have signed the CLA.

return fs
}

func eq(a, b []byte) bool {
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

}

// write the binded values in the order they were added
m.h.Write(m.bindings[challengeNumber])
Copy link
Copy Markdown
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.

3 participants