Documentation
¶
Index ¶
- Constants
- Variables
- func DecodeSecp256k1PrivateKey(data []byte) (*ecdsa.PrivateKey, error)
- func EncodeSecp256k1PrivateKey(k *ecdsa.PrivateKey) []byte
- func EncodeSecp256k1PublicKey(k *ecdsa.PublicKey) []byte
- func GenerateSecp256k1Key() (*ecdsa.PrivateKey, error)
- func LegacyKeccak256(data []byte) ([]byte, error)
- func NewBSCAddress(p ecdsa.PublicKey) ([]byte, error)
- func NewOverlayAddress(p ecdsa.PublicKey, networkID uint64, nonce []byte) (cluster.Address, error)
- func NewOverlayFromBSCAddress(ethAddr []byte, networkID uint64, nonce []byte) (cluster.Address, error)
- func Recover(signature, data []byte) (*ecdsa.PublicKey, error)
- func RecoverEIP712(signature []byte, data *eip712.TypedData) (*ecdsa.PublicKey, error)
- func Secp256k1PrivateKeyFromBytes(data []byte) *ecdsa.PrivateKey
- type DH
- type RecoverFunc
- type Signer
Constants ¶
const (
AddressSize = 20
)
Variables ¶
var ErrBadHashLength = errors.New("wrong block hash length")
var (
ErrInvalidLength = errors.New("invalid signature length")
)
Functions ¶
func DecodeSecp256k1PrivateKey ¶
func DecodeSecp256k1PrivateKey(data []byte) (*ecdsa.PrivateKey, error)
DecodeSecp256k1PrivateKey decodes raw ECDSA private key.
func EncodeSecp256k1PrivateKey ¶
func EncodeSecp256k1PrivateKey(k *ecdsa.PrivateKey) []byte
EncodeSecp256k1PrivateKey encodes raw ECDSA private key.
func EncodeSecp256k1PublicKey ¶
EncodeSecp256k1PublicKey encodes raw ECDSA public key in a 33-byte compressed format.
func GenerateSecp256k1Key ¶
func GenerateSecp256k1Key() (*ecdsa.PrivateKey, error)
GenerateSecp256k1Key generates an ECDSA private key using secp256k1 elliptic curve.
func LegacyKeccak256 ¶
func NewBSCAddress ¶
NewBSCAddress returns a binary representation of BNB Smart Chain address. This function is based on github.com/ethereum/go-ethereum/crypto.PubkeyToAddress.
func NewOverlayAddress ¶
NewOverlayAddress constructs a Cluster Address from ECDSA public key.
func NewOverlayFromBSCAddress ¶
func NewOverlayFromBSCAddress(ethAddr []byte, networkID uint64, nonce []byte) (cluster.Address, error)
NewOverlayFromBSCAddress constructs a Cluster Address for an BNB Smart Chain address.
func Recover ¶
Recover verifies signature with the data base provided. It is using `btcec.RecoverCompact` function.
func RecoverEIP712 ¶
RecoverEIP712 recovers the public key for eip712 signed data.
func Secp256k1PrivateKeyFromBytes ¶
func Secp256k1PrivateKeyFromBytes(data []byte) *ecdsa.PrivateKey
Secp256k1PrivateKeyFromBytes returns an ECDSA private key based on the byte slice.
Types ¶
type DH ¶
type DH interface {
}DH is an interface allowing to generate shared keys for public key using a salt from a known private key TODO: implement clef support beside in-memory
func NewDH ¶
func NewDH(key *ecdsa.PrivateKey) DH
NewDH returns an ECDH shared secret key generation seeded with in-memory private key
type RecoverFunc ¶
RecoverFunc is a function to recover the public key from a signature
type Signer ¶
type Signer interface { // Sign signs data with ethereum prefix (eip191 type 0x45). Sign(data []byte) ([]byte, error) // SignTx signs an BNB Smart Chain transaction. SignTx(transaction *types.Transaction, chainID *big.Int) (*types.Transaction, error) // SignTypedData signs data according to eip712. SignTypedData(typedData *eip712.TypedData) ([]byte, error) // PublicKey returns the public key this signer uses. PublicKey() (*ecdsa.PublicKey, error) // BSCAddress returns the BNB Smart Chain this signer uses. BSCAddress() (common.Address, error) }
func NewDefaultSigner ¶
func NewDefaultSigner(key *ecdsa.PrivateKey) Signer