Documentation
¶
Overview ¶
Package ECDSA implements Cosmos-SDK compatible ECDSA public and private key. The keys can be serialized.
Index ¶
- func IsSNormalized(sigS *big.Int) bool
- func NormalizeS(sigS *big.Int) *big.Int
- type PrivKey
- func (sk *PrivKey) Bytes() []byte
- func (sk *PrivKey) MarshalTo(dAtA []byte) (int, error)
- func (sk *PrivKey) PubKey() PubKey
- func (sk *PrivKey) Sign(msg []byte) ([]byte, error)
- func (sk *PrivKey) String(name string) string
- func (sk *PrivKey) Unmarshal(bz []byte, curve elliptic.Curve, expectedSize int) error
- type PubKey
- func (pk *PubKey) Address(protoName string) tmcrypto.Address
- func (pk *PubKey) Bytes() []byte
- func (pk *PubKey) MarshalTo(dAtA []byte) (int, error)
- func (pk *PubKey) String(curveName string) string
- func (pk *PubKey) Unmarshal(bz []byte, curve elliptic.Curve, expectedSize int) error
- func (pk *PubKey) VerifySignature(msg []byte, sig []byte) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsSNormalized ¶
IsSNormalized returns true for the integer sigS if sigS falls in lower half of the curve order
Types ¶
type PrivKey ¶
type PrivKey struct {
ecdsa.PrivateKey
}
func GenPrivKey ¶
GenPrivKey generates a new secp256r1 private key. It uses operating system randomness.
func (*PrivKey) Sign ¶
Sign hashes and signs the message using ECDSA. Implements SDK PrivKey interface. NOTE: this now calls the ecdsa Sign function (not method!) directly as the s value of the signature is needed to low-s normalize the signature value See issue: https://github.com/stafiprotocol/cosmos-sdk/issues/9723 It then raw encodes the signature as two fixed width 32-byte values concatenated, reusing the code copied from secp256k1_nocgo.go
type PubKey ¶
func (*PubKey) Address ¶
Address gets the address associated with a pubkey. If no address exists, it returns a newly created ADR-28 address for ECDSA keys. protoName is a concrete proto structure id.
func (*PubKey) Bytes ¶
Bytes returns the byte representation of the public key using a compressed form specified in section 4.3.6 of ANSI X9.62 with first byte being the curve type.
func (*PubKey) String ¶
String returns a string representation of the public key based on the curveName.
func (*PubKey) VerifySignature ¶
VerifySignature checks if sig is a valid ECDSA signature for msg. This includes checking for low-s normalized signatures where the s integer component of the signature is in the lower half of the curve order 7/21/21 - expects raw encoded signature (fixed-width 64-bytes, R || S)