fix(bls12381): go build flags were not configured correctly. (#20752)

Co-authored-by: ocnc2 <169075746+ocnc2@users.noreply.github.com>
This commit is contained in:
Devon Bear 2024-06-24 03:54:34 -04:00 committed by GitHub
parent ef0c600d66
commit 600f7740cc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 17 additions and 8 deletions

View File

@ -1,8 +1,10 @@
package bls12_381
const (
// PrivKeyName is the name of the private key as it is stored in the keystore.
PrivKeyName = "cometbft/PrivKeyBls12_381"
PubKeyName = "cometbft/PubKeyBls12_381"
// PubKeyName is the name of the public key as it is stored in the keystore.
PubKeyName = "cometbft/PubKeyBls12_381"
// PubKeySize is the size, in bytes, of public keys as used in this package.
PubKeySize = 32
// PrivKeySize is the size, in bytes, of private keys as used in this package.
@ -12,9 +14,8 @@ const (
// SeedSize is the size, in bytes, of private key seeds. These are the
// private key representations used by RFC 8032.
SeedSize = 32
// MaxMsgLen defines the maximum length of the message bytes as passed to Sign.
MaxMsgLen = 32
// KeyType is the type of key this package provides.
KeyType = "bls12381"
)

View File

@ -1,3 +1,5 @@
//go:build !bls12381
package bls12_381
import (

View File

@ -36,13 +36,17 @@ func NewPrivateKeyFromBytes(bz []byte) (PrivKey, error) {
if err != nil {
return PrivKey{}, err
}
return secretKey.Marshal(), nil
return PrivKey{
Key: secretKey.Marshal(),
}, nil
}
// GenPrivKey generates a new key.
func GenPrivKey() (PrivKey, error) {
secretKey, err := bls12381.RandKey()
return PrivKey(secretKey.Marshal()), err
return PrivKey{
Key: secretKey.Marshal(),
}, err
}
// Bytes returns the byte representation of the Key.
@ -58,7 +62,9 @@ func (privKey PrivKey) PubKey() cryptotypes.PubKey {
return nil
}
return PubKey(secretKey.PublicKey().Marshal())
return &PubKey{
Key: secretKey.PublicKey().Marshal(),
}
}
// Equals returns true if two keys are equal and false otherwise.
@ -68,7 +74,7 @@ func (privKey PrivKey) Equals(other cryptotypes.LedgerPrivKey) bool {
// Type returns the type.
func (PrivKey) Type() string {
return keyType
return KeyType
}
// Sign signs the given byte array. If msg is larger than
@ -167,7 +173,7 @@ func (pubKey PubKey) Bytes() []byte {
// Type returns the key's type.
func (PubKey) Type() string {
return keyType
return KeyType
}
// Equals returns true if the other's type is the same and their bytes are deeply equal.