Question

All I need are to get a private and public keypair for ECDSA. Stanford Javascript Crypto Library does it in a non-standard way ( https://groups.google.com/forum/?fromgroups#!topic/sjcl-discuss/UaWUyMWS3Rs ) and that's useless to me - like what's the point of making a MD5 library that gives different results to everything else?

Is there an actual, working way to use ECDSA in javascript?

Was it helpful?

Solution

The jsrsasign 4.0.0 now supports ECDSA signing and verification with EC private and public key.

http://kjur.github.io/jsrsasign/

I think this meets your needs. Here is a demo page.

http://kjur.github.io/jsrsasign/sample-ecdsa.html

OTHER TIPS

First of all, the comment you link to talks about the format of the ECDSA signature, not the keypair. Secondly, it is a bit misleading:

The output from the ECDSA algorithm is two integers in the interval [1, n-1]. The ECDSA standard (FIPS 183-3) does not specify way a standard method to encode this pair of numbers as a array of bytes.

One way is by encapsulating the numbers in an ASN.1 SEQUENCE. This is the way specified by ANSI X9.62 and RFC3278. It is the standard output from Java and (AFAIR) Microsoft CNG/.NET.

Another way is by left-padding the numbers with zeroes so they have the same byte-length as n and then just concatenating them. This is done by PKCS#11 and most smartcard implementations.

If I read the source code correctly, the SJCL encodes the ECDSA signature in the second way. You can easily convert this format to the first one.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top