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"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
"crypto/rand"
|
"encoding/hex"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
@ -15,7 +15,6 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
bls12381 "github.com/corestario/kyber/pairing/bls12381"
|
|
||||||
"github.com/depools/dc4bc/airgapped"
|
"github.com/depools/dc4bc/airgapped"
|
||||||
"github.com/depools/dc4bc/client/types"
|
"github.com/depools/dc4bc/client/types"
|
||||||
"github.com/depools/dc4bc/fsm/state_machines/dkg_proposal_fsm"
|
"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 {
|
if err = json.Unmarshal(msg.Data, &pubKeyReq); err != nil {
|
||||||
t.Fatalf("failed to unmarshal pubKey request: %v", err)
|
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",
|
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)
|
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 {
|
for dkgID, keyring := range keyrings {
|
||||||
fmt.Printf("DKG identifier: %s\n", dkgID)
|
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("-----------------------------------------------------")
|
fmt.Println("-----------------------------------------------------")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/hex"
|
"encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
prysmBLS "github.com/prysmaticlabs/prysm/shared/bls"
|
prysmBLS "github.com/prysmaticlabs/prysm/shared/bls"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
@ -15,7 +15,7 @@ func checkSignature() *cobra.Command {
|
||||||
Short: "checks a signature on prysm compatibility",
|
Short: "checks a signature on prysm compatibility",
|
||||||
Args: cobra.ExactArgs(1),
|
Args: cobra.ExactArgs(1),
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
sig, err := hex.DecodeString(args[0])
|
sig, err := base64.StdEncoding.DecodeString(args[0])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("failed to decode signature bytes from string: %v", err)
|
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",
|
Short: "checks a pubkey on prysm compatibility",
|
||||||
Args: cobra.ExactArgs(1),
|
Args: cobra.ExactArgs(1),
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
pubkey, err := hex.DecodeString(args[0])
|
pubkey, err := base64.StdEncoding.DecodeString(args[0])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("failed to decode pubkey bytes from string: %v", err)
|
log.Fatalf("failed to decode pubkey bytes from string: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ func verify() *cobra.Command {
|
||||||
Short: "verify signature with Prysm",
|
Short: "verify signature with Prysm",
|
||||||
Args: cobra.ExactArgs(3),
|
Args: cobra.ExactArgs(3),
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
sig, err := hex.DecodeString(args[0])
|
sig, err := base64.StdEncoding.DecodeString(args[0])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("failed to decode signature bytes from string: %v", err)
|
log.Fatalf("failed to decode signature bytes from string: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ func verify() *cobra.Command {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("failed to get prysm sig from bytes: %v", err)
|
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 {
|
if err != nil {
|
||||||
log.Fatalf("failed to decode pubkey bytes from string: %v", err)
|
log.Fatalf("failed to decode pubkey bytes from string: %v", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue