2
$\begingroup$

I`m currently implementing an ECDSA library based on curves like secp256k1. I would like to test it using some test vectors, like http://csrc.nist.gov/groups/STM/cavp/documents/dss/ecdsatestvectors.zip . Is there any place where I can get some vectors for testing encryption with that curve?

Example vector has this structure:

var testVectors = []struct {
msg    string
Qx, Qy string
r, s   string
ok     bool
}

and looks like this (for P224 curve):

{
    "96b2b6536f6df29be8567a72528aceeaccbaa66c66c534f3868ca9778b02faadb182e4ed34662e73b9d52ecbe9dc8e875fc05033c493108b380689ebf47e5b062e6a0cdb3dd34ce5fe347d92768d72f7b9b377c20aea927043b509c078ed2467d7113405d2ddd458811e6faf41c403a2a239240180f1430a6f4330df5d77de37",
    "851e3100368a22478a0029353045ae40d1d8202ef4d6533cfdddafd8",
    "205302ac69457dd345e86465afa72ee8c74ca97e2b0b999aec1f10c2",
    "4450c2d38b697e990721aa2dbb56578d32b4f5aeb3b9072baa955ee0",
    "e26d4b589166f7b4ba4b1c8fce823fa47aad22f8c9c396b8c6526e12",
    false,
},
{
    "86778dbb4a068a01047a8d245d632f636c11d2ad350740b36fad90428b454ad0f120cb558d12ea5c8a23db595d87543d06d1ef489263d01ee529871eb68737efdb8ff85bc7787b61514bed85b7e01d6be209e0a4eb0db5c8df58a5c5bf706d76cb2bdf7800208639e05b89517155d11688236e6a47ed37d8e5a2b1e0adea338e",
    "ad5bda09d319a717c1721acd6688d17020b31b47eef1edea57ceeffc",
    "c8ce98e181770a7c9418c73c63d01494b8b80a41098c5ea50692c984",
    "de5558c257ab4134e52c19d8db3b224a1899cbd08cc508ce8721d5e9",
    "745db7af5a477e5046705c0a5eff1f52cb94a79d481f0c5a5e108ecd",
    true,
},
$\endgroup$
  • $\begingroup$ DSA (and ECDSA) is not an encryption algorithm, but a signature algorithm. And this signature is not deterministic ... the best we could do is to give some example signatures which you could verify, or some sample random $k$ together with the signature created from this. $\endgroup$ – Paŭlo Ebermann Oct 1 '11 at 15:12
  • $\begingroup$ I already have a testing architecture in place from a library implementing curves like P224, but I can't find any external data to test my implementation against. It should work, I can successfully generate, sign and verify anything with it, but comparing it with someone else's implementation would be desirable. $\endgroup$ – ThePiachu Oct 1 '11 at 19:07
  • $\begingroup$ You could try and find as many corner cases as possible, regarding the input and internal random number generation. Then you could test against e.g. bouncy castle, which contains a ECDSA implementation as well as all the Secp curves (in the ASN.1 part of the source). $\endgroup$ – Maarten - reinstate Monica Jan 2 '12 at 17:03
2
$\begingroup$

I don't unfortunately know a good set of preexisting test vectors for this curve. Instead I decided to advice you how you can generate them yourself. Hope this helps.

Some (fairly recent) OpenSSL versions are familiar with secp256k1 curve. You may use e.g. OpenSSL's command line tool openssl's commands ecparam, ec, dgst to generate key pairs, parameter files, and ECDSA signatures using the curve.

If you do some scripting, you can even create files that appear similar than the the ECDSA test vectors from NIST/CAVP.

On the other hand, if you do not wish to force specific value for $k$ for testing or use deterministic variant of ECDSA signing (see RFC 6979), then you may be better of trying this:

  • Validate your verification function with some pregenerated test vectors (containing both correct and incorrect signatures). Note: Remember to generate the vectors using some independent implementation (possibly e.g. OpenSSL).
  • Validate your signature function for compatibility with your verification function.
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.