Documentation
¶
Overview ¶
package der provides DER encoding for Bitcoin signatures as specified in BIP66.
Index ¶
Constants ¶
View Source
const ( // TypeCompound is the prefix byte for any DER encoded signature. TypeCompound byte = 0x30 // TagInteger is the DER tag byte denoting a large integer which follows. TagInteger byte = 2 // MaxIntegerSize is the maximum size of an integer that BIP66 strict-DER encoding allows. MaxIntegerSize = 32 // MinimumSignatureLength and MaximumSignatureLength describe the min/max lengths possible // for DER-encoded signatures allowed by BIP66. MinimumSignatureLength = 9 MaximumSignatureLength = 73 )
Variables ¶
View Source
var ( // ErrNotEncodable is returned when an encoding function is passed a value // which cannot be encoded according to strict-DER as specified in BIP66. ErrNotEncodable = errors.New("failed to encode value in strict-DER") // ErrInvalidSigHashType is returned when DER-encoding a signature, if the sighash type // given is larger than can fit in a byte. ErrInvalidSigHashType = errors.New("failed to encode invalid sighash type in strict-DER") )
View Source
var ( // ErrInvalidSignatureEncoding is returned when decoding a signature fails // due to a BIP66 validation problem. ErrInvalidSignatureEncoding = errors.New("failed to decode DER signature") )
Functions ¶
func CheckEncodableBigInt ¶
CheckEncodableBigInt validates whether the big.Int v can be encoded in strict-DER as defined by BIP66. Returns ErrNotEncodable if it is not encodable.
func DecodeSignature ¶
DecodeSignature decodes the given DER-encoded signature byte slice and returns the signature (r, s), as well as the signature hash type. Validates that the format matches BIP66 strict-DER encoding and returns ErrInvalidSignatureEncoding otherwise.
func EncodeBigInt ¶
EncodeBigInt encodes a big.Int as a DER byte slice. Returns ErrNotEncodable if it is not encodable.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.