Files
evm/warp/bls_adapter.go
zeekay 170c1ba5f8 refactor: remove warp aliases, use warp.Signer directly
- Remove luxWarp alias, use warp package directly
- Remove AppSender indirection, use p2p.Sender directly
- Update warptypes alias where local warp package conflicts
- Update node to v1.22.43, warp to v1.16.39
2025-12-22 04:12:50 -08:00

53 lines
1.3 KiB
Go

// Copyright (C) 2019-2025, Lux Industries, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package warp
import (
"github.com/luxfi/crypto/bls"
"github.com/luxfi/ids"
"github.com/luxfi/warp"
)
// LocalSigner implements signing with luxfi/crypto/bls
type LocalSigner struct {
sk *bls.SecretKey
pk *bls.PublicKey
}
// NewLocalSigner creates a new local signer using luxfi/crypto/bls
func NewLocalSigner(sk *bls.SecretKey) *LocalSigner {
return &LocalSigner{
sk: sk,
pk: bls.PublicFromSecretKey(sk),
}
}
// Sign signs the message with the private key
func (s *LocalSigner) Sign(msg []byte) ([]byte, error) {
sig := bls.Sign(s.sk, msg)
return bls.SignatureToBytes(sig), nil
}
// SignUnsignedMessage signs an unsigned warp message
func (s *LocalSigner) SignUnsignedMessage(unsignedMsg *warp.UnsignedMessage) ([]byte, error) {
msgBytes := unsignedMsg.Bytes()
return s.Sign(msgBytes)
}
// GetPublicKey returns the public key
func (s *LocalSigner) GetPublicKey() *bls.PublicKey {
return s.pk
}
// PublicKey returns the public key as compressed bytes (48 bytes)
func (s *LocalSigner) PublicKey() []byte {
return bls.PublicKeyToCompressedBytes(s.pk)
}
// NodeID returns the node ID derived from the public key
func (s *LocalSigner) NodeID() ids.NodeID {
// Create a dummy NodeID for testing
return ids.GenerateTestNodeID()
}