Skip to content

Commit

Permalink
Lint fix for sign package
Browse files Browse the repository at this point in the history
  • Loading branch information
K1li4nL committed May 31, 2024
1 parent 44e1918 commit 6b48bd8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 14 deletions.
8 changes: 4 additions & 4 deletions sign/bls/bls.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (s *scheme) Sign(private kyber.Scalar, msg []byte) ([]byte, error) {
return sig, nil
}

func (s *scheme) Verify(X kyber.Point, msg, sig []byte) error {
func (s *scheme) Verify(x kyber.Point, msg, sig []byte) error {
hashable, ok := s.sigGroup.Point().(hashablePoint)
if !ok {
return errors.New("bls: point needs to implement hashablePoint")
Expand All @@ -93,7 +93,7 @@ func (s *scheme) Verify(X kyber.Point, msg, sig []byte) error {
if err := sigPoint.UnmarshalBinary(sig); err != nil {
return err
}
if !s.pairing(X, HM, sigPoint) {
if !s.pairing(x, HM, sigPoint) {
return errors.New("bls: invalid signature")
}
return nil
Expand All @@ -111,9 +111,9 @@ func (s *scheme) AggregateSignatures(sigs ...[]byte) ([]byte, error) {
return sig.MarshalBinary()
}

func (s *scheme) AggregatePublicKeys(Xs ...kyber.Point) kyber.Point {
func (s *scheme) AggregatePublicKeys(xs ...kyber.Point) kyber.Point {
aggregated := s.keyGroup.Point()
for _, X := range Xs {
for _, X := range xs {
aggregated.Add(aggregated, X)
}
return aggregated
Expand Down
3 changes: 2 additions & 1 deletion sign/bls/bls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ func BenchmarkBLSVerifyAggregate(b *testing.B) {
sig2, err := scheme.Sign(private2, msg)
require.Nil(b, err)
sig, err := scheme.AggregateSignatures(sig1, sig2)
require.Nil(b, err)
key := scheme.AggregatePublicKeys(public1, public2)
b.ResetTimer()
for i := 0; i < b.N; i++ {
Expand All @@ -242,7 +243,7 @@ func BenchmarkBLSVerifyBatchVerify(b *testing.B) {
private, public := scheme.NewKeyPair(random.New())
privates[i] = private
publics[i] = public
msg := make([]byte, 64, 64)
msg := make([]byte, 64)
_, err := rand.Read(msg)
require.Nil(b, err)
msgs[i] = msg
Expand Down
4 changes: 0 additions & 4 deletions sign/cosi/cosi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,9 @@ func TestMask(t *testing.T) {
n := 17

// Generate key pairs
var kps []*key.Pair
var privates []kyber.Scalar
var publics []kyber.Point
for i := 0; i < n; i++ {
kp := key.NewKeyPair(testSuite)
kps = append(kps, kp)
privates = append(privates, kp.Private)
publics = append(publics, kp.Public)
}

Expand Down
10 changes: 5 additions & 5 deletions sign/schnorr/schnorr.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,25 @@ type Suite interface {
kyber.Random
}

type SchnorrScheme struct {
type Scheme struct {
s Suite
}

func NewScheme(s Suite) sign.Scheme {
return &SchnorrScheme{s}
return &Scheme{s}
}

func (s *SchnorrScheme) NewKeyPair(random cipher.Stream) (kyber.Scalar, kyber.Point) {
func (s *Scheme) NewKeyPair(random cipher.Stream) (kyber.Scalar, kyber.Point) {
priv := s.s.Scalar().Pick(random)
pub := s.s.Point().Mul(priv, nil)
return priv, pub
}

func (s *SchnorrScheme) Sign(private kyber.Scalar, msg []byte) ([]byte, error) {
func (s *Scheme) Sign(private kyber.Scalar, msg []byte) ([]byte, error) {
return Sign(s.s, private, msg)
}

func (s *SchnorrScheme) Verify(public kyber.Point, msg, sig []byte) error {
func (s *Scheme) Verify(public kyber.Point, msg, sig []byte) error {
return Verify(s.s, public, msg, sig)
}

Expand Down

0 comments on commit 6b48bd8

Please sign in to comment.