Commit graph

13083 commits

Author SHA1 Message Date
Jason Rhinelander
7151ccf0f9 Remove long-done TODO 2020-12-01 23:53:32 -04:00
Jason Rhinelander
8297b051f7 Use send_u32 2020-11-30 00:47:12 -04:00
Jason Rhinelander
343687dd6e Fix buggy, wrong command IDs
Monero's codes are extremely broken (relative to Monero's own ledger app
code) with wrong codes, omissions, and status codes that don't exist at
all.
2020-11-30 00:47:12 -04:00
Jason Rhinelander
7ecab90008 Clean up how options get set with VALIDATE 2020-11-30 00:47:12 -04:00
Jason Rhinelander
540d097810 Improve crappy ledger C++ code
Fixes lots of crappy C++ code.  I strongly get the impression from these
changes that whoever wrote this code was a C programmer with very little
C++ experience.  Sadly no one in the upstream Monero PR review tried to
help or seemed to care about the code quality.

- Get rid of superfluous `this->` throughout the ledger code.
- DRY: abstract away sending sequences of bytes, replacing:
    memmove(buffer, this->buffer_send+offset, 32);
    offset += 32
  with:
    send_bytes(buffer, 32, offset);
- DRY: abstract sending/receiving u32
- DRY: abstract receiving bytes/u32
- properly prefix memcpy/memmove with std::
- use std::string_view and std::string for setting/retrieving name
- rename `this->controle_device` to `debug_device`
- replace `f(void)` -> `f()` (on C++ methods, FFS!)
- DRY: replace set-length-then-exchange dance with a function
- DRY: merge nearly-identical exchange() and exchange_wait_for_input()
- remove never-used ok/mask arguments from exchange()
- Remove ASSERT_SW macro used only in one place
- Replace dumb ASSERT_X macro that was just an alias for another macro
- remove ASSERT_T0 macro that isn't used anywhere
2020-11-30 00:47:12 -04:00
Jason Rhinelander
1b97f37e35 Ledger: don't send nulls for no reason
don't send 32 null bytes for no reason in INS_GEN_TXOUT_KEYS when there
is no additional txkey    (this doesn't even match the case when there
is one since we send it encrypted, requiring 64 bytes).
2020-11-30 00:47:12 -04:00
Jason Rhinelander
a56284e311 Switch version strings to string_view's 2020-11-30 00:47:12 -04:00
Jason Rhinelander
3eeb295f16 Code cleanups 2020-11-30 00:47:12 -04:00
Jason Rhinelander
591c828aa2 Improve CMD debugging
- Show the instruction name (in debug builds)
- annotate the byte values
2020-11-30 00:47:12 -04:00
Jason Rhinelander
7214a29211 Clean up more nasty C code 2020-11-30 00:47:12 -04:00
Jason Rhinelander
f6ba1a465e Add cmd response time to debugging log output 2020-11-30 00:47:12 -04:00
Jason Rhinelander
87fe444303 Don't calculate CLSAG c on the device
It's slow and unnecessary and depends on no keys in the hardware wallet
(c is public info in CLSAG).  If the wallet was to provide a changed c
value then verification would simply fail.
2020-11-30 00:47:12 -04:00
Jason Rhinelander
d87a91bfc8 Revert protocol version to 1 2020-11-30 00:47:12 -04:00
Jason Rhinelander
e408a3c991 Clean up HW debug code
The hard wallet debug code had no way to enable it, and if you did
manually add the define, didn't compile.  It was also nasty, gross,
disgusting code that someone slopped into the file.

This fixes it, adds a cmake option for it, and significantly cleans it
up--just because code is for debugging doesn't mean it should be nasty
and broken.
2020-11-30 00:47:12 -04:00
Jason Rhinelander
2525ab4d0d Ledger: Revise/fix/optimize data chunk transmission
- Sending one 32-byte key at a time is noticeably slower than sending in
  larger chunks.
- Sending in 256-byte chunks was broken because the size field is only
  254 bytes.  Since we are actually sending these for Keccak, it makes
  some sense to chunk it at 136 bytes (i.e. keccak block size).
- Change how multipart works to send as parts 1->2->...->0.  Previously
  0xff (rather than 0) marked the last chunk.
- Allow multi-part chunks to wrap by wrapping the part after 255 to 1
  (skipping 0 since that now means "last").
- Use multi-part chunk scheme for CLSAG in addition to prefix hashing.
2020-11-30 00:47:12 -04:00
Jason Rhinelander
4a9767ead3 Reformat length function signatures
Function signatures (especially in headers) should be readable!

