Commit graph

58 commits

Author SHA1 Message Date
Wladimir J. van der Laan f0877f8b62
Merge pull request #5227
4cdaa95 Resize after succesful result (Pieter Wuille)
9d8604f Header define style cleanups (Pieter Wuille)
a53fd41 Deterministic signing (Pieter Wuille)
3060e36 Add the RFC6979 PRNG (Pieter Wuille)
a8f5087 Add HMAC-SHA256 (Pieter Wuille)
36fa4a7 Split up crypto/sha2 (Pieter Wuille)
2014-12-01 14:57:58 +01:00
Wladimir J. van der Laan 6582f323f0
Merge pull request #5224
f321d6b Add key generation/verification to ECC sanity check (Pieter Wuille)
d0c41a7 Add sanity check after key generation (Pieter Wuille)
2014-11-24 14:39:25 +01:00
Pieter Wuille d0c41a7350 Add sanity check after key generation
Add a sanity check to prevent cosmic rays from flipping a bit in the
generated public key, or bugs in the elliptic curve code. This is
simply done by signing a (randomized) message, and verifying the
result.
2014-11-23 10:47:39 +01:00
Pieter Wuille a53fd41485 Deterministic signing 2014-11-20 17:22:06 +01:00
Philip Kaufmann a01fa3035f minor style cleanup after HTTP rest interface merge
- no code changes
2014-11-20 12:29:19 +01:00
Pieter Wuille f4e0aefadc Do signature-s negation inside the tests
To avoid the need for libsecp256k1 to expose such functionality.
2014-11-10 05:03:24 -08:00
ENikS 5985ba9e61 Fixing warning C4099: 'CExtPubKey' : type name first seen using 'class' now seen using 'struct' 2014-11-06 17:53:25 -05:00
Philip Kaufmann b4347f6035 minor code style cleanup after recent merges
- add a missing license header
- correct some header orderings etc.
2014-11-04 14:36:46 +01:00
Cory Fields d2e74c55bd boost: moveonly: split CPubKey and friends to new files 2014-10-31 01:19:37 -04:00
Michael Ford ffd8eddab5 Update comments in key to be doxygen compatible 2014-10-28 12:02:25 +08:00
Cory Fields 066e2a1403 script: move CScriptID to standard.h and add a ctor for creating them from CScripts
This allows for a reversal of the current behavior.

This:
CScript foo;
CScriptID bar(foo.GetID());

Becomes:
CScript foo;
CScriptID bar(foo);

This way, CScript is no longer dependent on CScriptID or Hash();
2014-10-17 13:44:14 -04:00
Pieter Wuille 8138cbea3c Add automatic script test generation, and actual checksig tests 2014-09-26 21:58:48 +02:00
Pieter Wuille 20e01b1a03 Apply clang-format on some infrequently-updated files 2014-09-19 19:21:46 +02:00
Wladimir J. van der Laan f6a8105037
Merge pull request #4779
093303a add missing header end comments (Philip Kaufmann)
2014-09-01 15:35:09 +02:00
Philip Kaufmann 093303a887 add missing header end comments
- ensures a consistent usage in header files
- also add a blank line after the copyright header where missing
- also remove orphan new-lines at the end of some files
2014-08-28 22:25:21 +02:00
Wladimir J. van der Laan 8bdd2877c4
Fix a few "Uninitialized scalar field" warnings
Fix a few warnings reported by Coverity.
None of these is critical, but making sure that class fields are
initialized can avoid heisenbugs.
2014-08-28 15:30:50 +02:00
Andrew Poelstra 4a09e1df51
key.cpp: fail with a friendlier message on missing ssl EC support
Previously if bitcoind is linked with an OpenSSL which is compiled
without EC support, this is seen as an assertion failure "pKey !=
NULL" at key.cpp:134, which occurs after several seconds. It is an
esoteric piece of knowledge to interpret this as "oops, I linked
with the wrong OpenSSL", and because of the delay it may not even
be noticed.

The new output is

: OpenSSL appears to lack support for elliptic curve cryptography. For
more information, visit
https://en.bitcoin.it/wiki/OpenSSL_and_EC_Libraries
: Initialization sanity check failed. Bitcoin Core is shutting down.

which occurs immediately after attempted startup.

This also blocks in an InitSanityCheck() function which currently only
checks for EC support but should eventually do more. See #4081.
2014-06-03 12:09:51 -07:00
Kamil Domanski f40dbeedde remove CPubKey::VerifyCompact( ) which is never used 2014-05-20 14:58:21 +02:00
Pieter Wuille 6fd7ef2bbf Also switch the (unused) verification code to low-s instead of even-s.
a81cd968 introduced a malleability breaker for signatures
(using an even value for S). In e0e14e43 this was changed to
the lower of two potential values, rather than the even one.
Only the signing code was changed though, the (for now unused)
verification code wasn't adapted.
2014-03-10 20:38:32 +01:00
Peter Todd 5a986edac8
Document that CPubKey.IsValid() is consensus critical 2014-02-25 09:31:43 -05:00
Brandon Dahler 51ed9ec971 Cleanup code using forward declarations.
Use misc methods of avoiding unnecesary header includes.
Replace int typedefs with int##_t from stdint.h.
Replace PRI64[xdu] with PRI[xdu]64 from inttypes.h.
Normalize QT_VERSION ifs where possible.
Resolve some indirect dependencies as direct ones.
Remove extern declarations from .cpp files.
2013-11-10 09:36:28 -06:00
Philip Kaufmann a39967401e fix wrong memcmp() usage in CKey::operator==
- add a check for CKey::size() of a and b (size can be 0 or 32)
- change the fixed value in memcmp() to use a.size() instead
- fixes #3090
2013-10-28 17:09:50 +01:00
patrick s 6e51b3bddf improve wallet load time by removing duplicated calls to EC_KEY_check_key and adding a hash for vchPubKey/vchPrivKey entries in wallet.dat
backwards compatible with previous wallet.dat format
2013-08-28 23:53:26 -07:00
Pieter Wuille eb2c999050 BIP32 derivation implementation 2013-07-15 01:05:25 +02:00
Pieter Wuille 896185d7ed Make signature cache store CPubKeys 2013-05-30 05:20:23 +02:00
Pieter Wuille dfa23b94c2 CSecret/CKey -> CKey/CPubKey split/refactor 2013-05-30 05:20:21 +02:00
Pieter Wuille 5d891489ab Make CPubKey statically allocated 2013-05-30 05:18:42 +02:00
Pieter Wuille 0fb9073edd Split off hash.h from util.h 2012-12-18 21:39:29 +01:00
Pieter Wuille 69fc8047a9 Compact serialization for scripts
Special serializers for script which detect common cases and encode
them much more efficiently. 3 special cases are defined:
* Pay to pubkey hash (encoded as 21 bytes)
* Pay to script hash (encoded as 21 bytes)
* Pay to pubkey starting with 0x02, 0x03 or 0x04 (encoded as 33 bytes)

