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

secp256k1: verifyDetached method works differently from EdDSA implementation #65

Open
alexkravets opened this issue Feb 5, 2021 · 1 comment

Comments

@alexkravets
Copy link

For these methods to work consistently and return false on verification failure, I had to wrap into try / catch like here:

const verifyDetached = async (jws, credentialDigestBuffer, publicKeyJwk) => {
  try {
    await _verifyDetached(jws, credentialDigestBuffer, publicKeyJwk)

  } catch (error) {
    const isVerificationFailed = error.message.includes('ECDSA Verify Failed')

    if (isVerificationFailed) {
      return false
    }

    throw error
  }

  return true
}

Wondering which implementation secp256k1 or EdDSA supposed to be original one.

@OR13
Copy link
Sponsor Member

OR13 commented Feb 5, 2021

Thanks for reporting this... this is bad.

The reason is for this bug is confusion over trying to match the behavior of JWS.verify in jose, which returns the verified payload or throws an error....

I think the correct behavior for "verifyDetached"... should be:

(detachedJws:string, messageDigest:Buffer, publicKeyJwk: any): Promise<Boolean>

OR13 added a commit that referenced this issue Feb 6, 2021
@OR13 OR13 mentioned this issue Feb 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants