signschnorr

package
v0.0.0-...-bc1f52c Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Signature

type Signature struct {
	R *big.Int
	S *big.Int
}

Signature is a type representing either an ecdsa or schnorr signature.

func SignSchnorr

func SignSchnorr(privateKey *bchec.PrivateKey, hash []byte) (*Signature, error)

signSchnorr signs the hash using the schnorr signature algorithm. The rfc6979 nonce derivation function accepts additional entropy. We are using the same entropy that is used by bitcoin-abc so our test vectors will be compatible. This byte string is chosen to avoid collisions with ECDSA which would render the signature insecure.

See https://github.com/bitcoincashorg/bitcoincash.org/blob/master/spec/2019-05-15-schnorr.md#recommended-practices-for-secure-signature-generation

func (*Signature) Serialize

func (sig *Signature) Serialize() []byte

Serialize returns the a serialized signature depending on the SignatureType. Note that the serialized bytes returned do not include the appended hash type used in Bitcoin signature scripts.

ECDSA signature in the more strict DER format.

encoding/asn1 is broken so we hand roll this output:

0x30 <length> 0x02 <length r> r 0x02 <length s> s

Jump to

Keyboard shortcuts

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