Update Phore Dependency to the latest version (#2792)

* add new changes

* fix typos
This commit is contained in:
Nishant Das
2019-06-13 00:06:39 +08:00
committed by Raul Jordan
parent d48e0925d0
commit 663490ee1f
9 changed files with 23 additions and 46 deletions

View File

@@ -958,7 +958,7 @@ go_repository(
go_repository(
name = "com_github_phoreproject_bls",
commit = "0b6cefc7f7eee050e3ac6d66d66ae8e469a4fbf1",
commit = "b495094dc72c7043b549f511a798391201624b14",
importpath = "github.com/phoreproject/bls",
)

View File

@@ -11,7 +11,6 @@ go_library(
"//beacon-chain/gateway:go_default_library",
"@com_github_joonix_log//:go_default_library",
"@com_github_sirupsen_logrus//:go_default_library",
"@grpc_ecosystem_grpc_gateway//runtime:go_default_library",
],
)

View File

@@ -6,33 +6,11 @@ import (
"fmt"
"net/http"
gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime"
joonix "github.com/joonix/log"
"github.com/prysmaticlabs/prysm/beacon-chain/gateway"
"github.com/sirupsen/logrus"
)
// Endpoint describes a gRPC endpoint
type Endpoint struct {
Network, Addr string
}
// Options is a set of options to be passed to Run
type Options struct {
// Addr is the address to listen
Addr string
// GRPCServer defines an endpoint of a gRPC service
GRPCServer Endpoint
// SwaggerDir is a path to a directory from which the server
// serves swagger specs.
SwaggerDir string
// Mux is a list of options to be passed to the grpc-gateway multiplexer
Mux []gwruntime.ServeMuxOption
}
var (
beaconRPC = flag.String("beacon-rpc", "localhost:4000", "Beacon chain gRPC endpoint")
port = flag.Int("port", 8000, "Port to serve on")

View File

@@ -106,7 +106,7 @@ func TestListenForStateInitialization_ContextCancelled(t *testing.T) {
<-exitRoutine
if sq.ctx.Done() == nil {
t.Error("Despite context being cancelled, the done channel is nil")
t.Error("Despite context being canceled, the done channel is nil")
}
}

View File

@@ -7,7 +7,7 @@ go_library(
visibility = ["//visibility:public"],
deps = [
"//shared/bytesutil:go_default_library",
"@com_github_phoreproject_bls//:go_default_library",
"@com_github_phoreproject_bls//g1pubs:go_default_library",
],
)

View File

@@ -7,28 +7,28 @@ import (
"fmt"
"io"
gobls "github.com/phoreproject/bls"
g1 "github.com/phoreproject/bls/g1pubs"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
)
// Signature used in the BLS signature scheme.
type Signature struct {
val *gobls.Signature
val *g1.Signature
}
// SecretKey used in the BLS signature scheme.
type SecretKey struct {
val *gobls.SecretKey
val *g1.SecretKey
}
// PublicKey used in the BLS signature scheme.
type PublicKey struct {
val *gobls.PublicKey
val *g1.PublicKey
}
// RandKey creates a new private key using a random method provided as an io.Reader.
func RandKey(r io.Reader) (*SecretKey, error) {
k, err := gobls.RandKey(r)
k, err := g1.RandKey(r)
if err != nil {
return nil, fmt.Errorf("could not initialize secret key: %v", err)
}
@@ -41,13 +41,13 @@ func SecretKeyFromBytes(priv []byte) (*SecretKey, error) {
return nil, fmt.Errorf("expected byte slice of length 32, received: %d", len(priv))
}
k := bytesutil.ToBytes32(priv)
return &SecretKey{val: gobls.DeserializeSecretKey(k)}, nil
return &SecretKey{val: g1.DeserializeSecretKey(k)}, nil
}
// PublicKeyFromBytes creates a BLS public key from a byte slice.
func PublicKeyFromBytes(pub []byte) (*PublicKey, error) {
b := bytesutil.ToBytes96(pub)
k, err := gobls.DeserializePublicKey(b)
b := bytesutil.ToBytes48(pub)
k, err := g1.DeserializePublicKey(b)
if err != nil {
return nil, fmt.Errorf("could not unmarshal bytes into public key: %v", err)
}
@@ -56,8 +56,8 @@ func PublicKeyFromBytes(pub []byte) (*PublicKey, error) {
// SignatureFromBytes creates a BLS signature from a byte slice.
func SignatureFromBytes(sig []byte) (*Signature, error) {
b := bytesutil.ToBytes48(sig)
s, err := gobls.DeserializeSignature(b)
b := bytesutil.ToBytes96(sig)
s, err := g1.DeserializeSignature(b)
if err != nil {
return nil, fmt.Errorf("could not unmarshal bytes into signature: %v", err)
}
@@ -66,12 +66,12 @@ func SignatureFromBytes(sig []byte) (*Signature, error) {
// PublicKey obtains the public key corresponding to the BLS secret key.
func (s *SecretKey) PublicKey() *PublicKey {
return &PublicKey{val: gobls.PrivToPub(s.val)}
return &PublicKey{val: g1.PrivToPub(s.val)}
}
// Sign a message using a secret key - in a beacon/validator client,
func (s *SecretKey) Sign(msg []byte, domain uint64) *Signature {
sig := gobls.Sign(msg, s.val, domain)
sig := g1.SignWithDomain(bytesutil.ToBytes32(msg), s.val, domain)
return &Signature{val: sig}
}
@@ -96,18 +96,18 @@ func (p *PublicKey) Aggregate(p2 *PublicKey) *PublicKey {
// Verify a bls signature given a public key, a message, and a domain.
func (s *Signature) Verify(msg []byte, pub *PublicKey, domain uint64) bool {
return gobls.Verify(msg, pub.val, s.val, domain)
return g1.VerifyWithDomain(bytesutil.ToBytes32(msg), pub.val, s.val, domain)
}
// VerifyAggregate verifies each public key against a message.
// This is vulnerable to rogue public-key attack. Each user must
// provide a proof-of-knowledge of the public key.
func (s *Signature) VerifyAggregate(pubKeys []*PublicKey, msg []byte, domain uint64) bool {
var keys []*gobls.PublicKey
var keys []*g1.PublicKey
for _, v := range pubKeys {
keys = append(keys, v.val)
}
return s.val.VerifyAggregateCommon(keys, msg, domain)
return s.val.VerifyAggregateCommonWithDomain(keys, bytesutil.ToBytes32(msg), domain)
}
// Marshal a signature into a byte slice.
@@ -118,9 +118,9 @@ func (s *Signature) Marshal() []byte {
// AggregateSignatures converts a list of signatures into a single, aggregated sig.
func AggregateSignatures(sigs []*Signature) *Signature {
var ss []*gobls.Signature
var ss []*g1.Signature
for _, v := range sigs {
ss = append(ss, v.val)
}
return &Signature{val: gobls.AggregateSignatures(ss)}
return &Signature{val: g1.AggregateSignatures(ss)}
}

View File

@@ -8,7 +8,7 @@ import (
)
var (
maxProcsMetric = promauto.NewGaugeFunc(prometheus.GaugeOpts{
_ = promauto.NewGaugeFunc(prometheus.GaugeOpts{
Name: "go_maxprocs",
Help: "The result of runtime.GOMAXPROCS(0)",
}, func() float64 {

View File

@@ -28,6 +28,6 @@ func TestLifecycle(t *testing.T) {
// The context should have been canceled.
if s.ctx.Err() == nil {
t.Error("Context was not cancelled")
t.Error("Context was not canceled")
}
}

View File

@@ -62,7 +62,7 @@ func TestStop_CancelsContext(t *testing.T) {
select {
case <-time.After(1 * time.Second):
t.Error("ctx not cancelled within 1s")
t.Error("ctx not canceled within 1s")
case <-vs.ctx.Done():
}
}