Skip to content
This repository has been archived by the owner on Nov 24, 2021. It is now read-only.

Verify that generated keypair correctly signs and verifies message #22

Closed
wants to merge 2 commits into from

Conversation

intelliot
Copy link
Contributor

Add a check in deriveKeypair to ensure that it always returns good keypairs.

  1. Sign a message.
  2. Verify the signature.
  3. Verify that the signature is not valid for a different message.

src/index.js Outdated
const badMessage = hash('This test message should NOT verify.')
const goodSignature = method.sign(goodMessage, keypair.privateKey)
if (method.verify(goodMessage, goodSignature, keypair.publicKey) !== true ||
method.verify(badMessage, goodSignature, keypair.publicKey) !== false) {

Choose a reason for hiding this comment

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

I'm not sure how meaningful the second check is. It seems like it tells us more about the correctness of the signing and verification functionality than the generated keypair.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True. I'll go ahead and remove it.

Copy link

@wilsonianb wilsonianb left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@intelliot
Copy link
Contributor Author

Merged via 1cf06f0

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants