-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Re-sign and re-share using proofs and EIP1271 signature (#100)
* initial resigning * add routes + flow * working resigning with result validation * fix tests * add integration tests for resiging * update integration tests to use cli commands * initial spec alignment + reshare module * working resharing * add EIP1271 owner signature verification * update resharing + add docker demo for resharing * add reshare threshold + integration tests * add threshold integration tests * fix logic at message processing * add eip1271 sig integration tests * add eip1271 sig verification to resign + integration/docker tests * add eip1271 sig resign test + bulk tests * fix/update unit + integration tests * update tests + fix bls set * PR comments resolved #1 * PR comments resolved #2 * PR comments resolved #3 * PR comments resolved #4 * PR comments resolved #5 * PR comments resolved #6 * fix tests + docker build update * update CI * fix test * lint * add more reshare integration tests * go 1.23 * add unit tests for join/disjoin sets of operators * lint * add proofs validation before sending + more reshare threshold integration tests * fix unit tests * lint * fix review comments * remove typo and unused struct --------- Co-authored-by: Matus Kysel <[email protected]>
- Loading branch information
1 parent
ace61ed
commit 8d55ffd
Showing
105 changed files
with
6,980 additions
and
714 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
bin/ | ||
.vscode/ | ||
examples/*/output/* | ||
integration_test/output | ||
|
||
######## Node | ||
# Logs | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
package initiator | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"os" | ||
"path/filepath" | ||
|
||
e2m_core "github.com/bloxapp/eth2-key-manager/core" | ||
cli_utils "github.com/bloxapp/ssv-dkg/cli/utils" | ||
"github.com/bloxapp/ssv-dkg/pkgs/initiator" | ||
"github.com/bloxapp/ssv-dkg/pkgs/wire" | ||
"github.com/ethereum/go-ethereum/accounts/keystore" | ||
"github.com/spf13/cobra" | ||
"go.uber.org/zap" | ||
|
||
spec "github.com/ssvlabs/dkg-spec" | ||
) | ||
|
||
func init() { | ||
cli_utils.SetReshareFlags(StartReshare) | ||
} | ||
|
||
var StartReshare = &cobra.Command{ | ||
Use: "reshare", | ||
Short: "Reshare an existing key to new operators", | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
fmt.Println(` | ||
βββββββ ββ βββ βββββ ββββββ ββββββ ββββββ βββ ββ βββ ββββββ ββββββ | ||
ββββ βββ βββββ βββ βββ βββ β βββββ β βββ β ββββ βββββββββ βββ β βββββ β | ||
βββ ββββββββ ββββββββ βββ βββ βββββ β ββββ βββββββββββ βββ βββ βββ βββββ | ||
ββββ ββββ ββ βββ βββ βββββββ βββ β β ββββββ βββ βββββββββ βββββββ βββ β | ||
βββββββ ββββ ββββββββββ ββββ ββββββββββββββββββββββββββββ ββ ββββββββ βββββββββββ | ||
βββ β β ββ ββ ββ β β ββ ββββββ ββ ββ βββ β β β βββββ ββ βββββ ββ ββββββ ββ β | ||
β β β β ββ ββ β β ββ β ββ β β ββ ββ β β β βββ β β ββ β ββ β ββ β β β | ||
β β β β ββ β β β β ββ β β β β β β ββ β β β ββ β β | ||
β β β β β β β β β β β β β β β β | ||
β`) | ||
if err := cli_utils.SetViperConfig(cmd); err != nil { | ||
return err | ||
} | ||
if err := cli_utils.BindReshareFlags(cmd); err != nil { | ||
return err | ||
} | ||
logger, err := cli_utils.SetGlobalLogger(cmd, "dkg-initiator") | ||
if err != nil { | ||
return err | ||
} | ||
defer func() { | ||
if err := cli_utils.Sync(logger); err != nil { | ||
log.Printf("Failed to sync logger: %v", err) | ||
} | ||
}() | ||
logger.Info("πͺ Initiator`s", zap.String("Version", cmd.Version)) | ||
opMap, err := cli_utils.LoadOperators(logger) | ||
if err != nil { | ||
logger.Fatal("π₯ Failed to load operators: ", zap.Error(err)) | ||
} | ||
oldOperatorIDs, err := cli_utils.StingSliceToUintArray(cli_utils.OperatorIDs) | ||
if err != nil { | ||
logger.Fatal("π₯ Failed to load participants: ", zap.Error(err)) | ||
} | ||
newOperatorIDs, err := cli_utils.StingSliceToUintArray(cli_utils.NewOperatorIDs) | ||
if err != nil { | ||
logger.Fatal("π₯ Failed to load new participants: ", zap.Error(err)) | ||
} | ||
// create a new ID for resharing | ||
id := spec.NewID() | ||
// create initiator instance | ||
dkgInitiator, err := initiator.New(opMap.Clone(), logger, cmd.Version, cli_utils.ClientCACertPath) | ||
if err != nil { | ||
return err | ||
} | ||
signedProofs, err := wire.LoadProofs(cli_utils.ProofsFilePath) | ||
if err != nil { | ||
logger.Fatal("π₯ Failed to read proofs json file:", zap.Error(err)) | ||
} | ||
ethNetwork := e2m_core.NetworkFromString(cli_utils.Network) | ||
if ethNetwork == "" { | ||
logger.Fatal("π₯ Cant recognize eth network") | ||
} | ||
// Open ethereum keystore | ||
jsonBytes, err := os.ReadFile(cli_utils.KeystorePath) | ||
if err != nil { | ||
return err | ||
} | ||
keyStorePassword, err := os.ReadFile(filepath.Clean(cli_utils.KeystorePass)) | ||
if err != nil { | ||
return fmt.Errorf("π₯ Error reading password file: %s", err) | ||
} | ||
sk, err := keystore.DecryptKey(jsonBytes, string(keyStorePassword)) | ||
if err != nil { | ||
return err | ||
} | ||
// Start the ceremony | ||
depositData, keyShares, proof, err := dkgInitiator.StartResharing(id, oldOperatorIDs, newOperatorIDs, signedProofs[0], sk.PrivateKey, ethNetwork, cli_utils.WithdrawAddress[:], cli_utils.OwnerAddress, cli_utils.Nonce) | ||
if err != nil { | ||
logger.Fatal("π₯ Failed to initiate DKG ceremony: ", zap.Error(err)) | ||
} | ||
var depositDataArr []*wire.DepositDataCLI | ||
var keySharesArr []*wire.KeySharesCLI | ||
var proofs [][]*wire.SignedProof | ||
depositDataArr = append(depositDataArr, depositData) | ||
keySharesArr = append(keySharesArr, keyShares) | ||
proofs = append(proofs, proof) | ||
// Save results | ||
logger.Info("π― All data is validated.") | ||
if err := cli_utils.WriteResults( | ||
logger, | ||
depositDataArr, | ||
keySharesArr, | ||
proofs, | ||
false, | ||
1, | ||
cli_utils.OwnerAddress, | ||
cli_utils.Nonce, | ||
cli_utils.WithdrawAddress, | ||
cli_utils.OutputPath, | ||
); err != nil { | ||
logger.Fatal("Could not save results", zap.Error(err)) | ||
} | ||
logger.Info("π Resharing ceremony completed") | ||
return nil | ||
}, | ||
} |
Oops, something went wrong.