mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 13:28:01 -05:00
* PeerDAS: Implement sync * Fix Potuz's comment. * Fix Potuz's comment. * Fix Potuz's comment. * Fix Satyajit's comment. * Partially fix Potuz's comment. * Fix Potuz's comment. * Fix Potuz's comment. * Fix Potuz's comment. * Fix Potuz's comment. * Fix Potuz's comment. * Fix Potuz's comment. * Fix Potuz's comment. * Add tests for `sendDataColumnSidecarsRequest`. * Fix Satyajit's comment. * Implement `TestSendDataColumnSidecarsRequest`. * Implement `TestFetchDataColumnSidecarsFromPeers`. * Implement `TestUpdateResults`. * Implement `TestSelectPeers`. * Implement `TestCategorizeIndices`. * Fix James' comment. * Fix James's comment. * Fix James' commit. * Fix James' comment. * Fix James' comment. * Fix flakiness in `TestSelectPeers`. * Update cmd/beacon-chain/flags/config.go Co-authored-by: Preston Van Loon <pvanloon@offchainlabs.com> * Fix Preston's comment. * Fix James's comment. * Implement `TestFetchDataColumnSidecars`. * Revert "Fix Potuz's comment." This reverts commitc45230b455. * Fix Potuz's comment. * Revert "Fix James' comment." This reverts commita3f919205a. * Fix James' comment. * Fix Preston's comment. * Fix James' comment. * `selectPeers`: Avoid map with key but empty value. * Fix typo. * Fix Potuz's comment. * Fix Potuz's comment. * Fix James' comment. * Add DataColumnStorage and SubscribeAllDataSubnets flag. * Add extra flags * Fix Potuz's and Preston's comment. * Add rate limiter check. --------- Co-authored-by: Preston Van Loon <pvanloon@offchainlabs.com> Co-authored-by: Kasey Kirkham <kasey@users.noreply.github.com>
48 lines
1.8 KiB
Go
48 lines
1.8 KiB
Go
package kzg
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/OffchainLabs/prysm/v6/consensus-types/blocks"
|
|
"github.com/OffchainLabs/prysm/v6/crypto/random"
|
|
"github.com/OffchainLabs/prysm/v6/testing/require"
|
|
GoKZG "github.com/crate-crypto/go-kzg-4844"
|
|
)
|
|
|
|
func GenerateCommitmentAndProof(blob GoKZG.Blob) (GoKZG.KZGCommitment, GoKZG.KZGProof, error) {
|
|
commitment, err := kzgContext.BlobToKZGCommitment(&blob, 0)
|
|
if err != nil {
|
|
return GoKZG.KZGCommitment{}, GoKZG.KZGProof{}, err
|
|
}
|
|
proof, err := kzgContext.ComputeBlobKZGProof(&blob, commitment, 0)
|
|
if err != nil {
|
|
return GoKZG.KZGCommitment{}, GoKZG.KZGProof{}, err
|
|
}
|
|
return commitment, proof, err
|
|
}
|
|
|
|
func TestVerify(t *testing.T) {
|
|
blobSidecars := make([]blocks.ROBlob, 0)
|
|
require.NoError(t, Verify(blobSidecars...))
|
|
}
|
|
|
|
func TestBytesToAny(t *testing.T) {
|
|
bytes := []byte{0x01, 0x02}
|
|
blob := GoKZG.Blob{0x01, 0x02}
|
|
commitment := GoKZG.KZGCommitment{0x01, 0x02}
|
|
proof := GoKZG.KZGProof{0x01, 0x02}
|
|
require.DeepEqual(t, blob, *bytesToBlob(bytes))
|
|
require.DeepEqual(t, commitment, bytesToCommitment(bytes))
|
|
require.DeepEqual(t, proof, bytesToKZGProof(bytes))
|
|
}
|
|
|
|
func TestGenerateCommitmentAndProof(t *testing.T) {
|
|
blob := random.GetRandBlob(123)
|
|
commitment, proof, err := GenerateCommitmentAndProof(blob)
|
|
require.NoError(t, err)
|
|
expectedCommitment := GoKZG.KZGCommitment{180, 218, 156, 194, 59, 20, 10, 189, 186, 254, 132, 93, 7, 127, 104, 172, 238, 240, 237, 70, 83, 89, 1, 152, 99, 0, 165, 65, 143, 62, 20, 215, 230, 14, 205, 95, 28, 245, 54, 25, 160, 16, 178, 31, 232, 207, 38, 85}
|
|
expectedProof := GoKZG.KZGProof{128, 110, 116, 170, 56, 111, 126, 87, 229, 234, 211, 42, 110, 150, 129, 206, 73, 142, 167, 243, 90, 149, 240, 240, 236, 204, 143, 182, 229, 249, 81, 27, 153, 171, 83, 70, 144, 250, 42, 1, 188, 215, 71, 235, 30, 7, 175, 86}
|
|
require.Equal(t, expectedCommitment, commitment)
|
|
require.Equal(t, expectedProof, proof)
|
|
}
|