Commit Graph

288 Commits

Author SHA1 Message Date
moneromooo-monero 54fd97ae3f
slow-hash: fix CNv2+ on big endian 2019-09-04 14:53:59 +00:00
Lev Sizov 4ad191ffa9 Removed unused boost/value_init header 2019-09-02 14:38:29 +02:00
Jesus Ramirez 2cd4fd8972 Changed the use of boost:value_initialized for C++ list initializer 2019-09-02 14:16:29 +02:00
luigi1111 8f6f674753
Merge pull request #5609
1dc3b1a wallet: add --extra-entropy command line flag (moneromooo-monero)
2019-08-27 15:14:15 -05:00
moneromooo-monero 1dc3b1a516
wallet: add --extra-entropy command line flag
It lets the user add custom entropy to the PRNG.
It does this by hashing the new data and xoring the resulting
hash with the PRNG state.
2019-08-22 11:12:57 +00:00
luigi1111 0a42fddde4
Merge pull request #5807
4b1df4e Fix for biased signature nonce (SarangNoether)
2019-08-21 15:38:35 -05:00
luigi1111 8956e90c63
Merge pull request #5731
c393e82 CryptonightR_JIT: fix return value on error (selene-kovri)
2019-08-21 15:09:48 -05:00
Sarang Noether 4b1df4e50f Fix for biased signature nonce 2019-08-12 15:58:15 -04:00
luigi1111 bb37e434fc
Merge pull request #5624
6b41bd8 Delete more include string.h (wepeng)
2019-07-24 14:39:40 -05:00
luigi1111 e3de4aa68b
Merge pull request #5502
25a7cfd add a few checks where it seems appropriate (moneromooo-monero)
1a66a86 remove unused code (moneromooo-monero)
2019-07-24 13:57:06 -05:00
moneromooo-monero c2238327d0
keccak: guard against misaligned memory accesses on ARM
The code generated is exactly the same as the direct access
one on x86_64
2019-07-04 22:13:16 +00:00
selene c393e824d6 CryptonightR_JIT: fix return value on error
The value was positive rather than zero, but the caller only
checks for negative errors
2019-07-04 12:49:54 +01:00
moneromooo-monero 0564da5fdc
ensure no NULL is passed to memcpy
NULL is valid when size is 0, but memcpy uses nonnull attributes,
so let's not poke the bear
2019-06-14 08:47:29 +00:00
moneromooo-monero a00cabd4f3
tree-hash: allocate variable memory on heap, not stack
Large amounts might run out of stack

