Commit graph

7 commits

Author SHA1 Message Date
Olaoluwa Osuntokun
369ea2aa8e client/clmscript: fix errors in witness size estimation
In this commit, we fix a few lingering errors in witness size
estimation. Both the witness paths were missing a single byte that
signals the number of witness elements. We also convert the OP_DATAs in
the witness script to a varint length, as that more accurately reflects
the way the field is interpreted, as we provide the witness stack as is,
rather than pushing elements onto the stack as if it were a sigScript.
Finally, we add a missing byte for the size of the witness script
itself.
2020-03-09 20:00:20 -07:00
Wilmer Paulino
1b2aa96a51 clmscript: add account witness script helpers 2020-02-05 12:09:16 -08:00
Wilmer Paulino
4930da65b0 clmscript: use more efficient script construction for accounts
The new construction saves about 35 bytes over the existing one. The
reduction in size comes from only encoding each public key (the trader's
and auctioneer's) once and not using the extra opcodes for
OP_CHECKMULTISIG.
2020-02-03 12:15:47 -08:00
Wilmer Paulino
4021b2919c multi: tweak trader key with shared secret and per-batch key
In this commit, we overhaul the keys used in the multi-sig construction
of an account to prevent script reuse and provide plausible deniability
between account outputs to third parties. This is done by tweaking the
trader's key with two new components:

1. A per-batch key, which is obtained from the auctioneer during account
creation. Every time the account is modified or participates in a
cleared batch within the system, the per-batch key is incremented by the
curve's base point, resulting in a different key used in the account
script.

2. A shared secret derived using Diffie-Hellman between the trader's and
auctioneer's base keys. By using this secret, we provide plausible
deniability to third parties with knowledge of the base keys and
per-batch key.

The resulting tweaked key for the trader is then used as the tweak for
the auctioneer's base key.
2020-01-29 13:23:15 -08:00
Wilmer Paulino
30c3d0699c clmscript: add utility function IncrementKey
This increments a given key by its curve's base point.
2020-01-27 18:07:14 -08:00
Wilmer Paulino
004e1cf857 multi: use btcec.PublicKey instead of [33]byte
This allows us to use utility functions that require the use of a parsed
public key without needing to parse every time.
2020-01-24 13:45:48 -08:00
Wilmer Paulino
dca3f2717e account: implement account manager with support to create accounts
The account manager is a subsystem of the client that will be
responsible for management of all CLM accounts on-chain. This initial
version only supports opening accounts at the moment, but this will be
extended later on to also support closing and modifying them. Open
accounts are also watched for their confirmation and spend, though the
spend path remains unhandled.

The commit stands alone by itself, and is not yet integrated into the
server as we still need to satisfy its dependencies, which we'll do in
the following commits.
2020-01-10 16:57:56 -08:00