Documentation
¶
Index ¶
- Constants
- Variables
- func GenerateKey(rand io.Reader) (priv []byte, x, y *big.Int, err error)
- func ParsePubKey(pubKeyStr []byte) (key *secp256k1.PublicKey, err error)
- func RecoverPubkey(sig, msg []byte) (*secp256k1.PublicKey, bool, error)
- func Sign(priv *secp256k1.PrivateKey, hash []byte) (r, s *big.Int, err error)
- func Verify(pubkey *secp256k1.PublicKey, msg []byte, r *big.Int, s *big.Int) bool
- type Error
- type ErrorCode
- type Signature
Constants ¶
const ( // ErrBadInputSize indicates that input to a signature was of the wrong size. ErrBadInputSize = iota // ErrInputValue indicates that the value of an input was wrong (e.g. zero). ErrInputValue // ErrSchnorrHashValue indicates that the hash of (R || m) was too large // and so a new k value (nonce) should be used. ErrSchnorrHashValue // ErrPointNotOnCurve indicates that a point was not on the given // elliptic curve. ErrPointNotOnCurve // ErrBadSigRYValue indicates that the calculated Y value of R was odd, // which is not allowed. ErrBadSigRYValue // ErrBadSigRNotOnCurve indicates that the calculated or given point R for some // signature was not on the curve. ErrBadSigRNotOnCurve // ErrUnequalRValues indicates that the calculated point R for some // signature was not the same as the given R value for the signature. ErrUnequalRValues // ErrRegenerateRPoint indicates that a point could not be regenerated // from r. ErrRegenerateRPoint // ErrPubKeyOffCurve indicates that a regenerated pubkey was off the curve. ErrPubKeyOffCurve // ErrRegenSig indicates that a regenerated pubkey could not be validated // against the signature. ErrRegenSig // ErrBadNonce indicates that a generated nonce from some algorithm was // unusable. ErrBadNonce // ErrZeroSigS indicates a zero signature S value, which is invalid. ErrZeroSigS // ErrNonmatchingR indicates that all signatures to be combined in a // threshold signature failed to have a matching R value. ErrNonmatchingR )
These constants are used to identify a specific RuleError.
const (
PubKeyBytesLen = 33
)
These constants define the lengths of serialized public keys.
const SignatureSize = 64
SignatureSize is the size of an encoded Schnorr signature.
Variables ¶
var BlakeVersionStringRFC6979 = []byte("Schnorr+BLAKE256")
BlakeVersionStringRFC6979 is the RFC6979 nonce version for a Schnorr signature over the secp256k1 curve using BLAKE256 as the hash function.
var Sha256VersionStringRFC6979 = []byte("Schnorr+SHA256 ")
Sha256VersionStringRFC6979 is the RFC6979 nonce version for a Schnorr signature over the secp256k1 curve using SHA256 as the hash function.
Functions ¶
func GenerateKey ¶
GenerateKey generates a key using a random number generator, returning the private scalar and the corresponding public key points.
func ParsePubKey ¶
ParsePubKey parses a public key for a koblitz curve from a bytestring into a ecdsa.Publickey, verifying that it is valid. It supports compressed signature formats only.
func RecoverPubkey ¶
RecoverPubkey is the exported and generalized version of schnorrRecover. It recovers a public key given a signature and a message, using BLAKE256 as the hashing function.
Types ¶
type Error ¶
type Error struct { ErrorCode ErrorCode // Describes the kind of error Description string // Human readable description of the issue }
Error identifies a violation.
type Signature ¶
Signature is a type representing a Schnorr signature.
func NewSignature ¶
NewSignature instantiates a new signature given some R,S values.
func ParseSignature ¶
ParseSignature parses a signature in BER format for the curve type `curve' into a Signature type, performing some basic sanity checks.
func (Signature) IsEqual ¶
IsEqual compares this Signature instance to the one passed, returning true if both Signatures are equivalent. A signature is equivalent to another, if they both have the same scalar value for R and S.