Skip to content

Commit 3da553a

Browse files
committed
feat: append sig to da message
1 parent fae3cf9 commit 3da553a

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

dataavailability/ethda/ethda.go

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import (
66
"fmt"
77
blobutils "github.com/crustio/blob-utils"
88
"github.com/ethereum/go-ethereum/common"
9+
"github.com/ethereum/go-ethereum/crypto"
10+
solsha3 "github.com/miguelmota/go-solidity-sha3"
911
"math/big"
1012
)
1113

@@ -55,7 +57,25 @@ func (d *EthdaBackend) PostSequence(ctx context.Context, batchesData [][]byte) (
5557
hashes = append(hashes, hash.Bytes()...)
5658
}
5759

58-
return hashes, nil
60+
currentHash := common.Hash{}.Bytes()
61+
for _, batchData := range batchesData {
62+
types := []string{
63+
"bytes32",
64+
"bytes32",
65+
}
66+
values := []interface{}{
67+
currentHash,
68+
crypto.Keccak256(batchData),
69+
}
70+
currentHash = solsha3.SoliditySHA3(types, values)
71+
}
72+
73+
sig, err := d.ethdaClient.SignBatchHash(common.BytesToHash(currentHash))
74+
if err != nil {
75+
return nil, err
76+
}
77+
78+
return append(sig, hashes...), nil
5979
}
6080

6181
func (d *EthdaBackend) GetSequence(ctx context.Context, batchHashes []common.Hash, dataAvailabilityMessage []byte) ([][]byte, error) {
@@ -64,8 +84,8 @@ func (d *EthdaBackend) GetSequence(ctx context.Context, batchHashes []common.Has
6484
}
6585

6686
var data [][]byte
67-
for i := 0; i < len(dataAvailabilityMessage)/common.HashLength; i++ {
68-
start := common.HashLength * i
87+
for i := 0; i < (len(dataAvailabilityMessage)-crypto.SignatureLength)/common.HashLength; i++ {
88+
start := common.HashLength*i + crypto.SignatureLength
6989
hash := common.BytesToHash(dataAvailabilityMessage[start : start+common.HashLength])
7090

7191
r, err := d.ethdaClient.GetBlob(hash)

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ require (
6060
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
6161
github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233 // indirect
6262
github.com/crate-crypto/go-kzg-4844 v0.7.0 // indirect
63-
github.com/crustio/blob-utils v0.2.1 // indirect
63+
github.com/crustio/blob-utils v0.3.1 // indirect
6464
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
6565
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
6666
github.com/deckarep/golang-set/v2 v2.1.0 // indirect

go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,10 @@ github.com/crustio/blob-utils v0.2.0 h1:cDBcKSbo160Ty6rX+jafCwK3Bhh7wfpjyKcE/c+E
167167
github.com/crustio/blob-utils v0.2.0/go.mod h1:7BcdCxXDgJ2xPNRLgVxlBXQ3eWZ0oFTcwZ+h3dpj58g=
168168
github.com/crustio/blob-utils v0.2.1 h1:kDiV8kPjyyjzIk64ezB6VN+H6fbtK9eAUcSmF94RJ5M=
169169
github.com/crustio/blob-utils v0.2.1/go.mod h1:d0x/5NSSocyvkRXkVJUnRGsB3EkZ0YuI/Nn8wN4l44g=
170+
github.com/crustio/blob-utils v0.3.0 h1:7Uh7FmZQLZFcacfmqZhV2Z5J6P88CeLoSwtoBcLRvsE=
171+
github.com/crustio/blob-utils v0.3.0/go.mod h1:d0x/5NSSocyvkRXkVJUnRGsB3EkZ0YuI/Nn8wN4l44g=
172+
github.com/crustio/blob-utils v0.3.1 h1:T++x9rKRqB7mlQp9nZpfadQd0UvKH6zMgV1695EvkUE=
173+
github.com/crustio/blob-utils v0.3.1/go.mod h1:d0x/5NSSocyvkRXkVJUnRGsB3EkZ0YuI/Nn8wN4l44g=
170174
github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg=
171175
github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4=
172176
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=

0 commit comments

Comments
 (0)