Reported by guidov
2019-06-14 08:47:20 +00:00
Your Name 6b41bd8eb5 Delete more include string.h 2019-06-11 16:08:42 +08:00
moneromooo-monero 1a66a86f94
remove unused code 2019-04-29 20:52:40 +00:00
stoffu a2195b9b7f
crypto: replace rand<T>()%N idiom with unbiased rand_idx(N) 2019-04-04 22:38:19 +09:00
Nathan Dorfman 9f49722c4d Fix build on FreeBSD 2019-03-24 01:12:06 -06:00
Riccardo Spagni 6c0c7d796d
Merge pull request #5252
7ac33342 slow-hash: cache TLS references locally once at function start (moneromooo-monero)
2019-03-21 14:48:24 +02:00
Riccardo Spagni 39107e18d5
Merge pull request #5251
7632dede crypto: fix PaX issue on NetBSD with CNv4 JIT (moneromooo-monero)
89b1630e gtest: build fix for NetBSD (moneromooo-monero)
fa43b547 tests: handle any cmake detected python interpreter (moneromooo-monero)
2019-03-21 14:47:43 +02:00
Riccardo Spagni 56feda84d3
Merge pull request #5250
a48e49aa aesb: avoid stomping on an existing define on NetBSD (moneromooo-monero)
2019-03-21 14:47:11 +02:00
Riccardo Spagni f9b1c4f962
Merge pull request #5213
efb2bdd3 slow-hash: default to JIT on x86_64 (moneromooo-monero)
2019-03-21 14:44:26 +02:00
Riccardo Spagni 48e3a341f8
Merge pull request #5211
c9b13fbb tests/trezor: HF9 and HF10 tests (Dusan Klinec)
a1fd1d49 device/trezor: HF10 support added, wallet::API (Dusan Klinec)
d74d26f2 crypto: hmac_keccak added (Dusan Klinec)
2019-03-21 14:44:04 +02:00
moneromooo-monero efb2bdd309
slow-hash: default to JIT on x86_64 2019-03-21 11:29:08 +00:00
Dusan Klinec d74d26f2c9
crypto: hmac_keccak added 2019-03-20 21:11:01 +01:00
Riccardo Spagni c3de019f56
Merge pull request #5192
d0e07b3d performance_tests: fix NetBSD build (moneromooo-monero)
7d88d8f2 discontinue use of alloca (moneromooo-monero)
2019-03-17 17:56:52 +02:00
moneromooo-monero 7ac3334217
slow-hash: cache TLS references locally once at function start 2019-03-07 18:11:19 +00:00
moneromooo-monero 7632dede7b
crypto: fix PaX issue on NetBSD with CNv4 JIT 2019-03-07 16:46:02 +00:00
moneromooo-monero a48e49aa36
aesb: avoid stomping on an existing define on NetBSD 2019-03-07 16:08:00 +00:00
binaryFate 1f2930ce0b Update 2019 copyright 2019-03-05 22:05:34 +01:00
moneromooo-monero 108c625b3f
CryptonightR: define out i386/x86_64 specific code on other archs 2019-03-05 10:24:24 +00:00
moneromooo-monero 1b8757dddc
slow-hash: fix build on arm 2019-03-05 10:24:24 +00:00
moneromooo-monero 0de14396b9
tests: add a CNv4 JIT test 2019-03-04 11:56:55 +00:00
moneromooo-monero 24d281c324
crypto: plug CNv4 JIT into cn_slow_hash
Enabled by setting the MONERO_USE_CNV4_JIT env var to 1
2019-03-04 11:56:55 +00:00
moneromooo-monero 78ab59ea44
crypto: clear cache after generating random program 2019-03-04 11:56:46 +00:00
SChernykh fff23bf7c6
CNv4 JIT compiler for x86-64 and tests
Minimalistic JIT code generator for random math sequence in CryptonightR.

Usage:
- Allocate writable and executable memory
- Call v4_generate_JIT_code with "buf" pointed to memory allocated on the previous step
- Call the generated code instead of "v4_random_math(code, r)", omit the "code" parameter
2019-03-04 11:56:29 +00:00
moneromooo-monero 7d88d8f27c
discontinue use of alloca
NetBSD emits:
warning: Warning: reference to the libc supplied alloca(3); this most likely will not work. Please use the compiler provided version of alloca(3), by supplying the appropriate compiler flags (e.g. not -std=c89).

and man 3 alloca says:

       Normally,  gcc(1)  translates  calls  to  alloca()  with  inlined code.  This is not done when either the -ansi, -std=c89, -std=c99, or the
       -std=c11 option is given and the header <alloca.h> is not included.  Otherwise, (without an -ansi or -std=c* option) the glibc  version  of
       <stdlib.h> includes <alloca.h> and that contains the lines:

           #ifdef  __GNUC__
           #define alloca(size)   __builtin_alloca (size)
           #endif

