Skip to content

Commit

Permalink
add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubuntu committed Nov 30, 2023
1 parent 8a8123f commit 65fc825
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
6 changes: 4 additions & 2 deletions core/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func NewChunkValidator(enc Encoder, asgn AssignmentCoordinator, cst ChainState,
}
}

// preprocessBlob for each Quorum
func (v *chunkValidator) preprocessBlob(quorumHeader *BlobQuorumInfo, blob *BlobMessage, operatorState *OperatorState) ([]*Chunk, *Assignment, *EncodingParams, error) {
if quorumHeader.AdversaryThreshold >= quorumHeader.QuorumThreshold {
return nil, nil, nil, errors.New("invalid header: quorum threshold does not exceed adversary threshold")
Expand Down Expand Up @@ -175,12 +176,13 @@ func (v *chunkValidator) ValidateBatch(blobs []*BlobMessage, operatorState *Oper
}
}

// Parallelize the universal verification for each subBatch
numSubBatch := len(subBatchMap)
out := make(chan error, numSubBatch)
for params, subBatch := range subBatchMap {
params := params
subBatch := subBatch
go v.UniversalVerifyWorker(params, &subBatch, out)
go v.universalVerifyWorker(params, &subBatch, out)
}

for i := 0; i < numSubBatch; i++ {
Expand All @@ -193,7 +195,7 @@ func (v *chunkValidator) ValidateBatch(blobs []*BlobMessage, operatorState *Oper
return nil
}

func (v *chunkValidator) UniversalVerifyWorker(params EncodingParams, subBatch *SubBatch, out chan error) {
func (v *chunkValidator) universalVerifyWorker(params EncodingParams, subBatch *SubBatch, out chan error) {

err := v.encoder.UniversalVerifyChunks(params, subBatch.Samples, subBatch.NumBlobs)
if err != nil {
Expand Down
16 changes: 12 additions & 4 deletions pkg/encoding/kzgEncoder/multiframe.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ import (
bls "github.com/Layr-Labs/eigenda/pkg/kzg/bn254"
)

// Sample is the basic unit for a verification
// A blob may contain multiple Samples
type Sample struct {
Commitment bls.G1Point
Proof bls.G1Point
Row int
Row int // corresponds to a row in the verification matrix
Coeffs []bls.Fr
X uint // X is int , at which index is evaluated
X uint // X is assignment
}

// generate a random value using Fiat Shamir transform
Expand Down Expand Up @@ -47,7 +49,12 @@ func GenRandomness(params rs.EncodingParams, samples []Sample, m int) (bls.Fr, e
return randomFr, nil
}

// m is number of blob
// UniversalVerify implements batch verification on a set of chunks given the same chunk dimension (chunkLen, numChunk).
// The details is given in Ethereum Research post whose authors are George Kadianakis, George Kadianakis, George Kadianakis
// https://ethresear.ch/t/a-universal-verification-equation-for-data-availability-sampling/13240
//
// m is number of blob, samples is a list of chunks
// Inside the code, ft stands for first term; st for the second term; tt for the third term
func (group *KzgEncoderGroup) UniversalVerify(params rs.EncodingParams, samples []Sample, m int) error {
verifier, _ := group.GetKzgVerifier(params)
ks := verifier.Ks
Expand Down Expand Up @@ -122,6 +129,8 @@ func (group *KzgEncoderGroup) UniversalVerify(params rs.EncodingParams, samples
leadingDs := make([]bls.Fr, n)

for k := 0; k < n; k++ {
// It is important to obtain the leading coset here
// As the params from the eigenda Core might not have NumChunks be the power of 2
x, err := rs.GetLeadingCosetIndex(
uint64(samples[k].X),
params.NumChunks,
Expand All @@ -141,7 +150,6 @@ func (group *KzgEncoderGroup) UniversalVerify(params rs.EncodingParams, samples
bls.CopyFr(&leadingDs[k], &hPow)
}

//
for k := 0; k < n; k++ {
rk := randomsFr[k]
bls.MulModFr(&ttCoeffs[k], &rk, &leadingDs[k])
Expand Down

0 comments on commit 65fc825

Please sign in to comment.