Documentation ¶
Index ¶
Constants ¶
const SecretKeyLength = 32
SecretKeyLength is the number of bytes in a SecretKey.
const SignatureLen = 64
SignatureLen is the number of bytes in a Signature.
Variables ¶
This section is empty.
Functions ¶
func GenKey ¶
GenKey generates a new key-pair, from a source of randomness.
Errors returned by this function will only come from the reader. If you know that the reader will never return errors, you can rest assured that this function won't either.
func TaggedHash ¶
TaggedHash addes some domain separation to SHA-256.
This is the hash_tag function mentioned in BIP-340.
See: https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki#specification
Types ¶
type PublicKey ¶
type PublicKey []byte
PublicKey represents a public key for BIP-340 signatures.
This key allows verifying signatures produced with the corresponding secret key.
This is simply an array of 32 bytes.
type SecretKey ¶
type SecretKey []byte
SecretKey represents a secret key for BIP-340 signatures.
This is simply an array of 32 bytes.
func (SecretKey) Public ¶
Public calculates the public key corresponding to a given secret key.
This will return an error if the secret key is invalid.
See: https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki#public-key-generation
func (SecretKey) Sign ¶
Sign uses a secret key to create a new signature.
Note that m should be the hash of a message, and not the actual message.
This accepts a source of randomness, but nil can be passed to use entirely deterministic signatures. Adding randomness hardens the implementation against fault attacks, but isn't strictly necessary for security.
Without randomness, an atomic counter is used to also hedge against attacks.
Errors will be returned if the source of randomness produces an error, or if the secret key is invalid.