It looks like alloca is a bad idea in modern C/C++, so we use
VLAs for C and std::vector for C++.
2019-02-25 11:11:07 +00:00
SChernykh f1fb06b137 Fixed path to int-util.h 2019-02-14 20:46:56 +01:00
SChernykh 9da0892b10 Adding cnv4-2 tweaks
Co-Authored-By: Lee Clagett <vtnerd@users.noreply.github.com>
2019-02-14 20:42:50 +01:00
SChernykh f51397b306 Cryptonight variant 4 aka CryptonightR
It introduces random integer math into the main loop.
2019-02-14 11:29:54 +01:00
moneromooo-monero ec1a62b50d
move int-util.h to epee 2018-12-04 15:14:29 +00:00
Riccardo Spagni c00ac446fd
Merge pull request #4854
bd98e99c Removed a lot of unnecessary includes (Martijn Otto)
2018-12-04 17:08:42 +02:00
xiphon 2a48c2a286
slow-hash: some more big endian fixes 2018-11-16 09:58:41 +00:00
moneromooo-monero b39fdf8ebe
slow-hash: fix for big endian 2018-11-16 09:58:38 +00:00
Martijn Otto bd98e99c80
Removed a lot of unnecessary includes 2018-11-15 17:29:34 +01:00
Riccardo Spagni 92c5a892b5
Merge pull request #4757
db24a2e5 hash: fix hash_permutation on big endian (moneromooo-monero)
2018-11-14 21:34:09 +02:00
Riccardo Spagni 8ba3f89b44
Merge pull request #4755
42d8d508 crypto: fix AES encryption on big endian (xiphon)
2018-11-14 21:33:38 +02:00
Riccardo Spagni 267b5d8807
Merge pull request #4711
c4fbfd78 Small function declaration cleanup in slow-hash.c (Pol Mauri)
2018-11-06 14:51:23 +02:00
xiphon 42d8d5085e crypto: fix AES encryption on big endian 2018-10-31 03:13:55 +00:00
moneromooo-monero db24a2e509
hash: fix hash_permutation on big endian 2018-10-29 22:26:44 +00:00
xiphon ba0faae789 crypto: fixed groestl on big-endian platforms 2018-10-25 02:06:23 +00:00
Pol Mauri c4fbfd786a Small function declaration cleanup in slow-hash.c
- These functions are declared twice in slow-hash.c. Remove one of the copies.
- The declarations have the wrong return type, should be void, not int.

