Javascript ECDSA gets private and public keys?

All I need to do is get a private and open pair for ECDSA. The Stanford Crypto Library does this in a non-standard way ( https://groups.google.com/forum/?fromgroups#!topic/sjcl-discuss/UaWUyyMWS3Rs ), and it is useless to me - like what MD5 library needs to do, which gives different results to everything else?

Is there a real working way to use ECDSA in javascript?

+4
source share
2 answers

Jsrsasign 4.0.0 now supports signing and verifying ECDSA using the EC private and public key.

http://kjur.imtqy.com/jsrsasign/

I think it suits your needs. Here is a demo page.

http://kjur.imtqy.com/jsrsasign/sample-ecdsa.html

+6
source

First of all, a comment that you refer to talk about the ECDSA signature format, not a key pair. Secondly, this 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 a standard method for encoding this pair of numbers as an array of bytes.

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

Another way is left padding numbers with zeros, so they have the same byte length as n , and then just concatenate them. This is done using PKCS # 11 and most smart card implementations.

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

0
source

All Articles