Also removes useless "const" on pass-by-value parameters from headers,
and pass the bool argument by value instead of by const lvalue
reference.
2020-11-30 00:47:12 -04:00
Jason Rhinelander
b810732058 Ledger: Remove obsolete MLSAG instruction 2020-11-30 00:47:12 -04:00
Jason Rhinelander
165d753e87 Remove Borromean generation
Like MLSAG, this code is no longer used (or usable) since HF16.
2020-11-30 00:47:12 -04:00
Jason Rhinelander
34c9e203de Remove epee scope handler from core code
We have a much nicer LOKI_DEFER replacement.
2020-11-30 00:47:12 -04:00
moneromooo-monero
bfb090227c use memwipe on secret k/alpha values
Reported by UkoeHB_ and sarang
2020-11-30 00:47:12 -04:00
Jason Rhinelander
1cceb8859e Add helpful message to error string
A few times I've connected my test Ledger but forgotten to open the app,
and then had connection failures without any indicating of what went
wrong (just "No device found").  This adds "(Is the device running with
the wallet app opened?)" to that error message as that is likely often
the culprit.
2020-11-30 00:47:12 -04:00
Jason Rhinelander
f971a7a464 Fix ringct tests
- 0 outputs is not valid post-Borromean. This was passing before because
previously the tests were using Borromean ringct construction.
- Remove and fix non-bulletproof/clsag tests which can't run anymore
(since we can't construct pre-clsag).
2020-11-30 00:47:12 -04:00
Jason Rhinelander
d757bddd8c Fix dumb parameters
Passing in a true/false value is dumb, we should just call
EXPECT_TRUE/EXPECT_FALSE rather than `EXPECT_TRUE(...(true, ...` or
`EXPECT_TRUE(...(false, ...`

Passing the fee in the output array and then taking it out of the output
array is similarly stupid, so don't do that either.
2020-11-30 00:47:12 -04:00
Jason Rhinelander
e35db12bd9 Fix CLSAG broken test
single 0 input with no outputs is not acceptable in post-Borromean.
2020-11-30 00:47:12 -04:00
Jason Rhinelander
9b7570ca25 ringct tests: Update ringct type to CLSAG
We can't construct pre-CLSAG anymore.
2020-11-30 00:47:12 -04:00
Jason Rhinelander
6e66053bde Fix inconsistent indenting
This one file used 2, 4, and 8 space indenting in different parts.  Fix
it.

(Only whitespace changes).
2020-11-30 00:47:12 -04:00
Jason Rhinelander
05c144aee0 Rename serialization test category for consistency
The vast majority of the tests use lower_case_category.lower_case_test,
but Serialization did it differently for no reason (and even then wasn't
consistent with the test names).  Fix that.
2020-11-30 00:47:12 -04:00
Jason Rhinelander
67f4e990d2 Remove MLSAG generation
The blockchain only accepts CLSAG txes now, so no need to keep the MLSAG
generation code around.  (MLSAG verification stays, of course).
2020-11-30 00:47:12 -04:00
Jason Rhinelander
16bb065f53 Split up and DRY Modernize and DRY ringct serialization tests
One big blob with 50 tests in it was stupid because you have no clue
what failed when something fails.
2020-11-30 00:47:12 -04:00
Jason Rhinelander
93e036eba6 Remove epee::to_hex::formatted 2020-11-30 00:47:12 -04:00
Jason Rhinelander
2531afd4d0 Reduce header use
- Replace <cinttypes> with more limited <cstdint>
- avoid epee for hex conversion
- don't include <iostream>
2020-11-30 00:47:12 -04:00
Jason Rhinelander
5f51c29646 Remove impossible code
This is dead code as the previous if is always entered for CLSAG.  The
body of this is applied later in the function, so this looks like code
that got moved but the original didn't get deleted?
2020-11-30 00:47:12 -04:00
Jason Rhinelander
cf683a0928 Fix LNS test in debug build
The capital Z here fails an assert in loki_name_system.cpp; lower-case
it to fix the test.
2020-11-30 00:47:12 -04:00
Jason Rhinelander
e8a340e9be Make RingCT and RangeProof types type-safe enum classes 2020-11-30 00:47:12 -04:00
Jason Rhinelander
d39afe00ea Remove mlsag generation
The blockchain doesn't accept MLSAG txes anymore (since HF16 + 10
blocks), so there is no need to keep the generation code around.