Function definitions here: 1e74586ee9/src/crypto/aesb.c (L151-L180)
Test plan: make release-test
2018-10-23 23:19:52 -07:00
xiphon ed36335c96 crypto: fixed incremental keccak API on big-endian platforms 2018-10-22 18:34:19 +03:00
Riccardo Spagni 2ec0d780c4
Merge pull request #4449
17142ec9 malloc scratchpad for all supported android archs (m2049r)
2018-09-29 22:20:24 +02:00
Riccardo Spagni fb47963e09
Merge pull request #4404
f3cd51a1 cryptonote tweak v2.2 (Lee Clagett)
2018-09-22 20:32:40 +02:00
Lee Clagett f3cd51a12b cryptonote tweak v2.2 2018-09-22 03:47:50 +00:00
Riccardo Spagni aa1d321e5f
Merge pull request #4395
9bf0105e Fixed Keccak implementation on big-endian platforms (Alexandro Sanchez)
2018-09-21 20:45:23 +02:00
Riccardo Spagni df98bc50a6
Merge pull request #4357
8501b8df crypto_ops_builder: link to EdDSA/Ed25519 draft RFC (moneromooo-monero)
2018-09-18 17:57:45 +02:00
Alexandro Sanchez 9bf0105e25 Fixed Keccak implementation on big-endian platforms 2018-09-17 18:24:20 +02:00
Riccardo Spagni 9f24e57dc2
Merge pull request #4326
bcda7adc NetBSD support (thomasvaughan)
2018-09-14 13:02:58 +02:00
thomasvaughan bcda7adcd4 NetBSD support 2018-09-11 14:32:33 +00:00
Riccardo Spagni e6d36c1701
Merge pull request #4219
9137ad2c blockchain: add a testnet v9 a day after v8 (moneromooo-monero)
ac4f71c2 wallet2: bump testnet rollback to account for coming reorg (moneromooo-monero)
8f418a6d bulletproofs: #include <openssl/bn.h> (moneromooo-monero)
2bf63650 bulletproofs: speed up the latest changes a bit (moneromooo-monero)
044dff5a bulletproofs: scale points by 8 to ensure subgroup validity (moneromooo-monero)
c83012c4 bulletproofs: match aggregated verification to sarang's latest prototype (moneromooo-monero)
ce0c7432 performance_tests: add padded bulletproof construction (moneromooo-monero)
1224e53b core_tests: add a test for 4-aggregated BP verification (moneromooo-monero)
0e6ed559 fuzz_tests: add a bulletproof fuzz test (moneromooo-monero)
463434d1 more comprehensive test for ge_p3 comparison to identity/point at infinity (moneromooo-monero)
d0a0565f unit_tests: add a few more multiexp unit tests (moneromooo-monero)
6526d87f core_tests: add a test for a tx with empty bulletproof (moneromooo-monero)
a129bbd9 multiexp: fix maxscalar off by one (moneromooo-monero)
7ed496cc ringct: error out when hashToPoint* returns the point at infinity (moneromooo-monero)
d1591853 cryptonote_basic: check output type before using it (moneromooo-monero)
61632dc1 ringct: prevent a potential very large allocation (moneromooo-monero)
a4317e61 crypto: some paranoid checks in generate_signature/check_signature (moneromooo-monero)
7434df1c crypto: never return zero in random32_unbiased (moneromooo-monero)
0825e974 multiexp: fix wrong Bos-Coster result for 1 non trivial input (moneromooo-monero)
a1359ad4 Check inputs to addKeys are in range (moneromooo-monero)
fe0fa3b9 bulletproofs: reject x, y, z, or w[i] being zero (moneromooo-monero)
5ffb2ff9 v8: per byte fee, pad bulletproofs, fixed 11 ring size (moneromooo-monero)
869b3bf8 bulletproofs: a few fixes from the Kudelski review (moneromooo-monero)
c4291762 bulletproofs: reject points not in the main subgroup (moneromooo-monero)
15697177 bulletproofs: speed up a few multiplies using existing Hi cache (moneromooo-monero)
0b05a0fa Add Pippenger cache and limit Straus cache size (moneromooo-monero)
51eb3bdc add pippenger unit tests (moneromooo-monero)
b17b8db3 performance_tests: add stats and loop count multiplier options (moneromooo-monero)
7314d919 perf_timer: split timer class into a base one and a logging one (moneromooo-monero)
d126a02b performance_tests: add aggregated bulletproof tx verification (moneromooo-monero)
263431c4 Pippenger multiexp (moneromooo-monero)
1ed0ed4d multiexp: cut down on memory allocations (moneromooo-monero)
1b867e7f precalc the ge_p3 representation of H (moneromooo-monero)
ef56529f performance_tests: document the tested bulletproof layouts (moneromooo-monero)
30111780 unit_tests: a couple more bulletproof unit tests for gamma (moneromooo-monero)
c444b1b2 require canonical multi output bulletproof layout (moneromooo-monero)
7e67c52f Add a define for the max number of bulletproof multi-outputs (moneromooo-monero)
2a8fcb42 Bulletproof aggregated verification and tests (moneromooo-monero)
126196b0 multiexp: some speedups (moneromooo-monero)
71d67bda aligned: aligned memory alloc/realloc/free (moneromooo-monero)
cb9ecab1 performance_tests: add signature generation/verification (moneromooo-monero)
bacf0a1e bulletproofs: add aggregated verification (moneromooo-monero)
e895c3de make straus cached mode thread safe, and add tests for it (moneromooo-monero)
7f48bf05 multiexp: bos coster now works for just one point (moneromooo-monero)
9ce9f8ca bulletproofs: add multi output bulletproofs to rct (moneromooo-monero)
f34e2e20 performance_tests: add tx checking tests with more than 2 outputs (moneromooo-monero)
0793184b performance_tests: add a --verbose flag, and default to terse (moneromooo-monero)
939bc223 add Straus multiexp (moneromooo-monero)
9ff6e6a0 ringct: add bos coster multiexp (moneromooo-monero)
e9164bb3 bulletproofs: misc optimizations (moneromooo-monero)
112f32f0 performance_tests: add crypto ops (moneromooo-monero)
f5d7b993 performance_tests: add bulletproofs (moneromooo-monero)
8f4ce989 performance_tests: add RingCT MLSAG gen/ver tests (moneromooo-monero)
1aa10c43 performance_tests: add (Borromean) range proofs (moneromooo-monero)
aacfd6e3 bulletproofs: multi-output bulletproofs (moneromooo-monero)
cb1cc757 performance_tests: don't override log level to 0 (moneromooo-monero)
2018-09-11 15:45:56 +02:00
moneromooo-monero 463434d1f7
more comprehensive test for ge_p3 comparison to identity/point at infinity
Reported by QuarksLab.
2018-09-11 13:38:20 +00:00
moneromooo-monero a4317e61b5
crypto: some paranoid checks in generate_signature/check_signature
Reported by QuarksLab.
2018-09-11 13:38:12 +00:00
moneromooo-monero 7434df1cc6
crypto: never return zero in random32_unbiased
This avoids problems when the caller can't deal with a zero
walue, which happens often enough that it's worth nipping the
problem in the bud.
2018-09-11 13:38:12 +00:00
moneromooo-monero 869b3bf824
bulletproofs: a few fixes from the Kudelski review
- fix integer overflow in n_bulletproof_amounts
- check input scalars are in range
- remove use of environment variable to tweak straus performance
- do not use implementation defined signed shift for signum
2018-09-11 13:38:05 +00:00
moneromooo-monero 1b867e7f40
precalc the ge_p3 representation of H 2018-09-11 13:37:42 +00:00
Riccardo Spagni f0ab4dc7b2
Merge pull request #4218
5fd83c13 Cryptonight variant 2 (SChernykh)
2018-09-11 15:22:25 +02:00
SChernykh 5fd83c13fb Cryptonight variant 2
Contains two modifications to improve ASIC resistance: shuffle and integer math.

