Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jianoaix committed Feb 5, 2024
1 parent 9a1e40f commit a34e98f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 23 deletions.
23 changes: 6 additions & 17 deletions pkg/encoding/kzgEncoder/batchCommitEquivalence_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@ func TestBatchEquivalence(t *testing.T) {
enc, err := group.NewKzgEncoder(params)
require.Nil(t, err)

inputFr := rs.ToFrArray(GETTYSBURG_ADDRESS_BYTES)
commit, g2commit, _, _, _, err := enc.Encode(inputFr)
require.Nil(t, err)

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

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

commitPairs[z] = kzgRs.CommitmentPair{
Commitment: *commit,
LengthCommitment: *g2commit,
Expand All @@ -35,14 +34,9 @@ func TestBatchEquivalence(t *testing.T) {

assert.True(t, group.BatchVerifyCommitEquivalence(commitPairs) == nil, "batch equivalence test failed\n")

var modifiedCommit bn254.G1Point
bn254.AddG1(&modifiedCommit, commit, commit)
for z := 0; z < numBlob; z++ {
inputFr := rs.ToFrArray(GETTYSBURG_ADDRESS_BYTES)

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

var modifiedCommit bn254.G1Point
bn254.AddG1(&modifiedCommit, commit, commit)
commitPairs[z] = kzgRs.CommitmentPair{
Commitment: modifiedCommit,
LengthCommitment: *g2commit,
Expand All @@ -52,11 +46,6 @@ func TestBatchEquivalence(t *testing.T) {
assert.False(t, group.BatchVerifyCommitEquivalence(commitPairs) == nil, "batch equivalence negative test failed\n")

for z := 0; z < numBlob; z++ {
inputFr := rs.ToFrArray(GETTYSBURG_ADDRESS_BYTES)

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

commitPairs[z] = kzgRs.CommitmentPair{
Commitment: *commit,
LengthCommitment: *g2commit,
Expand Down
4 changes: 2 additions & 2 deletions pkg/encoding/kzgEncoder/encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func NewKzgEncoderGroup(config *KzgConfig, loadG2Points bool) (*KzgEncoderGroup,

}

// n is the power
// Read the n-th G1 point from SRS.
func ReadG1Point(n uint64, g *KzgConfig) (bls.G1Point, error) {
if n > g.SRSOrder {
return bls.G1Point{}, fmt.Errorf("requested power %v is larger than SRSOrder %v", n, g.SRSOrder)
Expand All @@ -140,7 +140,7 @@ func ReadG1Point(n uint64, g *KzgConfig) (bls.G1Point, error) {
return g1point[0], nil
}

// n is the power
// Read the n-th G2 point from SRS.
func ReadG2Point(n uint64, g *KzgConfig) (bls.G2Point, error) {
if n > g.SRSOrder {
return bls.G2Point{}, fmt.Errorf("requested power %v is larger than SRSOrder %v", n, g.SRSOrder)
Expand Down
3 changes: 0 additions & 3 deletions pkg/encoding/kzgEncoder/frame.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,7 @@ func (f *Frame) Verify(ks *kzg.KZGSettings, commitment *bls.G1Point, x *bls.Fr,
// [s^n - x^n]_2
var xnMinusYn bls.G2Point


//bls.SubG2(&xnMinusYn, &ks.Srs.G2[len(f.Coeffs)], &xn2)
bls.SubG2(&xnMinusYn, g2Atn, &xn2)


// [interpolation_polynomial(s)]_1
is1 := bls.LinCombG1(ks.Srs.G1[:len(f.Coeffs)], f.Coeffs)
Expand Down
1 change: 0 additions & 1 deletion pkg/encoding/kzgEncoder/verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ func (v *KzgEncoderGroup) VerifyCommit(lengthCommit *wbls.G2Point, lowDegreeProo
if err != nil {
return err
}
//fmt.Printf("claimed length is %v the challeng point is %v\n", length, string(g1Challenge.MarshalText()))

if !VerifyLowDegreeProof(lengthCommit, lowDegreeProof, &g1Challenge) {
return errors.New("low degree proof fails")
Expand Down

0 comments on commit a34e98f

Please sign in to comment.