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

# README

ecdsa

ISC License GoDoc

Package ecdsa provides secp256k1-optimized ECDSA signing and verification.

This package provides data structures and functions necessary to produce and verify deterministic canonical signatures in accordance with RFC6979 and BIP0062, optimized specifically for the secp256k1 curve using the Elliptic Curve Digital Signature Algorithm (ECDSA), as defined in FIPS 186-3. See https://www.secg.org/sec2-v2.pdf (also found here at sec2-v2.pdf) for details on the secp256k1 standard.

It also provides functions to parse and serialize the ECDSA signatures with the more strict Distinguished Encoding Rules (DER) of ISO/IEC 8825-1 and some additional restrictions specific to secp256k1.

In addition, it supports a custom "compact" signature format which allows efficient recovery of the public key from a given valid signature and message hash combination.

A comprehensive suite of tests is provided to ensure proper functionality.

License

Package ecdsa is licensed under the copyfree ISC License.

# Functions

NewSignature instantiates a new signature given some r and s values.
ParseDERSignature parses a signature in the Distinguished Encoding Rules (DER) format per section 10 of [ISO/IEC 8825-1] and enforces the following additional restrictions specific to secp256k1: - The R and S values must be in the valid range for secp256k1 scalars: - Negative values are rejected - Zero is rejected - Values greater than or equal to the secp256k1 group order are rejected.
RecoverCompact attempts to recover the secp256k1 public key from the provided compact signature and message hash.
Sign generates an ECDSA signature over the secp256k1 curve for the provided hash (which should be the result of hashing a larger message) using the given secret key.
SignCompact produces a compact ECDSA signature over the secp256k1 curve for the provided hash (which should be the result of hashing a larger message) using the given secret key.

# Constants

ErrPointNotOnCurve is returned when attempting to recover a public key from a compact signature results in a point that is not on the elliptic curve.
ErrSigInvalidDataLen is returned when a signature that should be a DER signature does not specify the correct number of remaining bytes for the R and S portions.
ErrSigInvalidLen is returned when a signature that should be a compact signature is not the required length.
ErrSigInvalidRecoveryCode is returned when a signature that should be a compact signature has an invalid value for the public key recovery code.
ErrSigInvalidRIntID is returned when a signature that should be a DER signature does not have the expected ASN.1 integer ID for R.
ErrSigInvalidSeqID is returned when a signature that should be a DER signature does not have the expected ASN.1 sequence ID.
ErrSigInvalidSIntID is returned when a signature that should be a DER signature does not have the expected ASN.1 integer ID for S.
ErrSigInvalidSLen is returned when a signature that should be a DER signature does not specify the correct number of bytes for the S portion.
ErrSigMissingSLen is returned when a signature that should be a DER signature does not provide the length of S.
ErrSigMissingSTypeID is returned when a signature that should be a DER signature does not provide the ASN.1 type ID for S.
ErrSigNegativeR is returned when a signature that should be a DER signature has a negative value for R.
ErrSigNegativeS is returned when a signature that should be a DER signature has a negative value for S.
ErrSigOverflowsPrime is returned when a signature that should be a compact signature has the overflow bit set but adding the order to it would overflow the underlying field prime.
ErrSigRIsZero is returned when a signature has R set to the value zero.
ErrSigRTooBig is returned when a signature has R with a value that is greater than or equal to the group order.
ErrSigSIsZero is returned when a signature has S set to the value zero.
ErrSigSTooBig is returned when a signature has S with a value that is greater than or equal to the group order.
ErrSigTooLong is returned when a signature that should be a DER signature is too long.
ErrSigTooMuchRPadding is returned when a signature that should be a DER signature has too much padding for R.
ErrSigTooMuchSPadding is returned when a signature that should be a DER signature has too much padding for S.
ErrSigTooShort is returned when a signature that should be a DER signature is too short.
ErrSigZeroRLen is returned when a signature that should be a DER signature has an R length of zero.
ErrSigZeroSLen is returned when a signature that should be a DER signature has an S length of zero.

# Structs

Error identifies an error related to an ECDSA signature.
Signature is a type representing an ECDSA signature.

# Type aliases

ErrorKind identifies a kind of error.