# What is the high level procedure to use ECDSA?

I want to make a computer program to sign and verify some message using ECDSA.

There are some computer libraries but I'm having trouble using them, as I don't understand ECDSA.

What do I need theoretically?

1. Is ECDSA the same as other digital signing that I calculate hash of message, encrypt the hash and append it to the original message?

2. In ECDSA can I choose hashing function and some encrypting parameters? What I need to know about generating pair of keys? What else do I need to specify.

NOTE: I don't need to implement ECDSA algorithm, there are libraries for that, but what I need to know what are the variable parameters in the algorithm.

EDIT: Here is a note from the library:

sign = crypto.createSign('SHA256');

privateKey = getPrivateKeySomehow();

sign.write('some data to sign');
sign.end();

sign.sign(privateKey);
// Prints: the calculated signature using the specified private key and
// SHA-256. For RSA keys, the algorithm is RSASSA-PKCS1-v1_5 (see padding
// parameter below for RSASSA-PSS). For EC keys, the algorithm is ECDSA.


Does this mean I have to specify a hashing algorithm and also generate a pair of EC keys?

## migrated from security.stackexchange.comOct 28 '17 at 21:22

This question came from our site for information security professionals.

• ECDSA doesn't encrypt hash with private key. Only RSA digital signature does. – defalt Oct 25 '17 at 14:12
• So the answer to my 1. question is no. What it does then? – croraf Oct 25 '17 at 14:13
• You are searching for Generating EC Keys and Parameters. You have to install OpenSSL. – defalt Oct 25 '17 at 14:21
• I don't use this, but want to use node.js' crypto module. So if I understand correctly I first specify the curve (like secp256k1) and next generate a pair of keys? Can you elaborate in the answer? – croraf Oct 25 '17 at 14:28
• If you ask such questions, do not roll you own crypto. – Tobi Nary Oct 25 '17 at 14:56

Is ECDSA the same as other digital signing that I calculate hash of message, encrypt the hash and append it to the original message?

No. From a user standpoint, you give the ECDSA module the message, it will hash it internally and then do some black magic with it (which includes drawing a random number) and output you a signature. If you want to test if your implementation is decent, ie does the hashing by itself, take a long message (like a couple of kB long) and give it to the function. If it "just works" then it is hashing, if not, well then it is not hashing.

In ECDSA can I choose hashing function and some encrypting parameters? What I need to know about generating pair of keys? What else do I need to specify.

Theoretically you can choose the hashing function, practically things may get a little more difficult with SHA1 and SHA256 being the standard options for ECDSA (despite SHA1 being broken).

Key generation is straight-forward. You pick one of the named curves your library provides (preferably the number in its name should be larger than 240) and then call the function to generate the key. This function will then generate the public / private key pair for you, by drawing a random number and doing an operation known as "scalar multiplication". Do not try to generate a curve yourself, this is really hard to do. The "larger than 240" limitation should give you a curve with 120-bit or more security which is sufficient.

• This is very high-level. If you want more details on some part, just tell me. – SEJPM Oct 28 '17 at 22:22
• First of all this community is such a pleasant surprise :) – croraf Oct 29 '17 at 7:46
• The signature is then just appended to the plain message and the process is done? – croraf Nov 10 '17 at 10:52
• @croraf you combine the signature and the message in such a way that you can easily extract both from the result. How you do this is an implementation detail. For example, you could use ASN.1, simple fixed-size appending or Cantor-Pairing. – SEJPM Nov 10 '17 at 10:58
• Can I ask something more in chat chat.stackexchange.com/rooms/68527/room-for-croraf-and-sejpm? – croraf Nov 10 '17 at 11:03