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 NewEthereumAddress(p ecdsa.PublicKey) ([]byte, error)
- func NewOverlayAddress(p ecdsa.PublicKey, networkID uint64) (swarm.Address, error)
- func NewOverlayFromEthereumAddress(ethAddr []byte, networkID uint64) swarm.Address
- 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 (
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 ¶ added in v0.3.0
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 ¶ added in v0.2.0
func NewEthereumAddress ¶
NewEthereumAddress returns a binary representation of ethereum blockchain address. This function is based on github.com/ethereum/go-ethereum/crypto.PubkeyToAddress.
func NewOverlayAddress ¶
NewOverlayAddress constructs a Swarm Address from ECDSA public key.
func NewOverlayFromEthereumAddress ¶ added in v0.3.0
NewOverlayFromEthereumAddress constructs a Swarm Address for an Ethereum address.
func Recover ¶
Recover verifies signature with the data base provided. It is using `btcec.RecoverCompact` function.
func RecoverEIP712 ¶ added in v0.3.0
RecoverEIP712 recovers the public key for eip712 signed data.
func Secp256k1PrivateKeyFromBytes ¶ added in v0.3.0
func Secp256k1PrivateKeyFromBytes(data []byte) *ecdsa.PrivateKey
Secp256k1PrivateKeyFromBytes returns an ECDSA private key based on the byte slice.
Types ¶
type DH ¶ added in v0.3.0
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 ¶ added in v0.3.0
func NewDH(key *ecdsa.PrivateKey) DH
NewDH returns an ECDH shared secret key generation seeded with in-memory private key
type RecoverFunc ¶ added in v0.3.0
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 ethereum transaction. SignTx(transaction *types.Transaction) (*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) // EthereumAddress returns the ethereum address this signer uses. EthereumAddress() (common.Address, error) }
func NewDefaultSigner ¶
func NewDefaultSigner(key *ecdsa.PrivateKey) Signer