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

Speedup ec.recoverPubKey #104

Closed
wants to merge 1 commit into from

Conversation

fanatid
Copy link
Contributor

@fanatid fanatid commented Sep 14, 2016

Similar to cryptocoinjs/secp256k1-node#101
should be ~2x faster

@coveralls
Copy link

Coverage Status

Coverage increased (+0.007%) to 88.101% when pulling ec437d0 on fanatid:speedup-ec-recoverPubKey into ab93810 on indutny:master.

@indutny
Copy link
Owner

indutny commented Sep 14, 2016

Benchmarks? :)

@fanatid
Copy link
Contributor Author

fanatid commented Sep 14, 2016

var EC = require('elliptic').ec
var secp256k1 = new EC('secp256k1')

var R = secp256k1.genKeyPair().getPublic()
var e = secp256k1.genKeyPair().getPrivate()
var s = secp256k1.genKeyPair().getPrivate()
var rinv = secp256k1.genKeyPair().getPrivate()

var cnt = 5e2

console.time('1 point mul')
for (var i = 0; i < cnt; ++i) {
  secp256k1.g.mulAdd(e, R, s).mul(rinv)
}
console.timeEnd('1 point mul')

console.time('2 scalar mul')
for (var i = 0; i < cnt; ++i) {
  secp256k1.g.mulAdd(e.mul(rinv).umod(secp256k1.n), R, s.mul(rinv).umod(secp256k1.n))
}
console.timeEnd('2 scalar mul')
1 point mul: 3057.023ms
2 scalar mul: 1855.858ms

@indutny
Copy link
Owner

indutny commented Sep 14, 2016

Ok, I'm convinced. Thank you!

indutny pushed a commit that referenced this pull request Sep 15, 2016
PR-URL: #104
Reviewed-By: Fedor Indutny <fedor@indutny.com>
@indutny
Copy link
Owner

indutny commented Sep 15, 2016

Landed in f3edfe5, and released in 6.3.2. Thank you!

@indutny indutny closed this Sep 15, 2016
@fanatid fanatid deleted the speedup-ec-recoverPubKey branch September 15, 2016 11:44
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 this pull request may close these issues.

3 participants