Skip to content

Commit

Permalink
add test and rm required command line for g2
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubuntu committed Feb 6, 2024
1 parent 340cae9 commit 1ddaba1
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion core/encoding/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func CLIFlags(envPrefix string) []cli.Flag {
cli.StringFlag{
Name: G2PathFlagName,
Usage: "Path to G2 SRS",
Required: true,
Required: false,
EnvVar: common.PrefixEnvVar(envPrefix, "G2_PATH"),
},
cli.StringFlag{
Expand Down
42 changes: 42 additions & 0 deletions pkg/encoding/kzgEncoder/multiframe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,45 @@ func TestUniversalVerify(t *testing.T) {

assert.True(t, group.UniversalVerify(params, samples, numBlob) == nil, "universal batch verification failed\n")
}

func TestUniversalVerifyWithPowerOf2G2(t *testing.T) {
teardownSuite := setupSuite(t)
defer teardownSuite(t)

group, _ := kzgRs.NewKzgEncoderGroup(kzgConfig, true)
group.KzgConfig.G2Path = ""
params := rs.GetEncodingParams(numSys, numPar, uint64(len(GETTYSBURG_ADDRESS_BYTES)))
enc, err := group.NewKzgEncoder(params)
require.Nil(t, err)

numBlob := 5
samples := make([]kzgRs.Sample, 0)
for z := 0; z < numBlob; z++ {
inputFr := rs.ToFrArray(GETTYSBURG_ADDRESS_BYTES)

commit, _, _, frames, fIndices, err := enc.Encode(inputFr)
require.Nil(t, err)

// create samples
for i := 0; i < len(frames); i++ {
f := frames[i]
j := fIndices[i]

q, err := rs.GetLeadingCosetIndex(uint64(i), numSys+numPar)
require.Nil(t, err)

assert.Equal(t, j, q, "leading coset inconsistency")

sample := kzgRs.Sample{
Commitment: *commit,
Proof: f.Proof,
RowIndex: z,
Coeffs: f.Coeffs,
X: uint(q),
}
samples = append(samples, sample)
}
}

assert.True(t, group.UniversalVerify(params, samples, numBlob) == nil, "universal batch verification failed\n")
}

0 comments on commit 1ddaba1

Please sign in to comment.