Skip to content

Commit c2fd322

Browse files
committed
chore: Only use bvp for keying memstore
1 parent 3a4b044 commit c2fd322

File tree

1 file changed

+30
-17
lines changed

1 file changed

+30
-17
lines changed

server/memory_store.go

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"crypto/rand"
66
"fmt"
7+
"math/big"
78
"sync"
89
"time"
910

@@ -149,43 +150,55 @@ func (e *MemStore) Put(ctx context.Context, value []byte) ([]byte, error) {
149150
if err != nil {
150151
return nil, err
151152
}
152-
mockBatchHeaderHash := crypto.Keccak256Hash(entropy)
153+
mockBatchRoot := crypto.Keccak256Hash(entropy)
154+
blockNum, _ := rand.Int(rand.Reader, big.NewInt(1000))
155+
156+
num := uint32(blockNum.Uint64())
153157

154-
// only filling out commitment fields for now
155158
cert := &verify.Certificate{
156159
BlobHeader: &disperser.BlobHeader{
157160
Commitment: &common.G1Commitment{
158161
X: commitment.X.Marshal(),
159162
Y: commitment.Y.Marshal(),
160163
},
161-
// DataLength: ,
162-
// BlobQuorumParams: ,
164+
DataLength: uint32(len(encodedVal)),
165+
BlobQuorumParams: []*disperser.BlobQuorumParam{
166+
{
167+
QuorumNumber: 1,
168+
AdversaryThresholdPercentage: 29,
169+
ConfirmationThresholdPercentage: 30,
170+
ChunkLength: 300,
171+
},
172+
},
163173
},
164174
BlobVerificationProof: &disperser.BlobVerificationProof{
165175
BatchMetadata: &disperser.BatchMetadata{
166176
BatchHeader: &disperser.BatchHeader{
167-
// BatchRoot: ,
168-
// QuorumNumbers: ,
169-
// QuorumSignedPercentages: ,
170-
// ReferenceBlockNumber: ,
177+
BatchRoot: mockBatchRoot[:],
178+
QuorumNumbers: []byte{0x1, 0x0},
179+
QuorumSignedPercentages: []byte{0x60, 0x90},
180+
ReferenceBlockNumber: num,
171181
},
172-
// SignatoryRecordHash: ,
173-
// Fee: ,
174-
// ConfirmationBlockNumber: ,
175-
BatchHeaderHash: mockBatchHeaderHash[:],
182+
SignatoryRecordHash: mockBatchRoot[:],
183+
Fee: []byte{},
184+
ConfirmationBlockNumber: num,
185+
BatchHeaderHash: []byte{},
176186
},
177-
// BatchId: ,
178-
// BlobIndex: ,
179-
// InclusionProof: ,
180-
// QuorumIndexes: ,
187+
BatchId: 69,
188+
BlobIndex: 420,
189+
InclusionProof: entropy,
190+
QuorumIndexes: []byte{0x1, 0x0},
181191
},
182192
}
183193

184194
certBytes, err := rlp.EncodeToBytes(cert)
185195
if err != nil {
186196
return nil, err
187197
}
188-
certStr := string(certBytes)
198+
// construct key
199+
bytesKeys := append([]byte{0x4}, cert.BlobVerificationProof.InclusionProof...)
200+
201+
certStr := string(bytesKeys)
189202

190203
if _, exists := e.store[certStr]; exists {
191204
return nil, fmt.Errorf("commitment key already exists")

0 commit comments

Comments
 (0)