-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Re-sign and re-share using proofs and EIP1271 signature #100
Merged
Merged
Changes from 31 commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
2fe1d0f
initial resigning
pavelkrolevets f329be8
add routes + flow
pavelkrolevets 6a8f698
working resigning with result validation
pavelkrolevets c71c54b
fix tests
pavelkrolevets 49ee5e9
add integration tests for resiging
pavelkrolevets 192e714
update integration tests to use cli commands
pavelkrolevets 798333c
initial spec alignment + reshare module
pavelkrolevets db83ed4
working resharing
pavelkrolevets 323a9de
add EIP1271 owner signature verification
pavelkrolevets b07da73
update resharing + add docker demo for resharing
pavelkrolevets 2b994c0
add reshare threshold + integration tests
pavelkrolevets 94c75d9
add threshold integration tests
pavelkrolevets 49a58fb
fix logic at message processing
pavelkrolevets 7cf7e54
add eip1271 sig integration tests
pavelkrolevets 01449eb
add eip1271 sig verification to resign + integration/docker tests
pavelkrolevets d160313
add eip1271 sig resign test + bulk tests
pavelkrolevets cf71c67
fix/update unit + integration tests
pavelkrolevets 2ab1d07
Merge branch 'unstable' into re-sharing
pavelkrolevets e3599e9
update tests + fix bls set
pavelkrolevets a805153
PR comments resolved #1
pavelkrolevets 66aa776
PR comments resolved #2
pavelkrolevets 69a6564
PR comments resolved #3
pavelkrolevets 2588104
PR comments resolved #4
pavelkrolevets 67f0d5d
Merge branch 're-sign' into re-sharing
pavelkrolevets 9de0d2e
PR comments resolved #5
pavelkrolevets 48e52ed
PR comments resolved #6
pavelkrolevets a6600b4
fix tests + docker build update
pavelkrolevets 30421ef
update CI
pavelkrolevets b596736
fix test
pavelkrolevets b7507a8
lint
pavelkrolevets 7b5def5
add more reshare integration tests
pavelkrolevets 07857e5
go 1.23
pavelkrolevets 94936c0
add unit tests for join/disjoin sets of operators
pavelkrolevets cd66782
lint
pavelkrolevets f28b9cd
add proofs validation before sending + more reshare threshold integra…
pavelkrolevets 928a72f
fix unit tests
pavelkrolevets 0f675a5
lint
pavelkrolevets 9af8315
fix review comments
MatusKysel 2c789e9
remove typo and unused struct
MatusKysel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should make this fail on invalid input (now it fails silently with unknown outcomes)