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

ed25519 ECDH encryption? #33

Closed
beastybeast opened this issue Feb 28, 2015 · 17 comments
Closed

ed25519 ECDH encryption? #33

beastybeast opened this issue Feb 28, 2015 · 17 comments

Comments

@beastybeast
Copy link

When selecting the ed25519 curve like this:

var ec = new ellipticjs.ec('ed25519');

Can it then be used for asymmetric encryption?

I have searched the web with mixed results. Some say something about the possibilities to convert the keys between ed25519 and curve25519? But no clear indication as to using ed25519 directly?

When tested with the library it seam to work fine, but I do not know about security etc.

Benny

@indutny
Copy link
Owner

indutny commented Feb 28, 2015

What you want is called http://en.wikipedia.org/wiki/Integrated_Encryption_Scheme . I think we have at least one module mentioned in readme of elliptic.

Please let me know if there is anything else I could help you with.

@beastybeast
Copy link
Author

Think you misunderstood me as I am only talking about ECC encryption with a public private key pair when using the ed25519 curve. E.g. not symmetric encryption and then public private encryption as under the Integrated Encryption Scheme.

I am not using the ed25519 curve for signing - but all info on the web states the ed25519 curve is used for signing. No where is there any info about using the ed25519 curve for ECDH.

I have tested that it works fine with your library but think my question is if this is then secure?

@beastybeast
Copy link
Author

@indutny
Copy link
Owner

indutny commented Mar 2, 2015

I think it should be possible, though, you'll need to use curve25519 and ed25519 for ECDSA and ECDH.

@indutny
Copy link
Owner

indutny commented Mar 2, 2015

Regarding security - there are tons of side-channel leaks, but other than that - there should not be other problems.

@beastybeast
Copy link
Author

OK - for now I will then use seperate curves for encryption and signing!

BTW: Why do this code fail when I select curve25519 (works fine for ed25519)?

var eccdh = new ellipticjs.ec('curve25519');
var asymkeysdh;
asymkeysdh = eccdh.genKeyPair();
var keypublicdh = asymkeysdh.getPublic(true, 'hex');

It fails because getY is undefined here:

if (compact) {
    var res = [ this.pub.getY().isEven() ? 0x02 : 0x03 ].concat(x);
  } else {
    var y = this.pub.getY().toArray();

@indutny
Copy link
Owner

indutny commented Mar 4, 2015

It doesn't fail for me, what elliptic version are you using?

@beastybeast
Copy link
Author

Will test with the latest version ASAP.

BTW: What is the diff between the small and big distribution?

@indutny
Copy link
Owner

indutny commented Mar 4, 2015

small distribution does not include precomputed points for sepc256k1 curve. Technically they could be computed in runtime, but it takes some time and it might be useful for bitcoin apps to just distribute it with precomputed points.

@beastybeast
Copy link
Author

Have now testet the latest version 3.03 with the same result => getY is not defined.

Please note that I run it directly in the browser and just took the file elliptic,js from the dist folder!

@pohutukawa
Copy link

Don't know whether that's the reason for the problem you're having. But the Ed25519 private "key" is actually a "key seed" that's used to derive the private and public keys (internally). Benefit for that is that it's impossible to actually choose an illegal key (e. g. not adhering to the pre-defined bit mask on the first/last few bits as Curve25519 uses).

@beastybeast
Copy link
Author

Do not think that is the problem here. I actually had some problems to understand the concept to begin with ;-)

@indutny
Copy link
Owner

indutny commented Mar 5, 2015

@beastybeast exactly this code works for me in a browser too.

@beastybeast
Copy link
Author

I have now done some testing with the code and it works in Firefox but does not work in Chrome (Chromium) where getY is undefined - very strange!

Testing is done under Ubuntu 14.10 (64 bit), FF 36, Chromium Version 40.0.2214.11

@beastybeast
Copy link
Author

Now testet under Windows 8.1 and both IE, FF and Chrome works fine.

So the only problem is my development platform Chromium Version 40.0.2214.11 under Ubuntu 14.10 (64 bit)

NB: Have not tested Chromium under Windows!

@beastybeast
Copy link
Author

Chromium version 43.0.2325.0 works under Windows 8.1 (64 bit)

So the conclusion must be that there is a bug in Chromium Version 40.0.2214.11 - strange error!

Will try to upgrade my Chromium Linux version and see if it helps!

@beastybeast
Copy link
Author

Installed Chrome Version 41.0.2272.76 (64-bit) and it works fine under Ubuntu!

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