Pieter Wuille
a91d532338
Add CKey::SignSchnorr function for BIP 340/341 signing
3 years ago
MarcoFalke
faece47c47
refactor: Avoid &foo[0] on C-Style arrays
...
This is confusing at best when parts of a class use the
redundant operators and other parts do not.
4 years ago
Sawyer Billings
e8640849c7
doc: Use https URLs where possible
4 years ago
MarcoFalke
fa0074e2d8
scripted-diff: Bump copyright headers
...
-BEGIN VERIFY SCRIPT-
./contrib/devtools/copyright_header.py update ./
-END VERIFY SCRIPT-
4 years ago
practicalswift
46fcac1e4b
tests: Add fuzzing harness for ec_seckey_import_der(...) and ec_seckey_export_der(...)
4 years ago
Pieter Wuille
02c4cc5c5d
Make CHash256/CHash160 output to Span
4 years ago
Pieter Wuille
e549bf8a9a
Make CHash256 and CHash160 consume Spans
4 years ago
Pieter Wuille
e10439ce5a
scripted-diff: rename privkey with seckey in secp256k1 interface
...
-BEGIN VERIFY SCRIPT-
sed -i 's/privkey/seckey/g' src/key.cpp
-END VERIFY SCRIPT-
4 years ago
MarcoFalke
aaaaad6ac9
scripted-diff: Bump copyright of files changed in 2019
...
-BEGIN VERIFY SCRIPT-
./contrib/devtools/copyright_header.py update ./
-END VERIFY SCRIPT-
5 years ago
Wladimir J. van der Laan
36191a8bb5
Merge #12461 : scripted-diff: Rename key size consts to be relative to their class
...
0580f86bb4
Fixup whitespace (Ben Woosley)
47101bbb27
scripted-diff: Rename CPubKey and CKey::*_KEY_SIZE and COMPRESSED_*_KEY_SIZE (Ben Woosley)
Pull request description:
~~And introduce CPubKeySig to host code relative to key sigs.~~
ACKs for top commit:
meshcollider:
utACK 0580f86bb4
Tree-SHA512: 29aa0be54912358b138e391b9db78639786f56580493e590ec9f773c0e1b421740133d05a79be247c7ee57e71c9c9e41b9cb54088cb3c0e3f813f74f0895287b
5 years ago
practicalswift
eca9767673
Make reasoning about dependencies easier by not including unused dependencies
6 years ago
Jonas Schnelli
463921bb64
CKey: add method to negate the key
6 years ago
Ben Woosley
47101bbb27
scripted-diff: Rename CPubKey and CKey::*_KEY_SIZE and COMPRESSED_*_KEY_SIZE
...
To SIZE and COMPRESSED_SIZE
-BEGIN VERIFY SCRIPT-
sed -i 's/PRIVATE_KEY_SIZE/SIZE/g' src/*.h src/*.cpp src/**/*.h src/**/*.cpp
sed -i 's/COMPRESSED_PRIVATE_KEY_SIZE/COMPRESSED_SIZE/g' src/*.h src/**/*.cpp src/**/*.h src/**/*.cpp
sed -i 's/PUBLIC_KEY_SIZE/SIZE/g' src/*.h src/*.cpp src/**/*.h src/**/*.cpp
sed -i 's/COMPRESSED_PUBLIC_KEY_SIZE/COMPRESSED_SIZE/g' src/*.h src/*.cpp src/**/*.h src/**/*.cpp
-END VERIFY SCRIPT-
6 years ago
João Barbosa
3617f11739
Fix assertion in CKey::SignCompact
6 years ago
liuyujun
9a565a8282
Pass export privkey DER compression flag correctly
...
By passing a bitfield where a boolean was expected, the result was
always compressed. Fix this.
6 years ago
Wladimir J. van der Laan
2115cba9c6
Merge #13666 : Always create signatures with Low R values
...
e306be7429
Use 72 byte dummy signatures when watching only inputs may be used (Andrew Chow)
48b1473c89
Use 71 byte signature for DUMMY_SIGNATURE_CREATOR (Andrew Chow)
18dfea0dd0
Always create 70 byte signatures with low R values (Andrew Chow)
Pull request description:
When creating signatures for transactions, always make one which has a 32 byte or smaller R and 32 byte or smaller S value. This results in signatures that are always less than 71 bytes (32 byte R + 32 byte S + 6 bytes DER + 1 byte sighash) with low R values. In most cases, the signature will be 71 bytes.
Because R is not mutable in the same way that S is, a low R value can only be found by trying different nonces. RFC 6979 for deterministic nonce generation has the option to specify additional entropy, so we simply use that and add a uin32_t counter which we increment in order to try different nonces. Nonces are sill deterministically generated as the nonce used will the be the first one where the counter results in a nonce that results in a low R value. Because different nonces need to be tried, time to produce a signature does increase. On average, it takes twice as long to make a signature as two signatures need to be created, on average, to find one with a low R.
Having a fixed size signature makes size calculations easier and also saves half a byte of transaction size, on average.
DUMMY_SIGNATURE_CREATOR has been modified to produce 71 byte dummy signatures instead of 72 byte signatures.
Tree-SHA512: 3cd791505126ce92da7c631856a97ba0b59e87d9c132feff6e0eef1dc47768e81fbb38bfbe970371bedf9714b7f61a13a5fe9f30f962c81734092a4d19a4ef33
6 years ago
Andrew Chow
18dfea0dd0
Always create 70 byte signatures with low R values
...
When extra entropy is not specified by the caller, CKey::Sign will
now always create a signature that has a low R value and is at most
70 bytes. The resulting signature on the stack will be 71 bytes when
the sighash byte is included.
Using low R signatures means that the resulting DER encoded signature
will never need to have additional padding to account for high R
values.
6 years ago
DrahtBot
eb7daf4d60
Update copyright headers to 2018
6 years ago
John Newbery
131d4450b9
scripted-diff: Rename master key to seed
...
-BEGIN VERIFY SCRIPT-
ren() { git grep -l "\<$1\>" 'src/*.cpp' 'src/*.h' test | xargs sed -i "s:\<$1\>:$2:g"; }
ren GenerateNewHDMasterKey GenerateNewSeed
ren DeriveNewMasterHDKey DeriveNewSeed
ren SetHDMasterKey SetHDSeed
ren hdMasterKeyID hd_seed_id
ren masterKeyID seed_id
ren SetMaster SetSeed
ren hdmasterkeyid hdseedid
ren hdmaster hdseed
-END VERIFY SCRIPT-
7 years ago
Wladimir J. van der Laan
a34ac6ae07
Merge #9598 : Improve readability by removing redundant casts to same type (on all platforms)
...
06edc23f7
Improve readability by removing redundant casts to same type (on all platforms) (practicalswift)
Pull request description:
Same binaries check under Linux:
```
$ ../bitcoin-maintainer-tools/build-for-compare.py 874f13821f4193bd037cd37d005ee76b5a849398 82274c02ed
--executables "src/bitcoind,src/bitcoin-cli,src/bitcoin-tx"
$ sha256sum /tmp/compare/*.stripped
1fe1a8827474f7f24475ce3dc851e7ac658d4ed0ae38d11e67f5a810671eaa15 /tmp/compare/bitcoin-cli.82274c02ed2d82537dc55f008a29edb1bc09bbc4.stripped
1fe1a8827474f7f24475ce3dc851e7ac658d4ed0ae38d11e67f5a810671eaa15 /tmp/compare/bitcoin-cli.874f13821f4193bd037cd37d005ee76b5a849398.stripped
342c2ed0e60b60990a58cbf5845b256a4f9e3baff9db074baba5e34a620a60ea /tmp/compare/bitcoind.82274c02ed2d82537dc55f008a29edb1bc09bbc4.stripped
342c2ed0e60b60990a58cbf5845b256a4f9e3baff9db074baba5e34a620a60ea /tmp/compare/bitcoind.874f13821f4193bd037cd37d005ee76b5a849398.stripped
e4b2a80b2361d5cefd67a47eeb9298b8b712c26c7779d979348be8b2c7e3ec93 /tmp/compare/bitcoin-tx.82274c02ed2d82537dc55f008a29edb1bc09bbc4.stripped
e4b2a80b2361d5cefd67a47eeb9298b8b712c26c7779d979348be8b2c7e3ec93 /tmp/compare/bitcoin-tx.874f13821f4193bd037cd37d005ee76b5a849398.stripped
$ git diff -W --word-diff /tmp/compare/874f13821f4193bd037cd37d005ee76b5a849398 /tmp/compare/82274c02ed2d82537dc55f008a29edb1bc09bbc4
$
```
Tree-SHA512: 13ca5862fbb03771682b04a7523e581a7fe62e73620fa0e141cf1bc0a3b3f4e2e66bf14b46d1228e2b11b4960153545e7476f3295713a69b5cf5a28a7c2b358d
7 years ago
murrayn
a25cb0f313
Use ptrdiff_t type to more precisely indicate usage and avoid compiler warnings.
7 years ago
Russell Yanofsky
04ededf001
Make CKey::Load references const
...
No change in behavior, this just prevents CKey::Load arguments from looking
like outputs.
7 years ago
Akira Takizawa
595a7bab23
Increment MIT Licence copyright header year on files modified in 2017
7 years ago
practicalswift
06edc23f74
Improve readability by removing redundant casts to same type (on all platforms)
7 years ago
Wladimir J. van der Laan
79399c8cd0
Merge #10657 : Utils: Improvements to ECDSA key-handling code
...
63179d0
Scope the ECDSA constant sizes to CPubKey / CKey classes (Jack Grigg)
1ce9f0a
Ensure that ECDSA constant sizes are correctly-sized (Jack Grigg)
48abe78
Remove redundant `= 0` initialisations (Jack Grigg)
17fa391
Specify ECDSA constant sizes as constants (Jack Grigg)
e4a1086
Update Debian copyright list (Jack Grigg)
e181dbe
Add comments (Jack Grigg)
a3603ac
Fix potential overflows in ECDSA DER parsers (Jack Grigg)
Pull request description:
Mostly trivial, but includes fixes to potential overflows in the ECDSA DER parsers.
Cherry-picked from Zcash PR https://github.com/zcash/zcash/pull/2335
Tree-SHA512: 8fcbd51b0bd6723e5d33fa5d592f7cb68ed182796a9b837ecc8217991ad69d6c970258617dc00eb378c8caa4cec5d6b304d9d2c066acd40cda98e4da68e0caa4
7 years ago
practicalswift
a720b928c8
Remove includes in .cpp files for things the corresponding .h file already included
7 years ago
MeshCollider
1a445343f6
scripted-diff: Replace #include "" with #include <> (ryanofsky)
...
-BEGIN VERIFY SCRIPT-
for f in \
src/*.cpp \
src/*.h \
src/bench/*.cpp \
src/bench/*.h \
src/compat/*.cpp \
src/compat/*.h \
src/consensus/*.cpp \
src/consensus/*.h \
src/crypto/*.cpp \
src/crypto/*.h \
src/crypto/ctaes/*.h \
src/policy/*.cpp \
src/policy/*.h \
src/primitives/*.cpp \
src/primitives/*.h \
src/qt/*.cpp \
src/qt/*.h \
src/qt/test/*.cpp \
src/qt/test/*.h \
src/rpc/*.cpp \
src/rpc/*.h \
src/script/*.cpp \
src/script/*.h \
src/support/*.cpp \
src/support/*.h \
src/support/allocators/*.h \
src/test/*.cpp \
src/test/*.h \
src/wallet/*.cpp \
src/wallet/*.h \
src/wallet/test/*.cpp \
src/wallet/test/*.h \
src/zmq/*.cpp \
src/zmq/*.h
do
base=${f%/*}/ relbase=${base#src/} sed -i "s:#include \"\(.*\)\"\(.*\):if test -e \$base'\\1'; then echo \"#include <\"\$relbase\"\\1>\\2\"; else echo \"#include <\\1>\\2\"; fi:e" $f
done
-END VERIFY SCRIPT-
7 years ago
Jack Grigg
63179d0283
Scope the ECDSA constant sizes to CPubKey / CKey classes
7 years ago
practicalswift
90d4d89230
scripted-diff: Use the C++11 keyword nullptr to denote the pointer literal instead of the macro NULL
...
-BEGIN VERIFY SCRIPT-
sed -i 's/\<NULL\>/nullptr/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h src/qt/*/*.cpp src/qt/*/*.h src/wallet/*/*.cpp src/wallet/*/*.h src/support/allocators/*.h
sed -i 's/Prefer nullptr, otherwise SAFECOOKIE./Prefer NULL, otherwise SAFECOOKIE./g' src/torcontrol.cpp
sed -i 's/tor: Using nullptr authentication/tor: Using NULL authentication/g' src/torcontrol.cpp
sed -i 's/METHODS=nullptr/METHODS=NULL/g' src/test/torcontrol_tests.cpp src/torcontrol.cpp
sed -i 's/nullptr certificates/NULL certificates/g' src/qt/paymentserver.cpp
sed -i 's/"nullptr"/"NULL"/g' src/torcontrol.cpp src/test/torcontrol_tests.cpp
-END VERIFY SCRIPT-
7 years ago
Jack Grigg
1ce9f0a952
Ensure that ECDSA constant sizes are correctly-sized
7 years ago
Jack Grigg
48abe78e51
Remove redundant `= 0` initialisations
7 years ago
Jack Grigg
17fa3913ef
Specify ECDSA constant sizes as constants
7 years ago
Jack Grigg
e181dbe748
Add comments
7 years ago
Jack Grigg
a3603ac6f0
Fix potential overflows in ECDSA DER parsers
7 years ago
Jeremy Rubin
30ac7688e3
Fix subscript[0] potential bugs in key.cpp
7 years ago
practicalswift
b51aaf1c42
Remove unused C++ code not covered by unit tests
8 years ago
isle2983
27765b6403
Increment MIT Licence copyright header year on files modified in 2016
...
Edited via:
$ contrib/devtools/copyright_header.py update .
8 years ago
Wladimir J. van der Laan
f4d1fc259b
wallet: Get rid of LockObject and UnlockObject calls in key.h
...
Replace these with vectors allocated from the secure allocator.
This avoids mlock syscall churn on stack pages, as well as makes
it possible to get rid of these functions.
Please review this commit and the previous one carefully that
no `sizeof(vectortype)` remains in the memcpys and memcmps usage
(ick!), and `.data()` or `&vec[x]` is used as appropriate instead of
&vec.
8 years ago
Pavel Janík
4731cab8fb
Do not shadow variables
8 years ago
Pieter Wuille
fa2637a3be
Always require OS randomness when generating secret keys
9 years ago
Jonas Schnelli
90604f16af
add bip32 pubkey serialization
...
CExtPubKey should be serializable like CPubKey
9 years ago
MarcoFalke
fa24439ff3
Bump copyright headers to 2015
9 years ago
Pieter Wuille
48edf5746a
Update key.cpp to new secp256k1 API
9 years ago
Wladimir J. van der Laan
6a877e870e
Merge pull request #6034
...
a574899
chaincodes: abstract away more chaincode behavior [squashme] replace struct CCainCode with a typedef uint256 ChainCode (Cory Fields)
8cf1485
Abstract chaincodes into CChainCode (Pieter Wuille)
10 years ago
Cory Fields
a574899671
chaincodes: abstract away more chaincode behavior
...
[squashme] replace struct CCainCode with a typedef uint256 ChainCode
10 years ago
Pieter Wuille
a56054be65
Update key.cpp to use new libsecp256k1
...
libsecp256k1's API changed, so update key.cpp to use it.
Libsecp256k1 now has explicit context objects, which makes it completely thread-safe.
In turn, keep an explicit context object in key.cpp, which is explicitly initialized
destroyed. This is not really pretty now, but it's more efficient than the static
initialized object in key.cpp (which made for example bitcoin-tx slow, as for most of
its calls, libsecp256k1 wasn't actually needed).
This also brings in the new blinding support in libsecp256k1. By passing in a random
seed, temporary variables during the elliptic curve computations are altered, in such
a way that if an attacker does not know the blind, observing the internal operations
leaks less information about the keys used. This was implemented by Greg Maxwell.
10 years ago
Pieter Wuille
8cf1485f3b
Abstract chaincodes into CChainCode
...
# Conflicts:
# src/key.cpp
# src/key.h
10 years ago
Pieter Wuille
437ada3e55
Switch test case signing to RFC6979 extra entropy
...
Instead of manually tweaking the deterministic nonce post-generation,
pass the test case number in as extra entropy to RFC6979.
10 years ago
Cory Fields
16a58a8644
keys: remove libsecp256k1 verification until it's actually supported
...
This was added a while ago for testing purposes, but was never intended to be
used. Remove it until upstream libsecp256k1 decides that verification is
stable/ready.
10 years ago
Pieter Wuille
1a9576de9d
Use libsecp256k1's RFC6979 implementation
10 years ago