Skip to content

ecdsa.recoverPubKey takes a "curve" parameter that is private #255

Closed
@glorat

Description

@glorat

ecdsa.recoverPubKey takes "curve" as its first parameter. In all likelyhood, what needs passing in here is

var curve = ecurve.getCurveByName('secp256k1')

so the parameter is arguably redundant. However, having been forced to pass this curve, I can't find a way to actually do so! That's because both ecurve and ecurve.getCurveByName are private to the library as far as I can tell and the test case in ecdsa.scala cheats by requiring curve.

In practice, I can of course require("ecurve") in my library myself but this falls foul of the "instanceof" trap as described at http://www.mattesch.info/blog/the-instanceof-trap-in-node-js

Passing in my own curve does make the key recovery work but I then cannot pass the Q into ECPubKey constructor due to the instanceOf check which I have no way of passing.

I hope this makes sense... Possible fixes include:

  • Remove all instanceOf checks in the constructors of things like ECPubKey
  • Make ecurve or ecurve.getCurveByName exported from the bitcoin module
  • Remove curve as a parameter from recoverPubKey, or make it optional defaulted to the bitcoin cure
    I vote for the latter!

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions