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

testnet messaging signing appears to be broken #49

Closed
robby-d opened this issue Mar 5, 2014 · 5 comments
Closed

testnet messaging signing appears to be broken #49

robby-d opened this issue Mar 5, 2014 · 5 comments

Comments

@robby-d
Copy link
Contributor

robby-d commented Mar 5, 2014

//this fails:
var v = new Bitcoin.ECKey(null, true, Bitcoin.network.testnet.addressVersion);
Bitcoin.Message.signMessage(v, "testing 123", v.compressed)
** Error: Pubkey recovery unsuccessful

//this works:
var v = new Bitcoin.ECKey(null, true, Bitcoin.network.mainnet.addressVersion);
Bitcoin.Message.signMessage(v, "testing 123", v.compressed)
"1f416b66236ee7bb54a0c00ba0d8e48249a9b630a2a89f8840d5a1691cc7b86c099c386b5ed13ec27663c019dc881c81a0c7e1dadaff7aa9f2275bf758c11ad407"
@weilu
Copy link
Contributor

weilu commented Mar 9, 2014

I can't figure out why... @kyledrake can you take a look at it?

@tgerring
Copy link

Picking this apart, it looks like the error is occurring in JSBN. Here's my stacktrace:

Error: Point is not on the curve.
    at ECPointFp.validate (/Users/tgerring/dev/tgerring/bitcoinjs-lib/src/jsbn/ec.js:508:11)
    at Object.ECDSA.recoverPubKey (/Users/tgerring/dev/tgerring/bitcoinjs-lib/src/ecdsa.js:261:7)
    at Object.ECDSA.calcPubkeyRecoveryParam (/Users/tgerring/dev/tgerring/bitcoinjs-lib/src/ecdsa.js:297:26)
    at Object.Message.signMessage (/Users/tgerring/dev/tgerring/bitcoinjs-lib/src/Message.js:36:17)
    at Object.<anonymous> (/Users/tgerring/dev/tgerring/bitcoinjs-lib/demo/taylor.js:9:17)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)

for the given code run out of /demo:

var ECKey = require('../src/eckey.js');
var Network = require('../src/Network.js');
var Message = require('../src/Message.js');

startTimeMs = Date.now();
var v = new ECKey.ECKey(null, true, Network.testnet.addressVersion);
console.log(v);
var r = Message.signMessage(v, "testing 123", v.compressed);
console.log(r);
endTimeMs = Date.now();
console.log('Operation took', endTimeMs - startTimeMs, 'ms');

@tgerring
Copy link

Digging more, it looks like the initial error is being thrown in ECDSA.verifyRaw()

Note that https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/src/ecdsa.js#L123-L125 contains a message about Shamir's trick not working, yet it is used at https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/src/ecdsa.js#L269.

In the end, https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/src/ecdsa.js#L131 evaluates to false for testnet, but works for mainnet.

@robby-d
Copy link
Contributor Author

robby-d commented Mar 20, 2014

@weilu @kyledrake FYI, our new wallet, which uses bitcoinjslib is released in beta on testnet:

https://www.counterparty.co/counterwallet-live-testnet/
https://testnet.counterwallet.co

Thank you guys for this library!

@weilu
Copy link
Contributor

weilu commented Mar 28, 2014

Resolved by #101

@weilu weilu closed this as completed Mar 28, 2014
louisinger added a commit to louisinger/liquidjs-lib that referenced this issue Apr 19, 2022
* fix serialization of witness version in scriptPubKey

* export blindingDataLike from psbt.ts

* build

* remove warnings + enrich test

* use wip blech32 branch

* use FUTURE_SEGWIT_CONSTANT

* blech32 from npm (1.1.2)
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

3 participants