Also renames mlsag_prehash to clsag_prehash since that is where it is
primarily used now.
2020-11-30 00:47:12 -04:00
Jason Rhinelander
ca64e46e86 Compilation fixes 2020-11-30 00:47:12 -04:00
Jason Rhinelander
d6c77b2286 Allow prompting for restore height for hw wallet
For no good reason the hardware wallet creation didn't allow you to
specify a restore height from the cli wallet for no good reason.  This
commit lets it use the same prompt, and improves the prompt somewhat:

- you can now specify `curr` to use the current blockchain height (and
this is the default for the hardware wallet).

- added a note about the purpose of the restore height (i.e. that
transactions won't be seen if before the restore height).

- put example values in the description.

- show the default in the prompt.
2020-11-30 00:47:12 -04:00
Jason Rhinelander
51fcbec72e GUI hardware wallet support
- Adds "create_wallet" rpc arguments to allow creating a hardware wallet

- Adds a "create-hwdev" option to both rpc and cli wallets that creates
a "[wallet].hwdev.txt" file containing an optional comment to flag the
wallet as a hardware wallet.  Although this data is present in the
wallet file itself, that isn't available without a password description
and the the GUI wallet needs to know this *before* it opens the wallet
to properly display a wallet list with some indicators for hardware
wallets.  The comment also lets the user record some optional comment
such as "Jason's Ledger Nano S" to serve as a reminder in the GUI wallet
list.

- Fixes some unicode EN DASHes that got added to documentation comments
in place of the intended hyphens.
2020-11-30 00:47:12 -04:00
Jason Rhinelander
ad7e63a04f Overhaul tx prefix comms; rename some overloaded methods
Tx prefix communication was missing some needed information on the tx
type, and was a little inefficient.  This redoes the protocol to send
the tx type info and then the entire prefix (rather than starting from a
few bytes in).  It also changes how we number requests and signal the
final piece of a multi-piece transmission.
2020-11-30 00:47:12 -04:00
Jason Rhinelander
d044ecd391 Improve cli wallet output with Ledger 2020-11-30 00:47:12 -04:00
Jason Rhinelander
754a9c12cf Ledger support updates
Loki-side updates for Ledger Nano S support:

- Add a get-network command (and bump protocol version) so that we can
verify that the Ledger is set to the correct network type (i.e. mainnet
or testnet).  Previously there was no check at all, so you could have a
testnet wallet on desktop using mainnet keys on the Ledger.  Now they
get checked and an error occurs on mismatch.

- Reset required version to 0.9.0
2020-11-30 00:47:12 -04:00
Jason Rhinelander
09f687f90d
Merge pull request #1362 from jagerman/fix-ed25519-restore
Fix ed25519 restore
2020-11-27 13:32:33 -04:00
Jason Rhinelander
6c50740375 Fix loki-sn-keys ed25519 key restoration
crypto_sign_seed_keypair() does not safely work when seed==sk, so read
and store the seed separately to fix it.
2020-11-27 13:26:36 -04:00
Jason Rhinelander
b54f8ae845 Fix abort not actually aborting
If the input gets EOF it was printing "Aborted" but then going ahead
anyway.
2020-11-27 13:25:25 -04:00
Jason Rhinelander
9dd56bdc43 Print to stderr to not break | jq . 2020-11-26 23:55:04 -04:00
Jason Rhinelander
8e049e563a Fix encrypted connections in utils/lmq-rpc.py
- Added client key generation if no curve pubkey is specified
- Fixed missing import causing an error if you tried to specify an
x25519 privkey
2020-11-26 23:52:16 -04:00
Jason Rhinelander
b6a83a49a5
Merge pull request #1359 from jagerman/remove-obsolete-json-serialization
Remove obsolete json serialization
2020-11-23 18:15:05 -04:00
Jason Rhinelander
141e8c0084 Make static variable pack code less nasty
A function-local static variable made up of a local struct is just
nasty; replace it with a simpler static struct.
2020-11-23 17:22:53 -04:00
Jason Rhinelander
6fabd5b70c Remove obsolete JSON serialization
This json serialization layer was only used in the old Monero ZMQ
interface, which no longer exists, and so this is just dead code.

On top of that, it doesn't work properly for serializing CLSAG
transactions, so just delete it.
2020-11-23 17:16:55 -04:00
Jason Rhinelander
77424b0edf 8.1.4 version bump 2020-11-19 22:56:17 -04:00