fiatshamir

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 19, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Settings

type Settings struct {
	Transcript     *Transcript
	Prefix         string
	BaseChallenges []frontend.Variable
	Hash           hash.FieldHasher
}

func WithHash

func WithHash(hash hash.FieldHasher, baseChallenges ...frontend.Variable) Settings

func WithTranscript

func WithTranscript(transcript *Transcript, prefix string, baseChallenges ...frontend.Variable) Settings

type Transcript

type Transcript struct {
	// contains filtered or unexported fields
}

Transcript handles the creation of challenges for Fiat Shamir.

func NewTranscript

func NewTranscript(api frontend.API, h hash.FieldHasher, challengesID []string, opts ...TranscriptOption) *Transcript

NewTranscript returns a new transcript. h is the hash function that is used to compute the challenges. challenges are the name of the challenges. The order is important.

func (*Transcript) Bind

func (t *Transcript) Bind(challengeID string, values []frontend.Variable) error

Bind binds the challenge to value. A challenge can be binded to an arbitrary number of values, but the order in which the binded values are added is important. Once a challenge is computed, it cannot be binded to other values.

func (*Transcript) ComputeChallenge

func (t *Transcript) ComputeChallenge(challengeID string) (frontend.Variable, error)

ComputeChallenge computes the challenge corresponding to the given name. The resulting variable is:

  • H(name ∥ previous_challenge ∥ binded_values...) if the challenge is not the first one
  • H(name ∥ binded_values... ) if it's is the first challenge

type TranscriptOption

type TranscriptOption func(tc *transcriptConfig)

TranscriptOption allows modifying the Transcript operation.

func WithDomainSeparation

func WithDomainSeparation() TranscriptOption

WithDomainSeparation adds domain separation string `string:` as defined in RCF 9380. This mode of operation is beneficial when seeking for compatibility with native Transcript when initialized using gnark-crypto's MiMC implementation.

func WithTryBitmode

func WithTryBitmode(nbBits int) TranscriptOption

WithTryBitmode changes the Transcript to work on bits instead of field elements when writing input to the hasher. Requires that the hasher is also set to work in bitmode. This mode of operation is useful in cases where we work in mismatching fields and want to avoid overflows.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL