Commit Graph

60 Commits

Author SHA1 Message Date
moneromooo-monero
ff5626d785
ringct: handle exceptions verifying bulletproofs in worker threads 2018-01-15 11:48:23 +00:00
moneromooo-monero
4c313324b1
Add N/N multisig tx generation and signing
Scheme by luigi1111:

    Multisig for RingCT on Monero

    2 of 2

    User A (coordinator):
    Spendkey b,B
    Viewkey a,A (shared)

    User B:
    Spendkey c,C
    Viewkey a,A (shared)

    Public Address: C+B, A

    Both have their own watch only wallet via C+B, a

    A will coordinate spending process (though B could easily as well, coordinator is more needed for more participants)

    A and B watch for incoming outputs

    B creates "half" key images for discovered output D:
    I2_D = (Hs(aR)+c) * Hp(D)

    B also creates 1.5 random keypairs (one scalar and 2 pubkeys; one on base G and one on base Hp(D)) for each output, storing the scalar(k) (linked to D),
    and sending the pubkeys with I2_D.

    A also creates "half" key images:
    I1_D = (Hs(aR)+b) * Hp(D)

    Then I_D = I1_D + I2_D

    Having I_D allows A to check spent status of course, but more importantly allows A to actually build a transaction prefix (and thus transaction).

    A builds the transaction until most of the way through MLSAG_Gen, adding the 2 pubkeys (per input) provided with I2_D
    to his own generated ones where they are needed (secret row L, R).

    At this point, A has a mostly completed transaction (but with an invalid/incomplete signature). A sends over the tx and includes r,
    which allows B (with the recipient's address) to verify the destination and amount (by reconstructing the stealth address and decoding ecdhInfo).

    B then finishes the signature by computing ss[secret_index][0] = ss[secret_index][0] + k - cc[secret_index]*c (secret indices need to be passed as well).

    B can then broadcast the tx, or send it back to A for broadcasting. Once B has completed the signing (and verified the tx to be valid), he can add the full I_D
    to his cache, allowing him to verify spent status as well.

    NOTE:
    A and B *must* present key A and B to each other with a valid signature proving they know a and b respectively.
    Otherwise, trickery like the following becomes possible:
    A creates viewkey a,A, spendkey b,B, and sends a,A,B to B.
    B creates a fake key C = zG - B. B sends C back to A.
    The combined spendkey C+B then equals zG, allowing B to spend funds at any time!
    The signature fixes this, because B does not know a c corresponding to C (and thus can't produce a signature).

    2 of 3

    User A (coordinator)
    Shared viewkey a,A
    "spendkey" j,J

    User B
    "spendkey" k,K

    User C
    "spendkey" m,M

    A collects K and M from B and C
    B collects J and M from A and C
    C collects J and K from A and B

    A computes N = nG, n = Hs(jK)
    A computes O = oG, o = Hs(jM)

    B anc C compute P = pG, p = Hs(kM) || Hs(mK)
    B and C can also compute N and O respectively if they wish to be able to coordinate

    Address: N+O+P, A

    The rest follows as above. The coordinator possesses 2 of 3 needed keys; he can get the other
    needed part of the signature/key images from either of the other two.

    Alternatively, if secure communication exists between parties:
    A gives j to B
    B gives k to C
    C gives m to A

    Address: J+K+M, A

    3 of 3

    Identical to 2 of 2, except the coordinator must collect the key images from both of the others.
    The transaction must also be passed an additional hop: A -> B -> C (or A -> C -> B), who can then broadcast it
    or send it back to A.

    N-1 of N

    Generally the same as 2 of 3, except participants need to be arranged in a ring to pass their keys around
    (using either the secure or insecure method).
    For example (ignoring viewkey so letters line up):
    [4 of 5]
    User: spendkey
    A: a
    B: b
    C: c
    D: d
    E: e

    a -> B, b -> C, c -> D, d -> E, e -> A

    Order of signing does not matter, it just must reach n-1 users. A "remaining keys" list must be passed around with
    the transaction so the signers know if they should use 1 or both keys.
    Collecting key image parts becomes a little messy, but basically every wallet sends over both of their parts with a tag for each.
    Thia way the coordinating wallet can keep track of which images have been added and which wallet they come from. Reasoning:
    1. The key images must be added only once (coordinator will get key images for key a from both A and B, he must add only one to get the proper key actual key image)
    2. The coordinator must keep track of which helper pubkeys came from which wallet (discussed in 2 of 2 section). The coordinator
    must choose only one set to use, then include his choice in the "remaining keys" list so the other wallets know which of their keys to use.

    You can generalize it further to N-2 of N or even M of N, but I'm not sure there's legitimate demand to justify the complexity. It might
    also be straightforward enough to support with minimal changes from N-1 format.
    You basically just give each user additional keys for each additional "-1" you desire. N-2 would be 3 keys per user, N-3 4 keys, etc.

The process is somewhat cumbersome:

To create a N/N multisig wallet:

 - each participant creates a normal wallet
 - each participant runs "prepare_multisig", and sends the resulting string to every other participant
 - each participant runs "make_multisig N A B C D...", with N being the threshold and A B C D... being the strings received from other participants (the threshold must currently equal N)

As txes are received, participants' wallets will need to synchronize so that those new outputs may be spent:

 - each participant runs "export_multisig FILENAME", and sends the FILENAME file to every other participant
 - each participant runs "import_multisig A B C D...", with A B C D... being the filenames received from other participants

Then, a transaction may be initiated:

 - one of the participants runs "transfer ADDRESS AMOUNT"
 - this partly signed transaction will be written to the "multisig_monero_tx" file
 - the initiator sends this file to another participant
 - that other participant runs "sign_multisig multisig_monero_tx"
 - the resulting transaction is written to the "multisig_monero_tx" file again
 - if the threshold was not reached, the file must be sent to another participant, until enough have signed
 - the last participant to sign runs "submit_multisig multisig_monero_tx" to relay the transaction to the Monero network
2017-12-17 16:11:57 +00:00
moneromooo-monero
46eaaae79b
ringct: always use outPk.mask to decode amounts 2017-12-09 18:02:55 +00:00
moneromooo-monero
8d4469a0ac
ringct: do not include bulletproof commitments in signed message
Those are not serialized, but are restored from the outPk masks,
so depending on what tries to validate the tx, those commitments
may or may not be filled with valid data at the time. The outPk
masks are already hashed as part of the rctSigBase field.
2017-12-09 15:30:15 +00:00
moneromooo-monero
c83d0b3ee2
add bulletproofs from v7 on testnet 2017-12-08 13:50:45 +00:00
moneromooo-monero
d58835b2f6
integrate bulletproofs into monero 2017-12-08 13:48:15 +00:00
Howard Chu
510d0d4753
Use a threadpool
Instead of constantly creating and destroying threads
2017-09-14 21:42:48 +01:00
moneromooo-monero
da18898f0e
ringct: do not require range proof in decodeRct/decodeRctSimple
These fields aren't used, and they'll actually be pruned in
some cases
2017-02-27 22:28:45 +00:00
kenshi84
8027ce0c75 extract some basic code from libcryptonote_core into libcryptonote_basic 2017-02-08 22:45:15 +09:00
moneromooo-monero
6cc7d26140
ringct: reorder a bit to check quicker tests first 2017-01-21 20:29:22 +00:00
moneromooo-monero
5833d66f65
Change logging to easylogging++
This replaces the epee and data_loggers logging systems with
a single one, and also adds filename:line and explicit severity
levels. Categories may be defined, and logging severity set
by category (or set of categories). epee style 0-4 log level
maps to a sensible severity configuration. Log files now also
rotate when reaching 100 MB.

To select which logs to output, use the MONERO_LOGS environment
variable, with a comma separated list of categories (globs are
supported), with their requested severity level after a colon.
If a log matches more than one such setting, the last one in
the configuration string applies. A few examples:

This one is (mostly) silent, only outputting fatal errors:

MONERO_LOGS=*:FATAL

This one is very verbose:

MONERO_LOGS=*:TRACE

This one is totally silent (logwise):

MONERO_LOGS=""

This one outputs all errors and warnings, except for the
"verify" category, which prints just fatal errors (the verify
category is used for logs about incoming transactions and
blocks, and it is expected that some/many will fail to verify,
hence we don't want the spam):

MONERO_LOGS=*:WARNING,verify:FATAL

Log levels are, in decreasing order of priority:
FATAL, ERROR, WARNING, INFO, DEBUG, TRACE

Subcategories may be added using prefixes and globs. This
example will output net.p2p logs at the TRACE level, but all
other net* logs only at INFO:

MONERO_LOGS=*:ERROR,net*:INFO,net.p2p:TRACE

Logs which are intended for the user (which Monero was using
a lot through epee, but really isn't a nice way to go things)
should use the "global" category. There are a few helper macros
for using this category, eg: MGINFO("this shows up by default")
or MGINFO_RED("this is red"), to try to keep a similar look
and feel for now.

Existing epee log macros still exist, and map to the new log
levels, but since they're used as a "user facing" UI element
as much as a logging system, they often don't map well to log
severities (ie, a log level 0 log may be an error, or may be
something we want the user to see, such as an important info).
In those cases, I tried to use the new macros. In other cases,
I left the existing macros in. When modifying logs, it is
probably best to switch to the new macros with explicit levels.

The --log-level options and set_log commands now also accept
category settings, in addition to the epee style log levels.
2017-01-16 00:25:46 +00:00
moneromooo-monero
ba3968f6ce
rct: split rct checks between semantics and other
Semantics can be checked early
2017-01-14 21:17:32 +00:00
Lee Clagett
e3639f5cc3 Removed unused functions 2016-12-19 14:47:26 -05:00
luigi1111
9d906159c3
Tx verification failing is not an error
And rangeProofs are on outputs...
2016-12-12 17:01:20 -06:00
Riccardo Spagni
e6b05ed95a
Merge pull request #1414
3b005275 ringct: add sc_check calls in MLSAG_Ver for ss and cc (moneromooo-monero)
2f1732a7 ringct: guard against bad data exceptions in worker threads (moneromooo-monero)
2016-12-08 23:44:09 +02:00
moneromooo-monero
3b00527500
ringct: add sc_check calls in MLSAG_Ver for ss and cc
luigi1111's recommendation
2016-12-07 22:41:21 +00:00
moneromooo-monero
2f1732a7e5
ringct: guard against bad data exceptions in worker threads
If purported pubkeys aren't actually valid pubkeys, exceptions
will fly. These will terminate if thrown in a worker thread.
Guard against this.
2016-12-07 22:09:43 +00:00
luigi1111
46a0dcc1d2
ringct: luigi1111's changes to fix and speedup Borromean sigs 2016-12-04 21:54:16 +00:00
Shen Noether
76958fc75a
ringct: switch to Borromean signatures 2016-12-04 21:54:11 +00:00
Lee Clagett
f025198f19 Added task_region - a fork/join task implementation 2016-11-23 14:41:25 -05:00
Lee Clagett
64094e5f4e adding thread_group for managing async tasks 2016-11-02 19:21:55 -04:00
moneromooo-monero
ffd8c41f36
ringct: check the size of amount_keys is the same as destinations 2016-10-29 13:33:48 +01:00
moneromooo-monero
836669d276
ringct: always shutdown the boost io service
Even if no worker threads were started, it needs shutting down
or it will cause an invalid access in the io service thread
2016-10-29 13:31:53 +01:00
moneromooo-monero
3429bfb71d
ringct: thread verRct and verRctSimple 2016-10-15 13:32:13 +01:00
moneromooo-monero
e06a4daf33
ringct: remove unneeded type conversions 2016-10-15 11:58:39 +01:00
moneromooo-monero
afc70df7ea
ringct: reserve space in vectors to avoid excessive reallocation 2016-10-15 11:58:34 +01:00
moneromooo-monero
4038e86527
Add performance timers for ringct tx verification 2016-10-10 21:24:21 +01:00
moneromooo-monero
3126ba7425
ringct: use const refs as parameters where appropriate 2016-10-08 22:16:23 +01:00
moneromooo-monero
7d413f635f
rct: rework serialization to avoid storing vector sizes 2016-09-14 20:23:06 +01:00
moneromooo-monero
b38452bd55
ringct: pass structure by const ref, not value 2016-08-28 21:30:51 +01:00
moneromooo-monero
94fd881f74
rct: early out on failure on verRange 2016-08-28 21:30:38 +01:00
moneromooo-monero
074e602609
ringct: use Cryptonote serialization to hash non prunable data 2016-08-28 21:30:28 +01:00
moneromooo-monero
6f526cdff8
rct: log why verification fails
and remove some unnecessary variables in the checking code
2016-08-28 21:30:23 +01:00
moneromooo-monero
d4b62a1e29
rct amount key modified as per luigi1111's recommendations
This allows the key to be not the same for two outputs sent to
the same address (eg, if you pay yourself, and also get change
back). Also remove the key amounts lists and return parameters
since we don't actually generate random ones, so we don't need
to save them as we can recalculate them when needed if we have
the correct keys.
2016-08-28 21:30:19 +01:00
moneromooo-monero
93f5c625f0
rct: rework v2 txes into prunable and non prunable data
Nothing is pruned, but this allows easier changes later.
2016-08-28 21:30:18 +01:00
moneromooo-monero
d93746b6d3
rct: rework the verification preparation process
The whole rct data apart from the MLSAGs is now included in
the signed message, to avoid malleability issues.

Instead of passing the data that's not serialized as extra
parameters to the verification API, the transaction is modified
to fill all that information. This means the transaction can
not be const anymore, but it cleaner in other ways.
2016-08-28 21:30:16 +01:00
moneromooo-monero
3ab2ab3e76
rct: change the simple flag to a type
for future expansion
2016-08-28 21:30:14 +01:00
Shen Noether
c5be4b0bea
rct: avoid the need for the last II element
This element is used in the generation of the MLSAG, but isn't
needed in verification.
Also misc changes in the cryptonote code to match, by mooo.
2016-08-28 21:30:12 +01:00
moneromooo-monero
9b70856ccb
rct: make the amount key derivable by a third party with the tx key
Scheme design from luigi1114.
2016-08-28 21:29:46 +01:00
moneromooo-monero
cf33e1a52a
rct: do not serialize public keys in outPk
They can be reconstructed from vout
2016-08-28 21:29:43 +01:00
moneromooo-monero
e81a2b2cfa
port get_tx_key/check_tx_key to rct 2016-08-28 21:29:24 +01:00
moneromooo-monero
a4d4d6194b
integrate simple rct api 2016-08-28 21:29:20 +01:00
Shen Noether
dbb5f2d6a3
ringct: optimization/cleanup of hash functions 2016-08-28 21:29:16 +01:00
Shen Noether
4fd01f2bee
ringct: "simple" ringct variant
Allows the fake outs to be in different positions for each ring.
For rct inputs only.
2016-08-28 21:29:14 +01:00
moneromooo-monero
20e50ec7f7
ringct: do not serialize what can be reconstructed
The mixRing (output keys and commitments) and II fields (key images)
can be reconstructed from vin data.
This saves some modest amount of space in the tx.
2016-08-28 21:28:55 +01:00
moneromooo-monero
359f46901e
ringct: add missing size check for ecdhInfo 2016-08-28 21:28:41 +01:00
moneromooo-monero
229968eafc
ringct: change asserts to return false for boolean functions 2016-08-28 21:28:39 +01:00
moneromooo-monero
dc4aad7eb5
add rct to the protocol
It is not yet constrained to a fork, so don't use on the real network
or you'll be orphaned or rejected.
2016-08-28 21:28:37 +01:00
moneromooo-monero
54f7429cf6
ringct: allow no outputs, and add tests for this and fees 2016-08-28 21:28:27 +01:00
moneromooo-monero
e99904ac31
ringct: make fee optional 2016-08-28 21:28:25 +01:00