ecdsa

package
v0.0.0-...-942cd0b Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package ecdsa implements the Elliptic Curve Digital Signature Algorithm, as defined in https://en.bitcoin.it/wiki/Elliptic_Curve_Digital_Signature_Algorithm

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PrivateKey

type PrivateKey struct {
	PublicKey
	D *big.Int // this is the secret
}

PrivateKey represents an ECDSA private key.

func GenerateKey

func GenerateKey(c elliptic.Curve, passphrase string) *PrivateKey

GenerateKey generates a public and private key pair from the passphrase.

func GenerateKeyFromSecret

func GenerateKeyFromSecret(c elliptic.Curve, secret *big.Int) *PrivateKey

func (*PrivateKey) Sign

func (priv *PrivateKey) Sign(sighash []byte) *Signature

Sign computes the signature pair r and s from D and msgDigest.

type PublicKey

type PublicKey struct {
	elliptic.Curve
	X, Y *big.Int
}

PublicKey represents an ECDSA public key.

func (*PublicKey) Marshal

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

func (*PublicKey) MarshalCompressed

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

func (*PublicKey) Unmarshal

func (pub *PublicKey) Unmarshal(buf []byte) (*PublicKey, error)

type Signature

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

Signature represents an ECDSA signature.

func (*Signature) Marshal

func (sig *Signature) Marshal() []byte

Marshal encodes sig in DER format.

DER has the following format: 0x30 [total-length] 0x02 [r-length] [r] 0x02 [s-length] [s]

total-length: 1-byte length descriptor of everything that follows. r-length: 1-byte length descriptor of the r value that follows. r: arbitrary-length big-endian encoded r value. It cannot start with any 0x00 bytes, unless the first byte that follows is 0x80 or higher, in which case a single 0x00 is required. s-length: 1-byte length descriptor of the s value that follows. s: arbitrary-length big-endian encoded s value. The same rules apply as for r.

func (*Signature) Unmarshal

func (sig *Signature) Unmarshal(der []byte) (*Signature, error)

Unmarshal decodes DER format to sig.

func (*Signature) Verify

func (sig *Signature) Verify(pub *PublicKey, msgDigest []byte) bool

Verify reports whether the signature pair r and s, pub and msgDigest are all consistent.

Jump to

Keyboard shortcuts

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