Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix typos on signature.go #2065

Merged
merged 1 commit into from
Nov 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions btcec/schnorr/signature.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,7 @@ func schnorrVerify(sig *Signature, hash []byte, pubKeyBytes []byte) error {
// 7. Fail if is_infinite(R)
// 8. Fail if not hash_even_y(R)
// 9. Fail is x(R) != r.
// 10. Return success iff not failure occured before reachign this
// point.
// 10. Return success if failure did not occur before reaching this point.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The term iff is a scientific notation for "if and only if". So this is now wrong and not in line with the actual BIP: https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki#verification

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Damn, I missed that because the original line was not at all correct English.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An iff mixed in with the rest of the typos was indistinguishable from another type :)

Anyway, if you PR putting the iff back I'll merge. If not, I'll PR tomorrow.


// Step 1.
//
Expand Down Expand Up @@ -238,14 +237,14 @@ func zeroArray(a *[scalarSize]byte) {
}
}

// schnorrSign generates an BIP-340 signature over the secp256k1 curve for the
// schnorrSign generates a BIP-340 signature over the secp256k1 curve for the
// provided hash (which should be the result of hashing a larger message) using
// the given nonce and private key. The produced signature is deterministic
// (same message, nonce, and key yield the same signature) and canonical.
//
// WARNING: The hash MUST be 32 bytes and both the nonce and private keys must
// NOT be 0. Since this is an internal use function, these preconditions MUST
// be satisified by the caller.
// be satisfied by the caller.
func schnorrSign(privKey, nonce *btcec.ModNScalar, pubKey *btcec.PublicKey, hash []byte,
opts *signOptions) (*Signature, error) {

Expand All @@ -256,7 +255,7 @@ func schnorrSign(privKey, nonce *btcec.ModNScalar, pubKey *btcec.PublicKey, hash
// n = curve order
// d = private key
// m = message
// a = input randmoness
// a = input randomness
// r, s = signature
//
// 1. d' = int(d)
Expand Down Expand Up @@ -342,8 +341,8 @@ func schnorrSign(privKey, nonce *btcec.ModNScalar, pubKey *btcec.PublicKey, hash
return sig, nil
}

// SignOption is a functional option arguemnt that allows callers to modify the
// way we generate BIP-340 schnorr signatues.
// SignOption is a functional option argument that allows callers to modify the
// way we generate BIP-340 schnorr signatures.
type SignOption func(*signOptions)

// signOptions houses the set of functional options that can be used to modify
Expand All @@ -364,7 +363,7 @@ func defaultSignOptions() *signOptions {
}

// FastSign forces signing to skip the extra verification step at the end.
// Peformance sensitive applications may opt to use this option to speed up the
// Performance sensitive applications may opt to use this option to speed up the
// signing operation.
func FastSign() SignOption {
return func(o *signOptions) {
Expand Down Expand Up @@ -409,7 +408,7 @@ func Sign(privKey *btcec.PrivateKey, hash []byte,
// n = curve order
// d = private key
// m = message
// a = input randmoness
// a = input randomness
// r, s = signature
//
// 1. d' = int(d)
Expand Down Expand Up @@ -471,7 +470,7 @@ func Sign(privKey *btcec.PrivateKey, hash []byte,

// At this point, we check to see if a CustomNonce has been passed in,
// and if so, then we'll deviate from the main routine here by
// generating the nonce value as specifid by BIP-0340.
// generating the nonce value as specified by BIP-0340.
if opts.authNonce != nil {
// Step 6.
//
Expand Down
Loading