ecdsa

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 25, 2019 License: LGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPublicKeyFromByteSlice

func NewPublicKeyFromByteSlice(b []byte) (crypto.PublicKey, error)

NewPublicKeyFromByteSlice constructs an eth.publicKey instance from a byte slice.

func SigToPub

func SigToPub(
	hash common.Hash, signature crypto.Signature) (crypto.PublicKey, error)

SigToPub returns the PublicKey that created the given signature.

Types

type PrivateKey

type PrivateKey struct {
	// contains filtered or unexported fields
}

PrivateKey represents a private key structure used in geth and implments Crypto.PrivateKey interface.

func NewPrivateKey

func NewPrivateKey() (*PrivateKey, error)

NewPrivateKey creates a new PrivateKey structure.

func NewPrivateKeyFromECDSA

func NewPrivateKeyFromECDSA(key *ecdsa.PrivateKey) *PrivateKey

NewPrivateKeyFromECDSA creates a new PrivateKey structure from ecdsa.PrivateKey.

func (*PrivateKey) PublicKey

func (prv *PrivateKey) PublicKey() crypto.PublicKey

PublicKey returns the public key associate this private key.

func (*PrivateKey) Sign

func (prv *PrivateKey) Sign(hash common.Hash) (
	sig crypto.Signature, err error)

Sign calculates an ECDSA signature.

This function is susceptible to chosen plaintext attacks that can leak information about the private key that is used for signing. Callers must be aware that the given hash cannot be chosen by an adversery. Common solution is to hash any input before calculating the signature.

The produced signature is in the [R || S || V] format where V is 0 or 1.

type PublicKey

type PublicKey struct {
	// contains filtered or unexported fields
}

PublicKey represents a public key structure used in geth and implements Crypto.PublicKey interface.

func NewPublicKeyFromECDSA

func NewPublicKeyFromECDSA(key *ecdsa.PublicKey) *PublicKey

NewPublicKeyFromECDSA creates a new PublicKey structure from ecdsa.PublicKey.

func (*PublicKey) Bytes

func (pub *PublicKey) Bytes() []byte

Bytes returns the []byte representation of uncompressed public key. (65 bytes)

func (*PublicKey) Compress

func (pub *PublicKey) Compress() []byte

Compress encodes a public key to the 33-byte compressed format.

func (*PublicKey) VerifySignature

func (pub *PublicKey) VerifySignature(
	hash common.Hash, signature crypto.Signature) bool

VerifySignature checks that the given public key created signature over hash. The public key should be in compressed (33 bytes) or uncompressed (65 bytes) format. The signature should have the 64 byte [R || S] format.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL