Skip to content

Commit

Permalink
Move bls public_test.go back into the bls package
Browse files Browse the repository at this point in the history
  • Loading branch information
richardpringle committed Jan 14, 2025
1 parent a723269 commit 3c1ce6c
Showing 1 changed file with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.

package blstest
package bls

import (
"encoding/base64"
Expand All @@ -10,15 +10,14 @@ import (
"github.com/stretchr/testify/require"

"github.com/ava-labs/avalanchego/utils"
"github.com/ava-labs/avalanchego/utils/crypto/bls"
)

func TestPublicKeyFromCompressedBytesWrongSize(t *testing.T) {
require := require.New(t)

pkBytes := utils.RandomBytes(bls.PublicKeyLen + 1)
_, err := bls.PublicKeyFromCompressedBytes(pkBytes)
require.ErrorIs(err, bls.ErrFailedPublicKeyDecompress)
pkBytes := utils.RandomBytes(PublicKeyLen + 1)
_, err := PublicKeyFromCompressedBytes(pkBytes)
require.ErrorIs(err, ErrFailedPublicKeyDecompress)
}

func TestPublicKeyBytes(t *testing.T) {
Expand All @@ -27,10 +26,10 @@ func TestPublicKeyBytes(t *testing.T) {
pkBytes, err := base64.StdEncoding.DecodeString("h5qt9SPxaCo+vOx6sn+QkkpP7Y40Yja7SEAs2MGb/mZT7oKTWgLogjy5c4/wWIGC")
require.NoError(err)

pk, err := bls.PublicKeyFromCompressedBytes(pkBytes)
pk, err := PublicKeyFromCompressedBytes(pkBytes)
require.NoError(err)

pk2Bytes := bls.PublicKeyToCompressedBytes(pk)
pk2Bytes := PublicKeyToCompressedBytes(pk)

require.Equal(pkBytes, pk2Bytes)
}
Expand All @@ -41,13 +40,13 @@ func TestAggregatePublicKeysNoop(t *testing.T) {
pkBytes, err := base64.StdEncoding.DecodeString("h5qt9SPxaCo+vOx6sn+QkkpP7Y40Yja7SEAs2MGb/mZT7oKTWgLogjy5c4/wWIGC")
require.NoError(err)

pk, err := bls.PublicKeyFromCompressedBytes(pkBytes)
pk, err := PublicKeyFromCompressedBytes(pkBytes)
require.NoError(err)

aggPK, err := bls.AggregatePublicKeys([]*bls.PublicKey{pk})
aggPK, err := AggregatePublicKeys([]*PublicKey{pk})
require.NoError(err)

aggPKBytes := bls.PublicKeyToCompressedBytes(aggPK)
aggPKBytes := PublicKeyToCompressedBytes(aggPK)
require.NoError(err)

require.Equal(pk, aggPK)
Expand Down

0 comments on commit 3c1ce6c

Please sign in to comment.