Skip to content

Commit

Permalink
add --hex-entropy flag
Browse files Browse the repository at this point in the history
Signed-off-by: Ignacio Hagopian <[email protected]>
  • Loading branch information
jsign committed Mar 10, 2023
1 parent 5a7a8a1 commit 278affd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ The CLI tool provides an _offline_ subcommand:

You might not need `kzgcli offline download-state` you're pulling the current state out-of-band (e.g: direct download or the sequencer sent it to you). If that isn't the case, you can use it in an environment that has internet access (not necessarily your contribution environment).

The `kzgcli offline contribute` command doesn't require internet access, and will probably be the only command you'll run in your constrained environment. This command also accepts the `--urlrand` flag if you want to pull entropy from an external source of randomness available in your environment.
The `kzgcli offline contribute` command doesn't require internet access, and will probably be the only command you'll run in your constrained environment. This command also accepts the `--urlrand` and `--hex-entropy` flag if you want to pull entropy from an external source of randomness available in your environment or provided directly to the client, respectively.

The `kzgcli offline send-contribution` command sends the previously generated file by `kzgcli offline contribute` to the sequencer.

Expand Down
1 change: 1 addition & 0 deletions cmd/kzgcli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ func init() {

// Offline commands.
offlineContributeCmd.Flags().String("urlrand", "", "Pull entropy from an HTTP endpoint mixed with local CSRNG")
offlineContributeCmd.Flags().String("hex-entropy", "", "Hex encoded entropy to be mixed with local CSRNG")
offlineSendContributionCmd.Flags().String("session-id", "", "The sesion id as generated in the 'session_id' field in the authentication process")

rootCmd.AddCommand(offlineCmd)
Expand Down
14 changes: 14 additions & 0 deletions cmd/kzgcli/offline_contribute.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package main

import (
"encoding/hex"
"fmt"
"io"
"log"
"os"
"strings"

"github.com/jsign/go-kzg-ceremony-client/contribution"
"github.com/jsign/go-kzg-ceremony-client/extrand"
Expand Down Expand Up @@ -33,6 +35,18 @@ var offlineContributeCmd = &cobra.Command{
fmt.Printf("Got it! (length: %d)\n", len(urlBytes))
extRandomness = append(extRandomness, urlBytes)
}
hexEntropy, err := cmd.Flags().GetString("hex-entropy")
if err != nil {
log.Fatalf("get --hex-entropy flag value: %s", err)
}
if hexEntropy != "" {
hexEntropy := strings.TrimPrefix(hexEntropy, "0x")
hb, err := hex.DecodeString(hexEntropy)
if err != nil {
log.Fatalf("decoding hex entropy: %s", err)
}
extRandomness = append(extRandomness, hb)
}

fmt.Printf("Opening and parsing offline current state file...")
f, err := os.Open(args[0])
Expand Down

0 comments on commit 278affd

Please sign in to comment.