Skip to content

Commit

Permalink
fixed encoding of deposit data
Browse files Browse the repository at this point in the history
  • Loading branch information
CluEleSsUK committed Jan 30, 2025
1 parent f89c9a3 commit 8e62141
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion internal/holesky_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func createHoleskyDaemon(t *testing.T, index int) sidecar.Daemon {
}

func depositData(t *testing.T) api.UnsignedDepositData {
j := `{"withdrawal_credentials":"aGVsbG8gd29ybGRoZWxsbyB3b3JsZGhlbGxvIHdvcmw=","deposit_data_root":"aGVsbG8gd29ybGQ=","deposit_message_root":"aGVsbG8gd29ybGQ=","amount":1,"fork_version":"somefork","network_name":"somenetwork","deposit_cli_version":"somecli"}`
j := `{ "withdrawal_credentials": "000ccc1a6eee8f5a8faa0ae44a0010233f31213825527270336677c4c869acaa", "amount": 32000000000, "deposit_message_root": "64c7ef6d1a2a2eea6cb39969903d3b64d1079f97da5af6c311df9d497d5a313a", "deposit_data_root": "f260af30ed9b5978676f7bc437fa2dc356c24bdd7deccf521bbc4ab6e21f5237", "fork_version": "01017000", "network_name": "holesky", "deposit_cli_version": "2.8.0" }`

var d api.UnsignedDepositData
if err := json.Unmarshal([]byte(j), &d); err != nil {
Expand Down
18 changes: 9 additions & 9 deletions shared/api/deposit.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ type OwnerConfig struct {
}

type UnsignedDepositData struct {
WithdrawalCredentials []byte `json:"withdrawal_credentials"`
DepositDataRoot []byte `json:"deposit_data_root"`
DepositMessageRoot []byte `json:"deposit_message_root,omitempty"`
Amount uint64 `json:"amount,omitempty"`
ForkVersion string `json:"fork_version,omitempty"`
NetworkName string `json:"network_name,omitempty"`
DepositCLIVersion string `json:"deposit_cli_version,omitempty"`
WithdrawalCredentials encoding.HexBytes `json:"withdrawal_credentials"`
DepositDataRoot encoding.HexBytes `json:"deposit_data_root"`
DepositMessageRoot encoding.HexBytes `json:"deposit_message_root,omitempty"`
Amount uint64 `json:"amount,omitempty"`
ForkVersion string `json:"fork_version,omitempty"`
NetworkName string `json:"network_name,omitempty"`
DepositCLIVersion string `json:"deposit_cli_version,omitempty"`
}

type SignedDepositData struct {
UnsignedDepositData
PubKey []byte `json:"pubkey"`
Signature []byte `json:"signature"`
PubKey encoding.HexBytes `json:"pubkey"`
Signature encoding.HexBytes `json:"signature"`
}

type SigningOutput struct {
Expand Down
6 changes: 5 additions & 1 deletion shared/files/deposit.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
package files

import (
"encoding/hex"

"github.com/randa-mu/ssv-dkg/shared/api"
"github.com/randa-mu/ssv-dkg/shared/crypto"
)

func CreateSignedDepositData(scheme crypto.ThresholdScheme, config api.SignatureConfig, output api.SigningOutput) api.SignedDepositData {
var sig []byte
hex.Encode(sig, output.DepositDataSignature)
return api.SignedDepositData{
UnsignedDepositData: config.DepositData,
PubKey: crypto.ExtractGroupPublicKey(scheme, output.GroupPublicPolynomial),
Signature: output.DepositDataSignature,
Signature: sig,
}
}

0 comments on commit 8e62141

Please sign in to comment.