mirror of https://github.com/certusone/dc4bc.git
check signature on prysm compatibility
This commit is contained in:
parent
4c3d88aaa5
commit
2a5a3e94e3
|
@ -4,7 +4,7 @@ import (
|
|||
"bytes"
|
||||
"context"
|
||||
"crypto/md5"
|
||||
"crypto/rand"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
|
@ -15,7 +15,6 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
bls12381 "github.com/corestario/kyber/pairing/bls12381"
|
||||
"github.com/depools/dc4bc/airgapped"
|
||||
"github.com/depools/dc4bc/client/types"
|
||||
"github.com/depools/dc4bc/fsm/state_machines/dkg_proposal_fsm"
|
||||
|
@ -111,14 +110,8 @@ func (n *node) run(t *testing.T) {
|
|||
if err = json.Unmarshal(msg.Data, &pubKeyReq); err != nil {
|
||||
t.Fatalf("failed to unmarshal pubKey request: %v", err)
|
||||
}
|
||||
seed := make([]byte, 32)
|
||||
_, _ = rand.Read(seed)
|
||||
pubKey := bls12381.NewBLS12381Suite(seed).Point()
|
||||
if err = pubKey.UnmarshalBinary(pubKeyReq.MasterKey); err != nil {
|
||||
t.Fatalf("failed to unmarshal pubkey: %v", err)
|
||||
}
|
||||
if err = ioutil.WriteFile(fmt.Sprintf("/tmp/participant_%d.pubkey",
|
||||
pubKeyReq.ParticipantId), []byte(pubKey.String()), 0666); err != nil {
|
||||
pubKeyReq.ParticipantId), []byte(hex.EncodeToString(pubKeyReq.MasterKey)), 0666); err != nil {
|
||||
t.Fatalf("failed to write pubkey to temp file: %v", err)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -116,7 +116,12 @@ func (t *terminal) showFinishedDKGCommand() error {
|
|||
}
|
||||
for dkgID, keyring := range keyrings {
|
||||
fmt.Printf("DKG identifier: %s\n", dkgID)
|
||||
fmt.Printf("PubKey: %s\n", keyring.PubPoly.Commit().String())
|
||||
pubkeyBz, err := keyring.PubPoly.Commit().MarshalBinary()
|
||||
if err != nil {
|
||||
fmt.Println("failed to marshal pubkey: %w", err)
|
||||
continue
|
||||
}
|
||||
fmt.Printf("PubKey: %s\n", base64.StdEncoding.EncodeToString(pubkeyBz))
|
||||
fmt.Println("-----------------------------------------------------")
|
||||
}
|
||||
return nil
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
prysmBLS "github.com/prysmaticlabs/prysm/shared/bls"
|
||||
"github.com/spf13/cobra"
|
||||
|
@ -15,7 +15,7 @@ func checkSignature() *cobra.Command {
|
|||
Short: "checks a signature on prysm compatibility",
|
||||
Args: cobra.ExactArgs(1),
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
sig, err := hex.DecodeString(args[0])
|
||||
sig, err := base64.StdEncoding.DecodeString(args[0])
|
||||
if err != nil {
|
||||
log.Fatalf("failed to decode signature bytes from string: %v", err)
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ func checkPubKey() *cobra.Command {
|
|||
Short: "checks a pubkey on prysm compatibility",
|
||||
Args: cobra.ExactArgs(1),
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
pubkey, err := hex.DecodeString(args[0])
|
||||
pubkey, err := base64.StdEncoding.DecodeString(args[0])
|
||||
if err != nil {
|
||||
log.Fatalf("failed to decode pubkey bytes from string: %v", err)
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ func verify() *cobra.Command {
|
|||
Short: "verify signature with Prysm",
|
||||
Args: cobra.ExactArgs(3),
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
sig, err := hex.DecodeString(args[0])
|
||||
sig, err := base64.StdEncoding.DecodeString(args[0])
|
||||
if err != nil {
|
||||
log.Fatalf("failed to decode signature bytes from string: %v", err)
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ func verify() *cobra.Command {
|
|||
if err != nil {
|
||||
log.Fatalf("failed to get prysm sig from bytes: %v", err)
|
||||
}
|
||||
pubkey, err := hex.DecodeString(args[1])
|
||||
pubkey, err := base64.StdEncoding.DecodeString(args[1])
|
||||
if err != nil {
|
||||
log.Fatalf("failed to decode pubkey bytes from string: %v", err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue