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

Can't verify testnet signature #18

Closed
olalonde opened this issue May 11, 2015 · 10 comments · Fixed by #19
Closed

Can't verify testnet signature #18

olalonde opened this issue May 11, 2015 · 10 comments · Fixed by #19

Comments

@olalonde
Copy link

I've been trying to verify the following testnet message/signature with bitcore-message, but keep getting this stack trace.

message: localhost:3000
address: mx5u3nqdPpzvEZ3vfnuUQEyHg3gHd8zrrH
signature: G4Bi9/Z7hF17MpE9t7Txm3n0aBH6yCVLFB1VWzkZRz17FxErgA/oOWmwXWYr6/ILlRCmeYjc8MeI8PQWYAElZY8=
Invalid Argument: Error: i must be 0, 1, 2, or 3
Error
    at Error.NodeError (/src/node_modules/bitcore/lib/errors/index.js:20:41)
    at Object.module.exports.checkArgument (/src/node_modules/bitcore/lib/util/preconditions.js:14:13)
    at Function.Signature.fromCompact (/src/node_modules/bitcore/lib/crypto/signature.js:41:5)
    at Message.verify (/src/node_modules/bitcore-message/lib/message.js:92:29)
    at authenticate (/src/server/helpers/authenticate.js:38:32)
    at Layer.handle [as handle_request] (/src/node_modules/express/lib/router/layer.js:82:5)
@ghost
Copy link

ghost commented May 18, 2015

Can you post your code to see what you're doing wrong?
Judging by your error message, it could be a "bitcore" error, rather than a "bitcore-message" error.

@FoundationAwesome
Copy link

BUMP. Got the same error. Just followed the example instructions how to sign and verify a message. Mainnet this time though.

Ironically I came from bitcoinjs-lib where the documentation is also outdated.

@braydonf
Copy link
Contributor

There is a known issue with uncompressed public keys that will produced the same error message: #12

@FoundationAwesome
Copy link

Took the key from here: https://brainwallet.org/#sign

5KYZdUEo39z3FPrtuX2QbbwGnNP5zTd7yyr2SC1j299sBCnWjss

@FoundationAwesome
Copy link

I can confirm that this bug does not happen with compressed keys. Wondering now how to workarround this bug.

@braydonf
Copy link
Contributor

Adding support for uncompressed public keys in Signature.fromCompact: https://github.com/bitpay/bitcore/blob/master/lib/crypto/signature.js#L35 should fix the issue.

@FoundationAwesome
Copy link

todo-bitcore
Maybe some expert in crypto-signing wants to take on this todo? Would be really useful!

@ghost
Copy link

ghost commented May 24, 2015

I've found that bitcoinjs-lib is much cleaner than bitcore's... Not sure why they don't have as many stars.

@braydonf
Copy link
Contributor

Should be fixed in: bitpay/bitcore#1250

@braydonf braydonf added the ready label May 26, 2015
@braydonf
Copy link
Contributor

Should be fixed here with: #19

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

Successfully merging a pull request may close this issue.

3 participants