Skip to content
This repository has been archived by the owner on Feb 22, 2024. It is now read-only.

Use consistent parameter names for Sign and Verify functions #3

Merged
merged 1 commit into from
Nov 12, 2019

Conversation

alexvanin
Copy link
Contributor

@alexvanin alexvanin commented Nov 12, 2019

It may be misleading when verify function takes signature as a hash
parameter. This commit suggested to use rfc6979 original naming
for the parameters:

  • msg as the message to sign,
  • sig as the signature of message.

All hashing operations are encapsulated inside of the Sign
and Verify functions.

Also there are comment fixes and re-usage of hashBytes() in rfc6979.

// panic("could not unmarshal r / s")
// Verify verifies the signature of msg using the public key pub. It returns
// nil only if signature is valid.
func Verify(pub *ecdsa.PublicKey, sig, msg []byte) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it is better also to also change order of msg and sig, because go's stdlib and many other libraries (e.g. kyber) accept first message then signature.
https://golang.org/pkg/crypto/ed25519/#Verify
https://golang.org/pkg/crypto/ecdsa/#Verify
https://golang.org/pkg/crypto/rsa/#VerifyPKCS1v15

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought about it, but decided to make small changes at first.

Let's see @im-kulikov review. If the general idea of this PR is okay, I don't mind to change the order of parameters for better consistency.

Copy link
Contributor

Choose a reason for hiding this comment

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

@fyrchik I will do it soon, thx (see #5)

ecdsa.go Outdated Show resolved Hide resolved
It may be misleading when verify function takes signature as a hash
parameter. This commit suggested to use rfc6979 original naming
for the parameters:
- `msg` as the message to sign,
- `sig` as the signature of message.
All hashing operations are encapsulated inside of the Sign
and Verify functions.

Also there are comment fixes and re-usage of `hashBytes()` in rfc6979.
@im-kulikov im-kulikov merged commit bd754c2 into master Nov 12, 2019
@im-kulikov im-kulikov deleted the fix-naming branch November 12, 2019 12:28
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Improving existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants