From 8e621411326b0716e536d16efe98fe3b83f2dc60 Mon Sep 17 00:00:00 2001 From: Patrick McClurg Date: Thu, 30 Jan 2025 11:58:51 +0100 Subject: [PATCH] fixed encoding of deposit data --- internal/holesky_test.go | 2 +- shared/api/deposit.go | 18 +++++++++--------- shared/files/deposit.go | 6 +++++- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/internal/holesky_test.go b/internal/holesky_test.go index ad8d5d5..30669f8 100644 --- a/internal/holesky_test.go +++ b/internal/holesky_test.go @@ -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 { diff --git a/shared/api/deposit.go b/shared/api/deposit.go index 6c4f066..584d61b 100644 --- a/shared/api/deposit.go +++ b/shared/api/deposit.go @@ -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 { diff --git a/shared/files/deposit.go b/shared/files/deposit.go index 9915903..70f6650 100644 --- a/shared/files/deposit.go +++ b/shared/files/deposit.go @@ -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, } }