Shuffle makes use of the whole 64-byte cache line instead of 16 bytes only, making Cryptonight 4 times more demanding for memory bandwidth.

Integer math adds 64:32 bit integer division followed by 64 bit integer square root, adding large and unavoidable computational latency to the main loop.

More details and performance numbers: https://github.com/SChernykh/xmr-stak-cpu/blob/master/README.md
2018-09-09 20:43:01 +02:00
moneromooo-monero 8501b8dffb
crypto_ops_builder: link to EdDSA/Ed25519 draft RFC
instead of including the text, as it's not fully free to redistribute
2018-09-09 16:18:49 +00:00
luigi1111 e4378ed8aa
Merge pull request #4259
4e08100 Incremental Keccak API added (pr4r05)
2018-09-04 13:09:48 -05:00
moneromooo-monero d2e26c23f3
add and use constant time 32 byte equality function 2018-08-23 07:56:51 +00:00
moneromooo-monero ab74dc277a
crypto: make secret_key automatically mlock 2018-08-16 11:57:49 +00:00
luigi1111 5295e4eb82
Merge pull request #4137
63e342b crypto: move null_pkey/null_skey to the cpp file (moneromooo-monero)
0496c7c crypto: do not use boost::value_initialized to init null skey/pkey (moneromooo-monero)
2018-08-15 17:17:34 -05:00
Dusan Klinec 4e081001c0
Incremental Keccak API added
- needed for TREZOR integration
2018-08-15 18:20:22 +02:00
stoffu bcab579864
wallet: allow adjusting number of rounds for the key derivation function 2018-08-08 01:56:54 +09:00
luigi1111 3fde902394
Merge pull request #4097
61caab8 crypto: remove slight bias in key generation due to modulo (moneromooo-monero)
2018-07-27 14:23:54 -05:00
moneromooo-monero 0496c7c91a
crypto: do not use boost::value_initialized to init null skey/pkey 2018-07-20 23:06:22 +01:00
luigi1111 326437c5ff
Merge pull request #4074
ef649f9 crypto: remove unused unsafe random scalar generator (moneromooo-monero)
2018-07-19 14:08:56 -05:00
luigi1111 94ed562148
Merge pull request #4045
7cdd147 Changed URLs to HTTPS (einsteinsfool)
2018-07-19 13:56:38 -05:00
moneromooo-monero 63e342be84
crypto: move null_pkey/null_skey to the cpp file 2018-07-15 19:09:36 +01:00
moneromooo-monero 61caab8a8c
crypto: remove slight bias in key generation due to modulo 2018-07-05 09:18:01 +01:00
moneromooo-monero ef649f998d
crypto: remove unused unsafe random scalar generator 2018-06-28 16:44:13 +01:00
einsteinsfool 7cdd147da5 Changed URLs to HTTPS 2018-06-23 21:15:29 +02:00
moneromooo-monero 09f43b9a6b
crypto: add a README pointing to the SUPERCOP licence 2018-06-18 21:28:08 +01:00
luigi1111 b6eb7484d1
Merge pull request #3592
90a16b1 crypto: fix initialization order issue with random mutex (moneromooo-monero)
6a61f52 unit_tests: add ringdb unit tests (moneromooo-monero)
2018-05-31 14:41:17 -05:00
moneroexamples 9317bce9ca
crypto: more places needing fixing for GCC 8.1 2018-05-13 18:17:13 +01:00
moneromooo-monero 4a72d595a6
chacha: fix build with GCC 8.1 2018-05-13 18:17:11 +01:00
aivve b1a9e97b2d
slow-hash: fix memory leak for Windows /karbowanec#41 2018-04-24 20:47:29 +09:00
moneromooo-monero 90a16b119f
crypto: fix initialization order issue with random mutex 2018-04-10 12:30:48 +01:00
stoffu 7dfa5e9e6e
chacha: call prehashed version explicitly as generate_chacha_key_prehashed
hash: add prehashed version cn_slow_hash_prehashed
slow-hash: let cn_slow_hash take 4th parameter for deciding prehashed or not
slow-hash: add support for prehashed version for the other 3 platforms
2018-03-14 21:00:17 +09:00
stoffu b2d23b189e
crypto: revert odd namespace changes made in #3303 2018-03-14 21:00:17 +09:00
stoffu 27a196b126
device: untangle cyclic depenency
When #3303 was merged, a cyclic dependency chain was generated:

    libdevice <- libcncrypto <- libringct <- libdevice

