Comments (9)
@mrose17 Looking into it...
I could tell for sure that your public key
thing is the same up to the curve modulus. For some reason curve25519
package does not mod
it before returning to you.
Also curve25519
C module seems to amend the public key before using it, but it seems that even when uncommenting section in your example - it still differs.
from elliptic.
I wonder if it could be that Adam is using http://elligator.cr.yp.to/poster.pdf in his donna code.
from elliptic.
Ok, figured it out :) It does everything in reverse!
var elliptic = require('./lib/elliptic.js')
, ec = new elliptic.ec('curve25519')
, mysecret = new Buffer('00843b75caa5bdb940f740b7d9262e2ae9937c946dca7b0d18617ff5a1a33f46', 'hex')
, rev = new Buffer(32);
mysecret[0] &= 248
mysecret[31] &= 127
mysecret[31] |= 64
for (var i = 0; i < 32; i++)
rev[i] = mysecret[32 - i - 1];
var mykey = ec.keyFromPrivate(rev)
, yourpublic = new Buffer('97b22cf64c25ae2db61d07618ff291086feff2ae8779e57be59e988c33916b0f', 'hex')
, yourkey = ec.keyFromPublic(yourpublic)
, shared = mykey.derive(yourkey.getPublic())
console.log(' my private key ='+mykey.getPrivate('hex') + '\n')
console.log(' old pkg says my public key='+'200b85ac0e08d3fd0a0be90436765119037d30b7bff56f07cfab51ec1691837f')
// !!!!!!!!
// This one is reversed!
// !!!!!!!!
console.log(' new pkg says my public key='+mykey.getPublic('hex') + '\n')
console.log(' old pkg says your public key='+yourpublic.toString('hex'))
console.log(' new pkg says your public key='+yourkey.getPublic('hex') + '\n')
console.log('old pkg says the shared secret='+'91bae78939e897c5996417c77c5e3e19f82f4143acb34ef23848d3b6cc1f9930')
console.log('new pkg says the shared secret='+shared.toString(16))
from elliptic.
Thanks for sharing, though!
from elliptic.
thanks for looking into this. very odd. i was expecting something less esoteric. ok, so basically, the trick is to know when the flip the results for transmission to the other side (my public key) or use (derived shared secret). i've updated the gist above to reflect that.
https://gist.github.com/mrose17/36a9f5ada76bfab4b8bc
sorry for the confusion!
from elliptic.
/Users/indutny/Code/indutny/elliptic/2.js:26
curve25519.makeSecretKey(C_mysecret)
^
TypeError: Object #<Object> has no method 'makeSecretKey'
at Object.<anonymous> (/Users/indutny/Code/indutny/elliptic/2.js:26:12)
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)
at startup (node.js:119:16)
at node.js:929:3
from elliptic.
hmmm... just to confirm, we're talking about this package
https://github.com/thejh/node-curve25519
(or at least that's the one i'm talking about!)
from elliptic.
Yeah, it is just your gist that does not work :) May be you are using older version?
from elliptic.
sorry about that. here's what i did:
-
(temporarily) add this dependency to package.json for elliptic:
"curve25519": "git://github.com/thejh/node-curve25519.git"
-
the usual
npm -l install
-
ran this gist: https://gist.github.com/mrose17/36a9f5ada76bfab4b8bc
maybe there is a version mismatch, but i'm not sure how i did that...
from elliptic.
Related Issues (20)
- ec.Signature is not fully available in Typescript
- How to format a PHP-OpenSSL signature to be verifiable with elliptic? HOT 1
- Convert signature to base64 HOT 1
- Curve25519 Derivation doesn't work against RFC test Vector
- ⚠️ BN.toString(16) can result in wrong output ([email protected]) HOT 1
- Custom Curves HOT 1
- recoverPubKey accepts invalid signatures for recovery
- How to convert a DER-formatted signature back to a Signature object? HOT 1
- KeyPair.fromPublic: returns a KeyPair?
- How to create an ec.Signature instance from r,s in typescript
- I seem to get a wrong signature when using 'secp256k1' HOT 1
- Why hasn't this software been updated after 2021 years? HOT 1
- Feature request: support ed448 HOT 1
- How does point comparison work for the identity / point at infinity?
- Feature Request: Support for Secp256r1
- [FEATURE] Need equivalent of secp256k1_ec_seckey_tweak_add
- v6.5.2 has a breaking change HOT 1
- Regular expression injection - (ReDos)
- Elliptic's EDDSA missing signature length check HOT 2
- Dependabot alerts being raised for elliptic HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from elliptic.