Skip to content

Commit

Permalink
Merge branch 'Consensys:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
liuxiaobleach authored Jul 22, 2024
2 parents 4a33fcc + 02ff590 commit f1d3ae0
Show file tree
Hide file tree
Showing 82 changed files with 2,761 additions and 795 deletions.
11 changes: 11 additions & 0 deletions backend/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ type ProverConfig struct {
ChallengeHash hash.Hash
KZGFoldingHash hash.Hash
Accelerator string
StatisticalZK bool
}

// NewProverConfig returns a default ProverConfig with given prover options opts
Expand Down Expand Up @@ -133,6 +134,16 @@ func WithIcicleAcceleration() ProverOption {
}
}

// WithStatisticalZeroKnowledge ensures that statistical zero knowledgeness is achieved.
// This option makes the prover more memory costly, as there are 3 more size n (size of the circuit)
// allocations.
func WithStatisticalZeroKnowledge() ProverOption {
return func(pc *ProverConfig) error {
pc.StatisticalZK = true
return nil
}
}

// VerifierOption defines option for altering the behavior of the verifier. See
// the descriptions of functions returning instances of this type for
// implemented options.
Expand Down
2 changes: 1 addition & 1 deletion backend/groth16/bls12-377/verify.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion backend/groth16/bls12-381/verify.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion backend/groth16/bls24-315/verify.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion backend/groth16/bls24-317/verify.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 26 additions & 26 deletions backend/groth16/bn254/solidity.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,49 +75,49 @@ contract Verifier {
uint256 constant EXP_SQRT_FP = 0xC19139CB84C680A6E14116DA060561765E05AA45A1C72A34F082305B61F3F52; // (P + 1) / 4;
// Groth16 alpha point in G1
uint256 constant ALPHA_X = {{.Vk.G1.Alpha.X.String}};
uint256 constant ALPHA_Y = {{.Vk.G1.Alpha.Y.String}};
uint256 constant ALPHA_X = {{ (fpstr .Vk.G1.Alpha.X) }};
uint256 constant ALPHA_Y = {{ (fpstr .Vk.G1.Alpha.Y) }};
// Groth16 beta point in G2 in powers of i
uint256 constant BETA_NEG_X_0 = {{.Vk.G2.Beta.X.A0.String}};
uint256 constant BETA_NEG_X_1 = {{.Vk.G2.Beta.X.A1.String}};
uint256 constant BETA_NEG_Y_0 = {{.Vk.G2.Beta.Y.A0.String}};
uint256 constant BETA_NEG_Y_1 = {{.Vk.G2.Beta.Y.A1.String}};
uint256 constant BETA_NEG_X_0 = {{ (fpstr .Vk.G2.Beta.X.A0) }};
uint256 constant BETA_NEG_X_1 = {{ (fpstr .Vk.G2.Beta.X.A1) }};
uint256 constant BETA_NEG_Y_0 = {{ (fpstr .Vk.G2.Beta.Y.A0) }};
uint256 constant BETA_NEG_Y_1 = {{ (fpstr .Vk.G2.Beta.Y.A1) }};
// Groth16 gamma point in G2 in powers of i
uint256 constant GAMMA_NEG_X_0 = {{.Vk.G2.Gamma.X.A0.String}};
uint256 constant GAMMA_NEG_X_1 = {{.Vk.G2.Gamma.X.A1.String}};
uint256 constant GAMMA_NEG_Y_0 = {{.Vk.G2.Gamma.Y.A0.String}};
uint256 constant GAMMA_NEG_Y_1 = {{.Vk.G2.Gamma.Y.A1.String}};
uint256 constant GAMMA_NEG_X_0 = {{ (fpstr .Vk.G2.Gamma.X.A0) }};
uint256 constant GAMMA_NEG_X_1 = {{ (fpstr .Vk.G2.Gamma.X.A1) }};
uint256 constant GAMMA_NEG_Y_0 = {{ (fpstr .Vk.G2.Gamma.Y.A0) }};
uint256 constant GAMMA_NEG_Y_1 = {{ (fpstr .Vk.G2.Gamma.Y.A1) }};
// Groth16 delta point in G2 in powers of i
uint256 constant DELTA_NEG_X_0 = {{.Vk.G2.Delta.X.A0.String}};
uint256 constant DELTA_NEG_X_1 = {{.Vk.G2.Delta.X.A1.String}};
uint256 constant DELTA_NEG_Y_0 = {{.Vk.G2.Delta.Y.A0.String}};
uint256 constant DELTA_NEG_Y_1 = {{.Vk.G2.Delta.Y.A1.String}};
uint256 constant DELTA_NEG_X_0 = {{ (fpstr .Vk.G2.Delta.X.A0) }};
uint256 constant DELTA_NEG_X_1 = {{ (fpstr .Vk.G2.Delta.X.A1) }};
uint256 constant DELTA_NEG_Y_0 = {{ (fpstr .Vk.G2.Delta.Y.A0) }};
uint256 constant DELTA_NEG_Y_1 = {{ (fpstr .Vk.G2.Delta.Y.A1) }};
{{- if gt $numCommitments 0 }}
// Pedersen G point in G2 in powers of i
uint256 constant PEDERSEN_G_X_0 = {{.Vk.CommitmentKey.G.X.A0.String}};
uint256 constant PEDERSEN_G_X_1 = {{.Vk.CommitmentKey.G.X.A1.String}};
uint256 constant PEDERSEN_G_Y_0 = {{.Vk.CommitmentKey.G.Y.A0.String}};
uint256 constant PEDERSEN_G_Y_1 = {{.Vk.CommitmentKey.G.Y.A1.String}};
uint256 constant PEDERSEN_G_X_0 = {{ (fpstr .Vk.CommitmentKey.G.X.A0) }};
uint256 constant PEDERSEN_G_X_1 = {{ (fpstr .Vk.CommitmentKey.G.X.A1) }};
uint256 constant PEDERSEN_G_Y_0 = {{ (fpstr .Vk.CommitmentKey.G.Y.A0) }};
uint256 constant PEDERSEN_G_Y_1 = {{ (fpstr .Vk.CommitmentKey.G.Y.A1) }};
// Pedersen GRootSigmaNeg point in G2 in powers of i
uint256 constant PEDERSEN_GROOTSIGMANEG_X_0 = {{.Vk.CommitmentKey.GRootSigmaNeg.X.A0.String}};
uint256 constant PEDERSEN_GROOTSIGMANEG_X_1 = {{.Vk.CommitmentKey.GRootSigmaNeg.X.A1.String}};
uint256 constant PEDERSEN_GROOTSIGMANEG_Y_0 = {{.Vk.CommitmentKey.GRootSigmaNeg.Y.A0.String}};
uint256 constant PEDERSEN_GROOTSIGMANEG_Y_1 = {{.Vk.CommitmentKey.GRootSigmaNeg.Y.A1.String}};
uint256 constant PEDERSEN_GROOTSIGMANEG_X_0 = {{ (fpstr .Vk.CommitmentKey.GRootSigmaNeg.X.A0) }};
uint256 constant PEDERSEN_GROOTSIGMANEG_X_1 = {{ (fpstr .Vk.CommitmentKey.GRootSigmaNeg.X.A1) }};
uint256 constant PEDERSEN_GROOTSIGMANEG_Y_0 = {{ (fpstr .Vk.CommitmentKey.GRootSigmaNeg.Y.A0) }};
uint256 constant PEDERSEN_GROOTSIGMANEG_Y_1 = {{ (fpstr .Vk.CommitmentKey.GRootSigmaNeg.Y.A1) }};
{{- end }}
// Constant and public input points
{{- $k0 := index .Vk.G1.K 0}}
uint256 constant CONSTANT_X = {{$k0.X.String}};
uint256 constant CONSTANT_Y = {{$k0.Y.String}};
uint256 constant CONSTANT_X = {{ (fpstr $k0.X) }};
uint256 constant CONSTANT_Y = {{ (fpstr $k0.Y) }};
{{- range $i, $ki := .Vk.G1.K }}
{{- if gt $i 0 }}
uint256 constant PUB_{{sub $i 1}}_X = {{$ki.X.String}};
uint256 constant PUB_{{sub $i 1}}_Y = {{$ki.Y.String}};
uint256 constant PUB_{{sub $i 1}}_X = {{ (fpstr $ki.X) }};
uint256 constant PUB_{{sub $i 1}}_Y = {{ (fpstr $ki.Y) }};
{{- end }}
{{- end }}
Expand Down
9 changes: 8 additions & 1 deletion backend/groth16/bn254/verify.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion backend/groth16/bw6-633/verify.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion backend/groth16/bw6-761/verify.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions backend/groth16/groth16.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ type ProvingKey interface {
type VerifyingKey interface {
groth16Object
gnarkio.UnsafeReaderFrom
// VerifyingKey are the methods required for generating the Solidity
// verifier contract from the VerifyingKey. This will return an error if not
// supported on the CurveID().
solidity.VerifyingKey

// NbPublicWitness returns number of elements expected in the public witness
NbPublicWitness() int
Expand All @@ -104,10 +108,6 @@ type VerifyingKey interface {
// NbG2 returns the number of G2 elements in the VerifyingKey
NbG2() int

// ExportSolidity writes a solidity Verifier contract from the VerifyingKey
// this will return an error if not supported on the CurveID()
ExportSolidity(w io.Writer, exportOpts ...solidity.ExportOption) error

IsDifferent(interface{}) bool
}

Expand Down
Loading

0 comments on commit f1d3ae0

Please sign in to comment.