Skip to content

Add built-in self-tests and test vectors.#217

Closed
gmaxwell wants to merge 2 commits intobitcoin-core:masterfrom
gmaxwell:bist
Closed

Add built-in self-tests and test vectors.#217
gmaxwell wants to merge 2 commits intobitcoin-core:masterfrom
gmaxwell:bist

Conversation

@gmaxwell
Copy link
Contributor

This has a collection of static test vectors which were both randomly
and hand created and then machine reduced. All of the vectors were
tested against OpenSSL for agreement.

The vectors are checked at _start(), unless specifically built with
the them disabled (e.g. to reduce binary size.).

LCOV claims 91% branch coverage with the tests now.

@gmaxwell
Copy link
Contributor Author

I guess for discuss right now, I'm not super happy that the branch coverage is only 91%. I'm not sure what opinions are about running these things at startup, they do considerably slow down start. They could be trimmed down to a smaller set to make them faster.

@gmaxwell
Copy link
Contributor Author

Here is a recent lcov run with this patch in: http://people.xiph.org/~greg/secp256k1.bist1/

There are some unhit branches which are cryptographically unreachable, e.g. ecdsa_impl.h:206, and others are just serialization handling which would be easy enough to hit if thats what I was currently attempting. I'm most irritated right now with the uncovered carries in the scalar code, but I haven't tried to specifically craft something to hit them yet.

src/bist.h Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can put your name here :)

@sipa
Copy link
Contributor

sipa commented Feb 21, 2015

Doesn't compile with --enable-benchmark.

@gmaxwell
Copy link
Contributor Author

Hmph. Pretty sure it did at one point, I must have hosed it on a rebase. Will fix!

@sipa
Copy link
Contributor

sipa commented Feb 21, 2015

It only fails with non-standard -O options. I suppose it's something that's expected to be inlined but becomes an external symbol otherwise.

@sipa
Copy link
Contributor

sipa commented Feb 22, 2015

@sipa sipa mentioned this pull request Feb 23, 2015
@sipa
Copy link
Contributor

sipa commented Feb 24, 2015

For me, this increases the time for a secp256k1_start(SECP256K1_START_VERIFY | SECP256K1_START_SIGN) from 15ms to 53ms.

gmaxwell added 2 commits March 8, 2015 16:16
This has a collection of static test vectors which were both randomly
 and hand created and then machine reduced.  All of the vectors were
 tested against OpenSSL for agreement.

The vectors are checked at _start(), unless specifically built with
 the them disabled.

LCOV claims 91% branch coverage with the tests now.
@gmaxwell gmaxwell added this to the initial release milestone Aug 31, 2015
@jtimon
Copy link

jtimon commented Mar 21, 2017

Fast review ACK. Needs rebase.

@gmaxwell gmaxwell closed this Jun 11, 2019
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

Successfully merging this pull request may close these issues.

3 participants