package
1.2.17
Repository: https://github.com/hubmakerlabs/replicatr.git
Documentation: pkg.go.dev

# README

mleku.online/git/ec

This is a full drop-in replacement for github.com/btcsuite/btcd/btcec eliminating the import from the Decred repository, and including the chainhash helper functions, needed for hashing messages for signatures.

The decred specific tests also have been removed, as well as all tests that use blake256 hashes as these are irrelevant to bitcoin and nostr. Some of them remain present, commented out, in case it is worth regenerating the vectors based on sha256 hashes, but on first blush it seems unlikely to be any benefit.

This includes the old style compact secp256k1 ECDSA signatures, that recover the public key rather than take a key as a parameter as used in Bitcoin transactions, the new style Schnorr signatures, and the Musig2 implementation.

BIP 340 Schnorr signatures are implemented except for the nonstandard message length tests, that nobody uses anyway.

The remainder of this document is from the original README.md.


Package ec implements elliptic curve cryptography needed for working with Bitcoin. It is designed so that it may be used with the standard crypto/ecdsa packages provided with Go.

A comprehensive suite of testis provided to ensure proper functionality.

Package btcec was originally based on work from ThePiachu which is licensed under the same terms as Go, but it has signficantly diverged since then. The btcsuite developers original is licensed under the liberal ISC license.

Installation and Updating

$ go install -u -v mleku.online/git/ec

# Packages

No description provided by the author
Package chainhash provides abstracted hash functionality.
Package ecdsa provides secp256k1-optimized ECDSA signing and verification.
No description provided by the author
No description provided by the author
Package schnorr provides custom Schnorr signing and verification via secp256k1.
Package secp256k1 implements optimized secp256k1 elliptic curve operations in pure Go.
No description provided by the author
No description provided by the author

# Functions

AddNonConst adds the passed Jacobian points together and stores the result in the provided result param in *non-constant* time.
DecompressY attempts to calculate the Y coordinate for the given X coordinate such that the result pair is a point on the secp256k1 curve.
DoubleNonConst doubles the passed Jacobian point and stores the result in the provided result parameter in *non-constant* time.
GenerateSharedSecret generates a shared secret based on a secret key and a public key using Diffie-Hellman key exchange (ECDH) (RFC 4753).
Generator returns the public key at the Generator Point.
GeneratorJacobian sets the passed JacobianPoint to the Generator Point.
IsCompressedPubKey returns true the passed serialized public key has been encoded in compressed format, and false otherwise.
JacobianToByteSlice converts the passed JacobianPoint to a Pubkey and serializes that to a byte slice.
MakeJacobianPoint returns a Jacobian point with the provided X, Y, and Z coordinates.
NewPublicKey instantiates a new public key with the given x and y coordinates.
NewSecretKey is a wrapper for ecdsa.GenerateKey that returns a SecretKey instead of the normal ecdsa.PrivateKey.
NonceRFC6979 generates a nonce deterministically according to RFC 6979 using HMAC-SHA256 for the hashing function.
Params returns the secp256k1 curve parameters for convenience.
ParseJacobian parses a byte slice point as a secp256k1.Publickey and returns the pubkey as a JacobianPoint.
ParsePubKey parses a public key for a koblitz curve from a bytestring into a ecdsa.Publickey, verifying that it is valid.
S256 returns a Curve which implements secp256k1.
ScalarBaseMultNonConst multiplies k*G where G is the base point of the group and k is a big endian integer.
ScalarMultNonConst multiplies k*P where k is a big endian integer modulo the curve order and P is a point in Jacobian projective coordinates and stores the result in the provided Jacobian point.
SecKeyFromBytes returns a secret and public key for `curve' based on the secret key passed as an argument as a byte slice.
SecKeyFromScalar instantiates a new secret key from a scalar encoded as a big integer.

# Constants

No description provided by the author
No description provided by the author
SecKeyBytesLen defines the length in bytes of a serialized secret key.

# Variables

No description provided by the author
No description provided by the author
No description provided by the author

# Type aliases

CurveParams contains the parameters for the secp256k1 curve.
Error identifies an error related to public key cryptography using a sec256k1 curve.
ErrorKind identifies a kind of error.
FieldVal implements optimized fixed-precision arithmetic over the secp256k1 finite field.
JacobianPoint is an element of the group formed by the secp256k1 curve in Jacobian projective coordinates and thus represents a point on the curve.
KoblitzCurve provides an implementation for secp256k1 that fits the ECC Curve interface from crypto/elliptic.
ModNScalar implements optimized 256-bit constant-time fixed-precision arithmetic over the secp256k1 group order.
No description provided by the author
PublicKey is an ecdsa.PublicKey with additional functions to serialize in uncompressed, compressed, and hybrid formats.
SecretKey wraps an ecdsa.SecretKey as a convenience mainly for signing things with the secret key without having to directly import the ecdsa package.