Other scripts up to 121 bytes require 1 byte + script length. Above
that, scripts up to 16505 bytes require 2 bytes + script length.
2012-10-20 23:08:56 +02:00
Wladimir J. van der Laan 7fddf1210e update comment, secure_allocator is defined in allocators.h 2012-09-15 12:10:00 +02:00
Pieter Wuille 1025440184 Refactor: split CKeyID/CScriptID/CTxDestination from CBitcoinAddress
This introduces internal types:
* CKeyID: reference (hash160) of a key
* CScriptID: reference (hash160) of a script
* CTxDestination: a boost::variant of the former two

CBitcoinAddress is retrofitted to be a Base58 encoding of a
CTxDestination. This allows all internal code to only use the
internal types, and only have RPC and GUI depend on the base58 code.

Furthermore, the header dependencies are a lot saner now. base58.h is
at the top (right below rpc and gui) instead of at the bottom. For the
rest: wallet -> script -> keystore -> key. Only keystore still requires
a forward declaration of CScript. Solving that would require splitting
script into two layers.
2012-05-24 20:26:19 +02:00
Pieter Wuille fd61d6f506 Encapsulate public keys in CPubKey 2012-05-24 19:58:12 +02:00
Gavin Andresen d0e4051cd8 Merge branch 'optimize' 2012-05-22 11:13:00 -04:00
Fordy 3a25a2b9b0 Update License in File Headers
I originally created a pull to replace the "COPYING" in crypter.cpp and
crypter.h, but it turned out that COPYING was actually the correct
file.
2012-05-18 22:02:28 +08:00
Gavin Andresen 096e06dbb5 Refactor: move code from key.h to key.cpp 2012-05-17 16:33:26 -04:00
Pieter Wuille 0a83c0fcef Fix tests after recent refactors 2012-04-17 20:37:47 +02:00
Pieter Wuille 6b6aaa1698 Further reduce header dependencies
This commit removes the dependency of serialize.h on PROTOCOL_VERSION,
and makes this parameter required instead of implicit. This is much saner,
as it makes the places where changing a version number can have an
influence obvious.
2012-04-17 20:03:42 +02:00
Jeff Garzik 9fb89c26f3 Fix misc. minor sign-comparison warnings 2012-04-15 17:00:20 -04:00
Pieter Wuille 6b8de05d0a Begin doxygen-compatible comments 2012-03-26 16:48:23 +02:00
Pieter Wuille 3a4d81724e Merge pull request #864 from sipa/fix_856
Make compressed pubkeys require client >=0.5.99
2012-02-19 18:21:19 -08:00
Pieter Wuille a09f101f14 Fix #650: CKey::SetSecret BIGNUM leak 2012-02-19 18:45:56 +01:00
Pieter Wuille 38067c18f8 Make compressed pubkeys require 0.6.0 2012-02-18 15:42:38 +01:00
Gavin Andresen 882164196e Update all copyrights to 2012 2012-02-07 11:28:30 -05:00
Pieter Wuille 91f43a33f8 Full checking of all loaded keys 2012-01-26 19:26:43 +01:00
Pieter Wuille d4d9c734c3 Compact signatures with compressed pubkeys 2012-01-09 15:18:19 +01:00
Pieter Wuille 11529c6e4f Compressed pubkeys
This patch enabled compressed pubkeys when -compressedpubkeys is passed.
These are 33 bytes instead of 65, and require only marginally more CPU
power when verifying. Compressed pubkeys have a different corresponding
address, so it is determined at generation. When -compressedpubkeys is
given, all newly generated addresses will use a compressed key, while
older/other addresses keep using normal keys. Unpatched clients will
relay and verify these transactions.
2012-01-09 15:18:19 +01:00
Gavin Andresen 9ef7fa3447 Code cleanup: use ECDSA_size() instead of fixed 10,000 byte sig buffer, and explicity init static var 2011-12-19 19:10:34 -05:00
Pieter Wuille 93db3fceac Add GetSecret() and GetKeys() to CKeyStore 2011-12-17 21:49:47 +01:00
Pieter Wuille d825e6a31b Some extra comments 2011-11-07 00:11:34 +01:00
Pieter Wuille 01cc526318 Compact signatures and key recovery
Introduce a new type of signatures that are only 65 bytes long, and allow
reconstruction of the public key that was used to create the signature.
2011-09-27 19:48:22 +02:00