This was because libdevice needs access to a set of basic crypto operations
implemented in libringct such as scalarmultBase(), while libringct also needs
access to abstracted crypto operations implemented in libdevice such as
ecdhEncode(). To untangle this cyclic dependency chain, this patch splits libringct
into libringct_basic and libringct, where the basic crypto ops previously in
libringct are moved into libringct_basic. The cyclic dependency is now resolved
thanks to this separation:

    libcncrypto <- libringct_basic <- libdevice <- libcryptonote_basic <- libringct

This eliminates the need for crypto_device.cpp and rctOps_device.cpp.

Also, many abstracted interfaces of hw::device such as encrypt_payment_id() and
get_subaddress_secret_key() were previously implemented in libcryptonote_basic
(cryptonote_format_utils.cpp) and were then called from hw::core::device_default,
which is odd because libdevice is supposed to be independent of libcryptonote_basic.
Therefore, those functions were moved to device_default.cpp.
2018-03-14 21:00:15 +09:00
stoffu c9b38b4765
device: made function prototypes consistent with pre-#3303 codebase 2018-03-14 21:00:06 +09:00
moneromooo-monero 04a0cc89cf
slow-hash: fix uint64 type typo 2018-03-07 09:48:58 +00:00
Lee Clagett e136bc6b8a
tweaks to the monerov1 cryptonight algorithm 2018-03-05 18:18:45 +00:00
SChernykh d58c9ec99c
slow-hash: optimized version 2018-03-05 18:18:43 +00:00
moneromooo-monero 608fd6f14a
Monero Cryptonight variants, and add one for v7
This is the first variant of many, with the intent to improve
Monero's resistance to ASICs and encourage mining decentralization.
2018-03-05 18:18:39 +00:00
Edward Betts fbcc91c2a4 Correct spelling mistakes. 2018-03-05 17:00:40 +00:00
cslashm e745c1e38d Code modifications to integrate Ledger HW device into monero-wallet-cli.
The basic approach it to delegate all sensitive data (master key, secret
ephemeral key, key derivation, ....) and related operations to the device.
As device has low memory, it does not keep itself the values
(except for view/spend keys) but once computed there are encrypted (with AES
are equivalent) and return back to monero-wallet-cli. When they need to be
manipulated by the device, they are decrypted on receive.

Moreover, using the client for storing the value in encrypted form limits
the modification in the client code. Those values are transfered from one
C-structure to another one as previously.

The code modification has been done with the wishes to be open to any
other hardware wallet. To achieve that a C++ class hw::Device has been
introduced. Two initial implementations are provided: the "default", which
remaps all calls to initial Monero code, and  the "Ledger", which delegates
all calls to Ledger device.
2018-03-04 12:54:53 +01:00