ecdsa

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2019 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SECP256K1 int32 = iota + 1
	ECP256_FIPS186
	PUBLICKEY_FINGERPRINT_LEN = crypto.PUBLICKEY_FINGERPRINT_LEN
)
View Source
const (
	PublicKeyCompressedLength = 33
)

Variables

View Source
var (
	DefaultCurveType = ECP256_FIPS186
	DefaultVersion   = crypto.DefaultVersion
	DefaultFactory   = cryptoFactory{}
)

Functions

func GetEC

func GetEC(curveType int32) (elliptic.Curve, error)

func Secp256k1

func Secp256k1() elliptic.Curve

Types

type KeyDerivation

type KeyDerivation struct {
	// underlying root private key fingerprint
	RootFingerPrint []byte
	// index of child private key
	Index *big.Int
	// chaincode
	Chaincode []byte
}

func (*KeyDerivation) FromKDMessage

func (kd *KeyDerivation) FromKDMessage(msg *protos.KeyDerived)

func (*KeyDerivation) GenIntermediary

func (kd *KeyDerivation) GenIntermediary(pub *ecdsa.PublicKey, index *big.Int) ([]byte, *KeyDerivation, error)

func (*KeyDerivation) GetIndex

func (kd *KeyDerivation) GetIndex() *big.Int

func (*KeyDerivation) GetRootFingerPrint

func (kd *KeyDerivation) GetRootFingerPrint() []byte

func (*KeyDerivation) ToKDMessage

func (kd *KeyDerivation) ToKDMessage() *protos.KeyDerived

type KoblitzCurve

type KoblitzCurve struct {
	P       *big.Int // the order of the underlying field
	N       *big.Int // the order of the base point
	B       *big.Int // the constant of the KoblitzCurve equation
	Gx, Gy  *big.Int // (x,y) of the base point
	BitSize int      // the size of the underlying field
}

A Koblitz Curve with a=0.

func (*KoblitzCurve) Add

func (curve *KoblitzCurve) Add(x1, y1, x2, y2 *big.Int) (*big.Int, *big.Int)

func (*KoblitzCurve) Double

func (curve *KoblitzCurve) Double(x1, y1 *big.Int) (*big.Int, *big.Int)

func (*KoblitzCurve) IsOnCurve

func (curve *KoblitzCurve) IsOnCurve(x, y *big.Int) bool

func (*KoblitzCurve) Params

func (curve *KoblitzCurve) Params() *elliptic.CurveParams

func (*KoblitzCurve) ScalarBaseMult

func (curve *KoblitzCurve) ScalarBaseMult(k []byte) (*big.Int, *big.Int)

func (*KoblitzCurve) ScalarMult

func (curve *KoblitzCurve) ScalarMult(Bx, By *big.Int, k []byte) (*big.Int, *big.Int)

type PrivateKey

type PrivateKey struct {
	Version int32

	// Curve type
	CurveType int32

	// underlying private key
	Key *ecdsa.PrivateKey

	*KeyDerivation
}

func NewDefaultPrivatekey

func NewDefaultPrivatekey() (*PrivateKey, error)

func NewPrivatekey

func NewPrivatekey(curveType int32) (*PrivateKey, error)

func NewSECP256K1Privkey

func NewSECP256K1Privkey(s string) *PrivateKey

func (*PrivateKey) Child

func (priv *PrivateKey) Child(index *big.Int) (crypto.Hierarchical, error)

func (*PrivateKey) ChildPublic

func (priv *PrivateKey) ChildPublic(index *big.Int) (*PublicKey, error)

func (*PrivateKey) FromPBMessage

func (priv *PrivateKey) FromPBMessage(msg proto.Message) error

func (*PrivateKey) IsEqual

func (priv *PrivateKey) IsEqual(p interface{}) bool

func (*PrivateKey) IsEqualForTest

func (priv *PrivateKey) IsEqualForTest(otherPriv *PrivateKey) bool

func (*PrivateKey) PBMessage

func (priv *PrivateKey) PBMessage() proto.Message

func (*PrivateKey) Public

func (priv *PrivateKey) Public() crypto.Verifier

func (*PrivateKey) Sign

func (priv *PrivateKey) Sign(hash []byte) (sig *protos.Signature, err error)

func (*PrivateKey) String

func (priv *PrivateKey) String() string

func (*PrivateKey) ToECDSA

func (priv *PrivateKey) ToECDSA() *ecdsa.PrivateKey

deprecate APIs

type PublicKey

type PublicKey struct {
	Version int32

	// Curve type
	CurveType int32

	// underlying public key
	Key *ecdsa.PublicKey

	*KeyDerivation
}

func (*PublicKey) Child

func (pub *PublicKey) Child(index *big.Int) (crypto.Hierarchical, error)

func (*PublicKey) Digest

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

func (*PublicKey) FromPBMessage

func (pub *PublicKey) FromPBMessage(msg proto.Message) error

func (*PublicKey) IsEqual

func (pub *PublicKey) IsEqual(p interface{}) bool

func (*PublicKey) IsEqualForTest

func (pub *PublicKey) IsEqualForTest(otherPub *PublicKey) bool

func (*PublicKey) PBMessage

func (pub *PublicKey) PBMessage() proto.Message

func (*PublicKey) Recover

func (pub *PublicKey) Recover(sig *protos.Signature) error

func (*PublicKey) String

func (pub *PublicKey) String() string

func (*PublicKey) ToECDSA

func (pub *PublicKey) ToECDSA() *ecdsa.PublicKey

func (*PublicKey) Verify

func (pub *PublicKey) Verify(hash []byte, sig *protos.Signature) bool

Jump to

Keyboard shortcuts

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