Skip to content

Commit

Permalink
remove randomness from initiator ceremony dir name
Browse files Browse the repository at this point in the history
  • Loading branch information
moshe-blox committed Mar 19, 2024
1 parent f83043a commit 84fe8fc
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
1 change: 1 addition & 0 deletions cli/initiator/initiator.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ var StartDKG = &cobra.Command{
depositDataArr,
keySharesArr,
proofs,
false,
int(cli_utils.Validators),
cli_utils.OwnerAddress,
cli_utils.Nonce,
Expand Down
13 changes: 9 additions & 4 deletions cli/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ func WriteResults(
depositDataArr []*wire.DepositDataCLI,
keySharesArr []*wire.KeySharesCLI,
proofs [][]*wire.SignedProof,
withRandomness bool,
expectedValidatorCount int,
expectedOwnerAddress common.Address,
expectedOwnerNonce uint64,
Expand Down Expand Up @@ -448,11 +449,15 @@ func WriteResults(

// Create the ceremony directory.
timestamp := time.Now().UTC().Format("2006-01-02--15-04-05.000")
randomness := make([]byte, 4)
if _, err := rand.Read(randomness); err != nil {
return fmt.Errorf("failed to generate randomness: %w", err)
dirName := fmt.Sprintf("ceremony-%s", timestamp)
if withRandomness {
randomness := make([]byte, 4)
if _, err := rand.Read(randomness); err != nil {
return fmt.Errorf("failed to generate randomness: %w", err)
}
dirName = fmt.Sprintf("%s--%x", dirName, randomness)
}
dir := filepath.Join(outputPath, fmt.Sprintf("ceremony-%s--%x", timestamp, randomness))
dir := filepath.Join(outputPath, dirName)
err = os.Mkdir(dir, os.ModePerm)
if os.IsExist(err) {
return fmt.Errorf("ceremony directory already exists: %w", err)
Expand Down
14 changes: 12 additions & 2 deletions pkgs/operator/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,18 @@ func (s *Switch) SaveResultData(incMsg *wire.SignedTransport, outputPath string)
if withdrawPrefix != crypto.ETH1WithdrawalPrefixByte {
return fmt.Errorf("invalid withdrawal prefix: %x", withdrawPrefix)
}
return cli_utils.WriteResults(s.Logger, depositDataArr, keySharesArr, proofsArr,
1, common.HexToAddress(keySharesArr[0].Shares[0].OwnerAddress), keySharesArr[0].Shares[0].OwnerNonce, common.BytesToAddress(withdrawAddress), outputPath)
return cli_utils.WriteResults(
s.Logger,
depositDataArr,
keySharesArr,
proofsArr,
true,
1,
common.HexToAddress(keySharesArr[0].Shares[0].OwnerAddress),
keySharesArr[0].Shares[0].OwnerNonce,
common.BytesToAddress(withdrawAddress),
outputPath,
)
}

func (s *Switch) VerifyIncomingMessage(incMsg *wire.SignedTransport) (uint64, error) {
Expand Down

0 comments on commit 84fe8fc

Please sign in to comment.