0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-18 11:57:37 -05:00
Commit graph

24 commits

Author SHA1 Message Date
Gregory Maxwell
cfe0ed916a Fix miscellaneous style nits that irritate overactive static analysis.
Also increase consistency with how overflow && zero is tested, and
 avoid some mixed declarations and code that GCC wasn't detecting.
2015-09-24 08:42:37 +00:00
Pieter Wuille
dd891e0ed5 Get rid of _t as it is POSIX reserved 2015-09-21 21:03:37 +02:00
Gregory Maxwell
2632019713 Brace all the if/for/while.
Unbraced statements spanning multiple lines has been shown in many
 projects to contribute to the introduction of bugs and a failure
 to catch them in review, especially for maintenance on infrequently
 modified code.

Most, but not all, of the existing practice in the codebase were not
 cases that I would have expected to eventually result in bugs but
 applying it as a rule makes it easier for other people to safely
 contribute.

I'm not aware of any such evidence for the case with the statement
 on a single line, but some people strongly prefer to never do that
 and the opposite rule of "_always_ use a single line for single
 statement blocks" isn't a reasonable rule for formatting reasons.
 Might as well brace all these too, since that's more universally
 acceptable.

[In any case, I seem to have introduced the vast majority of the
 single-line form (as they're my preference where they fit).]

This also removes a broken test which is no longer needed.
2015-03-27 23:24:32 +00:00
Gregory Maxwell
792bcdb015 Covert several more files to C89. 2015-01-24 23:34:09 +00:00
Peter Dettman
cc604e9842 Avoid division when decomposing scalars
- In secp256k1_gej_split_exp, there are two divisions used. Since the denominator is a constant known at compile-time, each can be replaced by a multiplication followed by a right-shift (and rounding).
- Add the constants g1, g2 for this purpose and rewrite secp256k1_scalar_split_lambda_var accordingly.
- Remove secp256k1_num_div since no longer used

Rebased-by: Pieter Wuille
2014-12-02 16:50:00 +01:00
Pieter Wuille
ff8746d457 Add secp256k1_scalar_mul_shift_var 2014-12-02 16:50:00 +01:00
Pieter Wuille
c76be9efa0 Remove unused num functions 2014-11-30 23:38:01 +01:00
Pieter Wuille
99f0728f23 Fix secp256k1_num_set_bin handling of 0 2014-11-26 15:21:31 +01:00
Gregory Maxwell
71712b27e5 Switch to C89 comments in prep for making the whole codebase C89 compatible.
This should be whitespace/comment only changes and should produce the same
object code.
2014-11-15 07:33:07 -08:00
Gregory Maxwell
65a14abb48 Fix varrious signed/unsigned comparisons. 2014-11-12 15:47:12 -08:00
Gregory Maxwell
e28a8b86c7 Remove a VERIFY_CHECK for >=0ness on an unsigned type. 2014-11-12 15:47:12 -08:00
Gregory Maxwell
2cad067a36 Correct function prototypes and avoid unused parameter warnings. 2014-11-12 15:47:06 -08:00
Gregory Maxwell
a4a43d7543 Reorder static to comply with C99 and switch to the inline macro. 2014-11-12 13:07:55 -08:00
Gregory Maxwell
8563713a4f Add non-null and unused-result warnings for the external API.
GCC (and clang) supports extensions to annotate functions so that their
 results must be used and so that their arguments can't be statically
 provable to be null. If a caller violates these requirements they
 get a warning, so this helps them write correct code.

I deployed this in libopus a couple years ago with good success, and
 the implementation here is basically copied straight from that.

One consideration is that the non-null annotation teaches the optimizer
 and will actually compile out runtime non-nullness checks as dead-code.
 Since this is usually not whats wanted, the non-null annotations are
 disabled when compiling the library itself.

The commit also removes some dead inclusions of assert.h and introduces
 compatibility macros for restrict and inline in preparation for some
 portability improvements.
2014-11-12 12:23:09 -08:00
Pieter Wuille
501d58f098 Get rid of {num,scalar,ecdsa_sig}_{init,free} 2014-11-03 01:31:04 -08:00
Pieter Wuille
a9f5c8b875 Introduce secp256k1_scalar_t for future constant-time mod order operations 2014-10-28 04:33:23 -07:00
Pieter Wuille
fa492f059d Fix a signedness mistake in secp256k1_num_set_hex
We were using a potentially signed char as index in an array.
2014-08-27 01:21:57 +02:00
Pieter Wuille
e2beb0bd2d
Merge pull request #51
364fde6 fix unsigned warning in num_gmp_impl.h (caktux)
2014-08-27 01:20:19 +02:00
Pieter Wuille
1c7fa133a6 Add VERIFY_CHECK/DEBUG_CHECK and use CHECK macros more 2014-08-26 01:23:51 +02:00
Pieter Wuille
87c782f632
Merge pull request #53
2f6c801 Try to not leave secret data on the stack or heap. (Gregory Maxwell)
2014-08-23 14:13:10 +02:00
Gregory Maxwell
2f6c801911
Try to not leave secret data on the stack or heap.
This makes a basic effort and has not been audited.
Doesn't appear to have a measurable performance impact on bench.

It also adds a secp256k1_num_free to secp256k1_ecdsa_pubkey_create.
2014-08-14 07:06:36 -07:00
caktux
364fde65f6 fix unsigned warning in num_gmp_impl.h 2014-08-11 16:09:09 -04:00
Pieter Wuille
1a749b4a6e Add secp256k1_num_eq and use it in tests 2014-08-09 19:22:42 +02:00
Pieter Wuille
11ab562203 Move implementations from impl/*.h to *_impl.h 2014-03-12 18:40:02 +01:00
Renamed from src/impl/num_gmp.h (Browse further)