Skip to content

Commit

Permalink
onchain renaming (#1154)
Browse files Browse the repository at this point in the history
Co-authored-by: Ian Shim <shim@fastmail.com>
  • Loading branch information
0x0aa0 and ian-shim authored Jan 27, 2025
1 parent 9331331 commit f04df48
Show file tree
Hide file tree
Showing 33 changed files with 2,027 additions and 7,405 deletions.
2 changes: 1 addition & 1 deletion api/clients/v2/payload_retriever.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/Layr-Labs/eigenda/api/clients/codecs"
"github.com/Layr-Labs/eigenda/api/clients/v2/verification"
"github.com/Layr-Labs/eigenda/common/geth"
verifiercontract "github.com/Layr-Labs/eigenda/contracts/bindings/EigenDABlobVerifier"
verifiercontract "github.com/Layr-Labs/eigenda/contracts/bindings/EigenDACertVerifier"
core "github.com/Layr-Labs/eigenda/core/v2"
"github.com/Layr-Labs/eigenda/encoding"
"github.com/Layr-Labs/eigensdk-go/logging"
Expand Down
6 changes: 3 additions & 3 deletions api/clients/v2/test/payload_retriever_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
disperserv2 "github.com/Layr-Labs/eigenda/api/grpc/disperser/v2"
"github.com/Layr-Labs/eigenda/common"
testrandom "github.com/Layr-Labs/eigenda/common/testutils/random"
contractEigenDABlobVerifier "github.com/Layr-Labs/eigenda/contracts/bindings/EigenDABlobVerifier"
contractEigenDACertVerifier "github.com/Layr-Labs/eigenda/contracts/bindings/EigenDACertVerifier"
core "github.com/Layr-Labs/eigenda/core/v2"
"github.com/Layr-Labs/eigenda/encoding"
"github.com/Layr-Labs/eigenda/encoding/kzg"
Expand Down Expand Up @@ -464,7 +464,7 @@ func TestGetBlobReturnsBlobWithInvalidLen(t *testing.T) {

blobKey, blobBytes, blobCert := buildBlobAndCert(t, tester, relayKeys)

blobCert.BlobInclusionInfo.BlobCertificate.BlobHeader.Commitment.DataLength--
blobCert.BlobInclusionInfo.BlobCertificate.BlobHeader.Commitment.Length--

tester.MockRelayClient.On("GetBlob", mock.Anything, mock.Anything, blobKey).Return(blobBytes, nil).Once()
tester.MockCertVerifier.On(
Expand Down Expand Up @@ -505,7 +505,7 @@ func TestFailedDecoding(t *testing.T) {
require.NoError(t, err)
require.NotNil(t, maliciousCommitment)

blobCert.BlobInclusionInfo.BlobCertificate.BlobHeader.Commitment.Commitment = contractEigenDABlobVerifier.BN254G1Point{
blobCert.BlobInclusionInfo.BlobCertificate.BlobHeader.Commitment.Commitment = contractEigenDACertVerifier.BN254G1Point{
X: maliciousCommitment.X.BigInt(new(big.Int)),
Y: maliciousCommitment.Y.BigInt(new(big.Int)),
}
Expand Down
20 changes: 10 additions & 10 deletions api/clients/v2/verification/cert_verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/Layr-Labs/eigenda/common/geth"

disperser "github.com/Layr-Labs/eigenda/api/grpc/disperser/v2"
verifierBindings "github.com/Layr-Labs/eigenda/contracts/bindings/EigenDABlobVerifier"
verifierBindings "github.com/Layr-Labs/eigenda/contracts/bindings/EigenDACertVerifier"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
gethcommon "github.com/ethereum/go-ethereum/common"
)
Expand All @@ -25,21 +25,21 @@ type ICertVerifier interface {
// CertVerifier is responsible for making eth calls against the CertVerifier contract to ensure cryptographic and
// structural integrity of V2 certificates
//
// The cert verifier contract is located at https://github.com/Layr-Labs/eigenda/blob/master/contracts/src/core/EigenDABlobVerifier.sol
// The cert verifier contract is located at https://github.com/Layr-Labs/eigenda/blob/master/contracts/src/core/EigenDACertVerifier.sol
type CertVerifier struct {
// go binding around the EigenDACertVerifier ethereum contract
certVerifierCaller *verifierBindings.ContractEigenDABlobVerifierCaller
certVerifierCaller *verifierBindings.ContractEigenDACertVerifierCaller
}

var _ ICertVerifier = &CertVerifier{}

// NewCertVerifier constructs a CertVerifier
func NewCertVerifier(
ethClient geth.EthClient, // the eth client, which should already be set up
ethClient geth.EthClient, // the eth client, which should already be set up
certVerifierAddress string, // the hex address of the EigenDACertVerifier contract
) (*CertVerifier, error) {

verifierCaller, err := verifierBindings.NewContractEigenDABlobVerifierCaller(
verifierCaller, err := verifierBindings.NewContractEigenDACertVerifierCaller(
gethcommon.HexToAddress(certVerifierAddress),
ethClient)

Expand All @@ -57,10 +57,10 @@ func NewCertVerifier(
// This method returns nil if the cert is successfully verified. Otherwise, it returns an error.
func (cv *CertVerifier) VerifyCertV2FromSignedBatch(
ctx context.Context,
// The signed batch that contains the blob whose cert is being verified. This is obtained from the disperser, and
// is used to verify that the described blob actually exists in a valid batch.
// The signed batch that contains the blob whose cert is being verified. This is obtained from the disperser, and
// is used to verify that the described blob actually exists in a valid batch.
signedBatch *disperser.SignedBatch,
// Contains all necessary information about the blob, so that the cert can be verified.
// Contains all necessary information about the blob, so that the cert can be verified.
blobInclusionInfo *disperser.BlobInclusionInfo,
) error {
convertedSignedBatch, err := SignedBatchProtoToBinding(signedBatch)
Expand All @@ -73,7 +73,7 @@ func (cv *CertVerifier) VerifyCertV2FromSignedBatch(
return fmt.Errorf("convert blob inclusion info: %w", err)
}

err = cv.certVerifierCaller.VerifyBlobV2FromSignedBatch(
err = cv.certVerifierCaller.VerifyDACertV2FromSignedBatch(
&bind.CallOpts{Context: ctx},
*convertedSignedBatch,
*convertedBlobInclusionInfo)
Expand All @@ -92,7 +92,7 @@ func (cv *CertVerifier) VerifyCertV2(
ctx context.Context,
eigenDACert *EigenDACert,
) error {
err := cv.certVerifierCaller.VerifyBlobV2(
err := cv.certVerifierCaller.VerifyDACertV2(
&bind.CallOpts{Context: ctx},
eigenDACert.BatchHeader,
eigenDACert.BlobInclusionInfo,
Expand Down
52 changes: 26 additions & 26 deletions api/clients/v2/verification/conversion_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import (
"github.com/Layr-Labs/eigenda/api/grpc/common"
commonv2 "github.com/Layr-Labs/eigenda/api/grpc/common/v2"
disperserv2 "github.com/Layr-Labs/eigenda/api/grpc/disperser/v2"
contractEigenDABlobVerifier "github.com/Layr-Labs/eigenda/contracts/bindings/EigenDABlobVerifier"
contractEigenDACertVerifier "github.com/Layr-Labs/eigenda/contracts/bindings/EigenDACertVerifier"
"github.com/Layr-Labs/eigenda/core"
"github.com/consensys/gnark-crypto/ecc/bn254"
"github.com/consensys/gnark-crypto/ecc/bn254/fp"
)

func SignedBatchProtoToBinding(inputBatch *disperserv2.SignedBatch) (*contractEigenDABlobVerifier.SignedBatch, error) {
func SignedBatchProtoToBinding(inputBatch *disperserv2.SignedBatch) (*contractEigenDACertVerifier.SignedBatch, error) {
convertedBatchHeader, err := BatchHeaderProtoToBinding(inputBatch.GetHeader())
if err != nil {
return nil, fmt.Errorf("convert batch header: %s", err)
Expand All @@ -25,15 +25,15 @@ func SignedBatchProtoToBinding(inputBatch *disperserv2.SignedBatch) (*contractEi
return nil, fmt.Errorf("convert attestation: %s", err)
}

outputSignedBatch := &contractEigenDABlobVerifier.SignedBatch{
outputSignedBatch := &contractEigenDACertVerifier.SignedBatch{
BatchHeader: *convertedBatchHeader,
Attestation: *convertedAttestation,
}

return outputSignedBatch, nil
}

func BatchHeaderProtoToBinding(inputHeader *commonv2.BatchHeader) (*contractEigenDABlobVerifier.BatchHeaderV2, error) {
func BatchHeaderProtoToBinding(inputHeader *commonv2.BatchHeader) (*contractEigenDACertVerifier.BatchHeaderV2, error) {
var outputBatchRoot [32]byte

inputBatchRoot := inputHeader.GetBatchRoot()
Expand All @@ -50,15 +50,15 @@ func BatchHeaderProtoToBinding(inputHeader *commonv2.BatchHeader) (*contractEige
math.MaxUint32)
}

convertedHeader := &contractEigenDABlobVerifier.BatchHeaderV2{
convertedHeader := &contractEigenDACertVerifier.BatchHeaderV2{
BatchRoot: outputBatchRoot,
ReferenceBlockNumber: uint32(inputReferenceBlockNumber),
}

return convertedHeader, nil
}

func attestationProtoToBinding(inputAttestation *disperserv2.Attestation) (*contractEigenDABlobVerifier.Attestation, error) {
func attestationProtoToBinding(inputAttestation *disperserv2.Attestation) (*contractEigenDACertVerifier.Attestation, error) {
nonSignerPubkeys, err := repeatedBytesToBN254G1Points(inputAttestation.GetNonSignerPubkeys())
if err != nil {
return nil, fmt.Errorf("convert non signer pubkeys to g1 points: %s", err)
Expand All @@ -79,7 +79,7 @@ func attestationProtoToBinding(inputAttestation *disperserv2.Attestation) (*cont
return nil, fmt.Errorf("convert apk g2 to g2 point: %s", err)
}

convertedAttestation := &contractEigenDABlobVerifier.Attestation{
convertedAttestation := &contractEigenDACertVerifier.Attestation{
NonSignerPubkeys: nonSignerPubkeys,
QuorumApks: quorumApks,
Sigma: *sigma,
Expand All @@ -90,34 +90,34 @@ func attestationProtoToBinding(inputAttestation *disperserv2.Attestation) (*cont
return convertedAttestation, nil
}

func InclusionInfoProtoToBinding(inputInclusionInfo *disperserv2.BlobInclusionInfo) (*contractEigenDABlobVerifier.BlobVerificationProofV2, error) {
func InclusionInfoProtoToBinding(inputInclusionInfo *disperserv2.BlobInclusionInfo) (*contractEigenDACertVerifier.BlobInclusionInfo, error) {
convertedBlobCertificate, err := blobCertificateProtoToBinding(inputInclusionInfo.GetBlobCertificate())

if err != nil {
return nil, fmt.Errorf("convert blob certificate: %s", err)
}

return &contractEigenDABlobVerifier.BlobVerificationProofV2{
return &contractEigenDACertVerifier.BlobInclusionInfo{
BlobCertificate: *convertedBlobCertificate,
BlobIndex: inputInclusionInfo.GetBlobIndex(),
InclusionProof: inputInclusionInfo.GetInclusionProof(),
}, nil
}

func blobCertificateProtoToBinding(inputCertificate *commonv2.BlobCertificate) (*contractEigenDABlobVerifier.BlobCertificate, error) {
func blobCertificateProtoToBinding(inputCertificate *commonv2.BlobCertificate) (*contractEigenDACertVerifier.BlobCertificate, error) {
convertedBlobHeader, err := blobHeaderProtoToBinding(inputCertificate.GetBlobHeader())
if err != nil {
return nil, fmt.Errorf("convert blob header: %s", err)
}

return &contractEigenDABlobVerifier.BlobCertificate{
return &contractEigenDACertVerifier.BlobCertificate{
BlobHeader: *convertedBlobHeader,
Signature: inputCertificate.GetSignature(),
RelayKeys: inputCertificate.GetRelayKeys(),
}, nil
}

func blobHeaderProtoToBinding(inputHeader *commonv2.BlobHeader) (*contractEigenDABlobVerifier.BlobHeaderV2, error) {
func blobHeaderProtoToBinding(inputHeader *commonv2.BlobHeader) (*contractEigenDACertVerifier.BlobHeaderV2, error) {
inputVersion := inputHeader.GetVersion()
if inputVersion > math.MaxUint16 {
return nil, fmt.Errorf(
Expand Down Expand Up @@ -148,15 +148,15 @@ func blobHeaderProtoToBinding(inputHeader *commonv2.BlobHeader) (*contractEigenD
return nil, fmt.Errorf("hash payment header: %s", err)
}

return &contractEigenDABlobVerifier.BlobHeaderV2{
return &contractEigenDACertVerifier.BlobHeaderV2{
Version: uint16(inputVersion),
QuorumNumbers: quorumNumbers,
Commitment: *convertedBlobCommitment,
PaymentHeaderHash: paymentHeaderHash,
}, nil
}

func blobCommitmentProtoToBinding(inputCommitment *common.BlobCommitment) (*contractEigenDABlobVerifier.BlobCommitment, error) {
func blobCommitmentProtoToBinding(inputCommitment *common.BlobCommitment) (*contractEigenDACertVerifier.BlobCommitment, error) {
convertedCommitment, err := bytesToBN254G1Point(inputCommitment.GetCommitment())
if err != nil {
return nil, fmt.Errorf("convert commitment to g1 point: %s", err)
Expand All @@ -172,39 +172,39 @@ func blobCommitmentProtoToBinding(inputCommitment *common.BlobCommitment) (*cont
return nil, fmt.Errorf("convert length proof to g2 point: %s", err)
}

return &contractEigenDABlobVerifier.BlobCommitment{
return &contractEigenDACertVerifier.BlobCommitment{
Commitment: *convertedCommitment,
LengthCommitment: *convertedLengthCommitment,
LengthProof: *convertedLengthProof,
DataLength: inputCommitment.GetLength(),
Length: inputCommitment.GetLength(),
}, nil
}

// BlobCommitmentBindingToProto converts a BlobCommitment binding into a common.BlobCommitment protobuf
func BlobCommitmentBindingToProto(inputCommitment *contractEigenDABlobVerifier.BlobCommitment) *common.BlobCommitment {
func BlobCommitmentBindingToProto(inputCommitment *contractEigenDACertVerifier.BlobCommitment) *common.BlobCommitment {
return &common.BlobCommitment{
Commitment: bn254G1PointToBytes(&inputCommitment.Commitment),
LengthCommitment: bn254G2PointToBytes(&inputCommitment.LengthCommitment),
LengthProof: bn254G2PointToBytes(&inputCommitment.LengthProof),
Length: inputCommitment.DataLength,
Length: inputCommitment.Length,
}
}

func bytesToBN254G1Point(bytes []byte) (*contractEigenDABlobVerifier.BN254G1Point, error) {
func bytesToBN254G1Point(bytes []byte) (*contractEigenDACertVerifier.BN254G1Point, error) {
var g1Point bn254.G1Affine
_, err := g1Point.SetBytes(bytes)

if err != nil {
return nil, fmt.Errorf("deserialize g1 point: %s", err)
}

return &contractEigenDABlobVerifier.BN254G1Point{
return &contractEigenDACertVerifier.BN254G1Point{
X: g1Point.X.BigInt(new(big.Int)),
Y: g1Point.Y.BigInt(new(big.Int)),
}, nil
}

func bn254G1PointToBytes(inputPoint *contractEigenDABlobVerifier.BN254G1Point) []byte {
func bn254G1PointToBytes(inputPoint *contractEigenDACertVerifier.BN254G1Point) []byte {
var x fp.Element
x.SetBigInt(inputPoint.X)
var y fp.Element
Expand All @@ -216,7 +216,7 @@ func bn254G1PointToBytes(inputPoint *contractEigenDABlobVerifier.BN254G1Point) [
return bytes[:]
}

func bytesToBN254G2Point(bytes []byte) (*contractEigenDABlobVerifier.BN254G2Point, error) {
func bytesToBN254G2Point(bytes []byte) (*contractEigenDACertVerifier.BN254G2Point, error) {
var g2Point bn254.G2Affine

// SetBytes checks that the result is in the correct subgroup
Expand All @@ -235,13 +235,13 @@ func bytesToBN254G2Point(bytes []byte) (*contractEigenDABlobVerifier.BN254G2Poin
y[0] = g2Point.Y.A1.BigInt(new(big.Int))
y[1] = g2Point.Y.A0.BigInt(new(big.Int))

return &contractEigenDABlobVerifier.BN254G2Point{
return &contractEigenDACertVerifier.BN254G2Point{
X: x,
Y: y,
}, nil
}

func bn254G2PointToBytes(inputPoint *contractEigenDABlobVerifier.BN254G2Point) []byte {
func bn254G2PointToBytes(inputPoint *contractEigenDACertVerifier.BN254G2Point) []byte {
var g2Point bn254.G2Affine

// Order is intentionally reversed when converting here
Expand All @@ -258,8 +258,8 @@ func bn254G2PointToBytes(inputPoint *contractEigenDABlobVerifier.BN254G2Point) [
return pointBytes[:]
}

func repeatedBytesToBN254G1Points(repeatedBytes [][]byte) ([]contractEigenDABlobVerifier.BN254G1Point, error) {
var outputPoints []contractEigenDABlobVerifier.BN254G1Point
func repeatedBytesToBN254G1Points(repeatedBytes [][]byte) ([]contractEigenDACertVerifier.BN254G1Point, error) {
var outputPoints []contractEigenDACertVerifier.BN254G1Point
for _, bytes := range repeatedBytes {
g1Point, err := bytesToBN254G1Point(bytes)
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions api/clients/v2/verification/eigenda_cert.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package verification

import (
contractEigenDABlobVerifier "github.com/Layr-Labs/eigenda/contracts/bindings/EigenDABlobVerifier"
contractEigenDACertVerifier "github.com/Layr-Labs/eigenda/contracts/bindings/EigenDACertVerifier"
)

// EigenDACert contains all data necessary to retrieve and validate a blob
//
// This struct represents the composition of a eigenDA blob certificate, as it would exist in a rollup inbox.
type EigenDACert struct {
BlobInclusionInfo contractEigenDABlobVerifier.BlobVerificationProofV2
BatchHeader contractEigenDABlobVerifier.BatchHeaderV2
NonSignerStakesAndSignature contractEigenDABlobVerifier.NonSignerStakesAndSignature
BlobInclusionInfo contractEigenDACertVerifier.BlobInclusionInfo
BatchHeader contractEigenDACertVerifier.BatchHeaderV2
NonSignerStakesAndSignature contractEigenDACertVerifier.NonSignerStakesAndSignature
}
Loading

0 comments on commit f04df48

Please sign in to comment.