Skip to content

Commit

Permalink
Merge branch 'master' into bastian/migrate-deferred-contract-registers
Browse files Browse the repository at this point in the history
  • Loading branch information
Kay-Zee authored Nov 25, 2020
2 parents ffd0f0b + 741f40e commit 3498a3b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion cmd/bootstrap/cmd/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func readJSON(path string, target interface{}) {
}
err = json.Unmarshal(dat, target)
if err != nil {
log.Fatal().Err(err).Msg("cannot unmarshal json in file")
log.Fatal().Err(err).Msgf("cannot unmarshal json in file %s", path)
}
}

Expand Down
10 changes: 5 additions & 5 deletions crypto/bls.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,16 +193,16 @@ func (a *blsBLS12381Algo) decodePrivateKey(privateKeyBytes []byte) (PrivateKey,
// This function includes a membership check in G2
func (a *blsBLS12381Algo) decodePublicKey(publicKeyBytes []byte) (PublicKey, error) {
if len(publicKeyBytes) != pubKeyLengthBLSBLS12381 {
return nil, fmt.Errorf("the input length has to be equal to %d", pubKeyLengthBLSBLS12381)
return nil, fmt.Errorf("the input length has to be %d", pubKeyLengthBLSBLS12381)
}
var pk PubKeyBLSBLS12381
if readPointG2(&pk.point, publicKeyBytes) != nil {
return nil, errors.New("the input slice does not encode a public key")
return nil, errors.New("the input does not encode a BLS12-381 point")
}
if pk.point.checkMembershipG2() {
return &pk, nil
if !pk.point.checkMembershipG2() {
return nil, errors.New("the input does not encode a BLS12-381 point in the valid group")
}
return nil, errors.New("the public key is not a valid BLS12-381 curve key")
return &pk, nil
}

// PrKeyBLSBLS12381 is the private key of BLS using BLS12_381, it implements PrivateKey
Expand Down
8 changes: 4 additions & 4 deletions crypto/ecdsa.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,13 @@ func (a *ecdsaAlgo) rawDecodePrivateKey(der []byte) (PrivateKey, error) {
n := a.curve.Params().N
nlen := bitsToBytes(n.BitLen())
if len(der) != nlen {
return nil, errors.New("raw private key size is not valid")
return nil, fmt.Errorf("input has incorrect %s key size", a.algo)
}
var d big.Int
d.SetBytes(der)

if d.Cmp(n) >= 0 {
return nil, errors.New("raw public key value is not valid")
return nil, fmt.Errorf("input is not a valid %s key", a.algo)
}

priv := goecdsa.PrivateKey{
Expand All @@ -214,7 +214,7 @@ func (a *ecdsaAlgo) rawDecodePublicKey(der []byte) (PublicKey, error) {
p := (a.curve.Params().P)
plen := bitsToBytes(p.BitLen())
if len(der) != 2*plen {
return nil, errors.New("raw public key size is not valid")
return nil, fmt.Errorf("input has incorrect %s key size", a.algo)
}
var x, y big.Int
x.SetBytes(der[:plen])
Expand All @@ -223,7 +223,7 @@ func (a *ecdsaAlgo) rawDecodePublicKey(der []byte) (PublicKey, error) {
// all the curves supported for now have a cofactor equal to 1,
// so that IsOnCurve guarantees the point is on the right subgroup.
if x.Cmp(p) >= 0 || y.Cmp(p) >= 0 || !a.curve.IsOnCurve(&x, &y) {
return nil, errors.New("raw public key value is not valid")
return nil, fmt.Errorf("input is not a valid %s key", a.algo)
}

pk := goecdsa.PublicKey{
Expand Down

0 comments on commit 3498a3b

Please sign in to comment.