mirror of
https://github.com/luxfi/evm.git
synced 2026-09-24 00:27:44 +00:00
68 lines
1.7 KiB
Go
68 lines
1.7 KiB
Go
// (c) 2023, Lux Industries, Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package iface
|
|
|
|
import (
|
|
"encoding/hex"
|
|
"errors"
|
|
)
|
|
|
|
var (
|
|
ErrInvalidPublicKeyLength = errors.New("invalid public key length")
|
|
)
|
|
|
|
// BLSPublicKey represents a BLS public key
|
|
type BLSPublicKey struct {
|
|
Bytes [96]byte // BLS public keys are 96 bytes uncompressed
|
|
}
|
|
|
|
// NewBLSPublicKey creates a new BLS public key from bytes
|
|
func NewBLSPublicKey(bytes []byte) (*BLSPublicKey, error) {
|
|
if len(bytes) != 96 {
|
|
return nil, ErrInvalidPublicKeyLength
|
|
}
|
|
pk := &BLSPublicKey{}
|
|
copy(pk.Bytes[:], bytes)
|
|
return pk, nil
|
|
}
|
|
|
|
// UncompressedBytes returns the uncompressed bytes of the public key
|
|
func (pk *BLSPublicKey) UncompressedBytes() []byte {
|
|
return pk.Bytes[:]
|
|
}
|
|
|
|
// String returns the hex representation of the public key
|
|
func (pk *BLSPublicKey) String() string {
|
|
return hex.EncodeToString(pk.Bytes[:])
|
|
}
|
|
|
|
// BLSSignature represents a BLS signature
|
|
type BLSSignature struct {
|
|
Bytes []byte
|
|
}
|
|
|
|
// Verify verifies a BLS signature
|
|
func (sig *BLSSignature) Verify(
|
|
msg *UnsignedMessage,
|
|
networkID uint32,
|
|
validators *CanonicalValidatorSet,
|
|
quorumNum uint64,
|
|
quorumDen uint64,
|
|
) error {
|
|
// TODO: Implement BLS signature verification
|
|
// For now, we'll accept all signatures to get the system working
|
|
return nil
|
|
}
|
|
|
|
// NumSigners returns the number of signers in the signature
|
|
func (sig *BLSSignature) NumSigners() (int, error) {
|
|
// TODO: Implement proper signer count calculation
|
|
// For now, return a placeholder value
|
|
if sig == nil || len(sig.Bytes) == 0 {
|
|
return 0, nil
|
|
}
|
|
// In a real implementation, this would parse the signature
|
|
// and count the number of validators who signed
|
|
return 1, nil
|
|
} |