Skip to content
Snippets Groups Projects
Unverified Commit 05dfd1a9 authored by Hans Moog's avatar Hans Moog Committed by GitHub
Browse files

Fix: fixed some typos and empty line between godoc comments (#308)

parent feb06868
No related branches found
No related tags found
No related merge requests found
...@@ -2,14 +2,16 @@ package signaturescheme ...@@ -2,14 +2,16 @@ package signaturescheme
import ( import (
"fmt" "fmt"
"github.com/iotaledger/goshimmer/packages/binary/valuetransfer/address" "math/rand"
"github.com/mr-tron/base58" "github.com/mr-tron/base58"
"go.dedis.ch/kyber/v3" "go.dedis.ch/kyber/v3"
"go.dedis.ch/kyber/v3/pairing/bn256" "go.dedis.ch/kyber/v3/pairing/bn256"
"go.dedis.ch/kyber/v3/sign" "go.dedis.ch/kyber/v3/sign"
"go.dedis.ch/kyber/v3/sign/bdn" "go.dedis.ch/kyber/v3/sign/bdn"
"go.dedis.ch/kyber/v3/util/random" "go.dedis.ch/kyber/v3/util/random"
"math/rand"
"github.com/iotaledger/goshimmer/packages/binary/valuetransfer/address"
) )
// BLS implements BLS signature scheme which is robust against rogue public key attacks, or BDN // BLS implements BLS signature scheme which is robust against rogue public key attacks, or BDN
...@@ -19,7 +21,6 @@ import ( ...@@ -19,7 +21,6 @@ import (
// This package doesn't implement any threshold signature related primitives. // This package doesn't implement any threshold signature related primitives.
// it only contains what is needed for the node to check validity of the BLS signatures against addresses // it only contains what is needed for the node to check validity of the BLS signatures against addresses
// and also minimum signing required for testing // and also minimum signing required for testing
var suite = bn256.NewSuite() var suite = bn256.NewSuite()
const ( const (
...@@ -31,7 +32,6 @@ const ( ...@@ -31,7 +32,6 @@ const (
// ---------------- implements SignatureScheme interface // ---------------- implements SignatureScheme interface
// blsSignatureScheme defines an interface for the key pairs of BLS signatures. // blsSignatureScheme defines an interface for the key pairs of BLS signatures.
type blsSignatureScheme struct { type blsSignatureScheme struct {
priKey kyber.Scalar priKey kyber.Scalar
pubKey kyber.Point pubKey kyber.Point
...@@ -43,7 +43,6 @@ var rnd = random.New(rand.New(rand.NewSource(42))) ...@@ -43,7 +43,6 @@ var rnd = random.New(rand.New(rand.NewSource(42)))
// RandBLS creates a RANDOM instance of a signature scheme, that is used to sign the corresponding address. // RandBLS creates a RANDOM instance of a signature scheme, that is used to sign the corresponding address.
// mostly intended for testing. // mostly intended for testing.
// only for testing: each time same sequence! // only for testing: each time same sequence!
func RandBLS() SignatureScheme { func RandBLS() SignatureScheme {
ret := &blsSignatureScheme{} ret := &blsSignatureScheme{}
ret.priKey, ret.pubKey = bdn.NewKeyPair(suite, rnd) ret.priKey, ret.pubKey = bdn.NewKeyPair(suite, rnd)
...@@ -52,7 +51,6 @@ func RandBLS() SignatureScheme { ...@@ -52,7 +51,6 @@ func RandBLS() SignatureScheme {
// BLS creates an instance of BLS signature scheme // BLS creates an instance of BLS signature scheme
// from given private and public keys in marshaled binary form // from given private and public keys in marshaled binary form
func BLS(priKey, pubKey []byte) (SignatureScheme, error) { func BLS(priKey, pubKey []byte) (SignatureScheme, error) {
if len(priKey) != BLS_PRIVATE_KEY_SIZE || len(pubKey) != BLS_PUBLIC_KEY_SIZE { if len(priKey) != BLS_PRIVATE_KEY_SIZE || len(pubKey) != BLS_PUBLIC_KEY_SIZE {
return nil, fmt.Errorf("wrong key size") return nil, fmt.Errorf("wrong key size")
...@@ -117,7 +115,7 @@ func BLSSignatureFromBytes(data []byte) (result *blsSignature, err error, consum ...@@ -117,7 +115,7 @@ func BLSSignatureFromBytes(data []byte) (result *blsSignature, err error, consum
consumedBytes = 0 consumedBytes = 0
err = nil err = nil
if len(data) < BLS_FULL_SIGNATURE_SIZE { if len(data) < BLS_FULL_SIGNATURE_SIZE {
err = fmt.Errorf("marshalled BLS signature size must be %d", BLS_FULL_SIGNATURE_SIZE) err = fmt.Errorf("marshaled BLS signature size must be %d", BLS_FULL_SIGNATURE_SIZE)
return return
} }
if data[0] != address.VERSION_BLS { if data[0] != address.VERSION_BLS {
......
package signaturescheme package signaturescheme
import ( import (
"github.com/magiconair/properties/assert"
"testing" "testing"
"github.com/magiconair/properties/assert"
) )
var dataToSign = []byte("Hello Boneh-Lynn-Shacham (BLS) --> Boneh-Drijvers-Neven (BDN)") var dataToSign = []byte("Hello Boneh-Lynn-Shacham (BLS) --> Boneh-Drijvers-Neven (BDN)")
func TestBLS_base(t *testing.T) { func TestBLS_base(t *testing.T) {
blsSigScheme := RandBLS() blsSigScheme := RandBLS()
t.Logf("generating random BLS signature scheme: %s\n", blsSigScheme.(*blsSignatureScheme).String()) t.Logf("generating random BLS signature scheme: %s\n", blsSigScheme.(*blsSignatureScheme).String())
signature := blsSigScheme.Sign(dataToSign) signature := blsSigScheme.Sign(dataToSign)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment