Greg Fitzgerald
a420a9293f
Fix demo
2018-03-07 11:37:30 -07:00
Greg Fitzgerald
9834c251d0
Boot genesis block helper
...
Before this change, if you wanted to use a new Transaction
feature in the genesis block, you'd need to extend its
Creator object and associated methods. With yesterday's
addtions to Transcation, it's now so easy to work with
Transactions directly that we can get rid of the middleman.
Also added a KeyPair type alias, so that ring could be easily swapped
out with a competing library, if needed.
2018-03-07 11:10:15 -07:00
Greg Fitzgerald
54340ed4c6
Delete debugging println
...
Thanks @jackson-sandland!
2018-03-06 21:17:41 -07:00
Greg Fitzgerald
d1b6206858
Monomorphisize Entry and Event
...
Transaction turned out to be the only struct worth making generic.
2018-03-06 20:29:18 -07:00
Greg Fitzgerald
b725fdb093
Sha256Hash -> Hash
...
Because in Loom, there's just the one. Hopefully no worries that it
shares a name with std::Hash.
2018-03-06 17:40:01 -07:00
Greg Fitzgerald
1436bb1ff2
Move entry into its own module
...
Hmm, Logger doesn't depend on log.
2018-03-06 17:40:01 -07:00
Greg Fitzgerald
5a44c36b1f
Move hash into its own module
2018-03-06 17:40:01 -07:00
Greg Fitzgerald
f09952f3d7
DRY up transaction signing
...
Cleanup the big mess I copy-pasted myself into.
2018-03-06 16:34:25 -07:00
Greg Fitzgerald
4376032e3a
data -> asset
...
'data' is too vague.
2018-03-06 14:50:32 -07:00
Greg Fitzgerald
624c151ca2
Add signature module
...
Because things other than transactions can be signed.
2018-03-06 12:48:28 -07:00
Greg Fitzgerald
5d0356f74b
Move verify_entry to a method as well
2018-03-06 12:35:12 -07:00
Greg Fitzgerald
b019416518
Move verify into methods
...
A little overly-coupled to Serialize, but makes the code a lot tighter
2018-03-06 12:27:08 -07:00
Greg Fitzgerald
4fcd9e3bd6
Give Transaction its own module
2018-03-06 12:18:17 -07:00
Greg Fitzgerald
66bf889c39
Rename Transfer to Transaction
...
struct names should be nouns
2018-03-06 11:54:47 -07:00
Greg Fitzgerald
a2811842c8
More cleanup
...
Far fewer branches when we process transfers outside the context
of events.
2018-03-06 11:43:55 -07:00
Greg Fitzgerald
1929601425
Cleanup
...
Now that Transfer is out of the enum, we don't need to pattern
match to access its fields.
2018-03-06 11:19:59 -07:00
Greg Fitzgerald
282afee47e
Use Transfer struct on the client side too
...
Sharing is caring.
2018-03-06 11:03:43 -07:00
Greg Fitzgerald
e701ccc949
Rename Request::Transfer to Request::Transaction
2018-03-06 10:59:47 -07:00
Greg Fitzgerald
6543497c17
Move Transaction data into its own struct
...
This will allow us to add addition transfer types to the log.
2018-03-06 10:50:32 -07:00
Greg Fitzgerald
720c54a5bb
Allow balances to be negative
...
* Will allow owners to loan token to others.
* Will allow for parallel verification of balances without spilling
over 64 bits.
Fixes #43
2018-03-05 17:30:53 -07:00
Greg Fitzgerald
a4336a39d6
Initialize the testnode from a log
...
$ cargo run --bin silk-genesis-file-demo > demo-genesis.json
$ cat demo-genesis.json | cargo run --bin silk-genesis-block > demo-genesis.log
$ cat demo-genesis.log | cargo run --bin silk-testnode
2018-03-05 15:34:44 -07:00
Greg Fitzgerald
298989c4b9
Generate log from Genesis
2018-03-05 13:03:56 -07:00
Greg Fitzgerald
48c28c2267
Transactions now require a hash of the last entry they've seen
...
This ensures the transaction cannot be processed on a chain
that forked before that ID. It will also provide a basis for
expiration constraints. A client may want their transaction
to expire, and the generators may want to reject transactions
that have been floating in the ether for years.
2018-03-05 12:48:14 -07:00
Greg Fitzgerald
d76ecbc9c9
Don't block the server
2018-03-05 11:39:59 -07:00
Greg Fitzgerald
79fb9c00aa
Boot wait_on_signature() from accountant
...
Instead, there should be a way to query for a page of log data,
and checking whether it has a signature should be done client-side.
2018-03-05 10:45:18 -07:00
Greg Fitzgerald
c9e03f37ce
Logger now only speaks when spoken to
...
Before this change, the logger's send channel could quickly be
flooded with Tick events. Those events should only be passed to
a writer.
Also, the log_event() function no longer sends entries. That
functionality moved to the new process_events() function. This
will allow us to initialize the with the genesis block without
flooding the send channel with events the historian won't read.
2018-03-05 10:33:12 -07:00
Greg Fitzgerald
aa5f1699a7
Update the set of unique signatures when loading an existing log.
2018-03-04 22:31:12 -07:00
Greg Fitzgerald
955f76baab
Finally, genesis block generation without channels
2018-03-04 14:32:30 -07:00
Greg Fitzgerald
ff82fbf112
Make num_hashes mean the num_hashes since the last ID
...
Before this change, num_hashes meant the number of hashes since
the last ID, minus any hashing done on the event data. It made
no difference for Tick events, but logged Transaction events with
one less hash than actually occurred.
2018-03-04 09:52:36 -07:00
Greg Fitzgerald
8503a0a58f
Refactor
2018-03-04 09:21:45 -07:00
Greg Fitzgerald
b1e9512f44
Rename end_hash to id
2018-03-04 07:50:26 -07:00
Greg Fitzgerald
608def9c78
Consolidate imports
2018-03-04 07:28:51 -07:00
Greg Fitzgerald
bcb21bc1d8
Delete dead code
2018-03-04 07:20:17 -07:00
Greg Fitzgerald
9b26892bae
Add a demo app to generate the genesis file
2018-03-04 01:21:40 -07:00
Greg Fitzgerald
572475ce14
Load the genesis block
2018-03-04 00:15:17 -07:00
Greg Fitzgerald
876d7995e1
Refactor to support loading an existing ledger
2018-03-03 22:25:40 -07:00
Greg Fitzgerald
b8655e30d4
Make client-demo standalone
...
And remove deposit() methods from the API. Those should only be
used on the server to bootstrap.
2018-03-03 21:15:51 -07:00
Greg Fitzgerald
7cf0d55546
Remove optional 'from' field
2018-03-03 20:41:07 -07:00
Greg Fitzgerald
ce60b960c0
Special case sending money to self
...
In the genesis block, let matching 'from' and 'to' keys be used
to mint new coin.
2018-03-03 20:27:12 -07:00
Greg Fitzgerald
cebcb5b92d
Start genesis with a Tick, so that its hash can be used to bootstrap verification
2018-03-03 19:57:22 -07:00
Greg Fitzgerald
11a0f96f5e
Add command-line tool for generating a genesis block
2018-03-03 17:35:05 -07:00
Greg Fitzgerald
f7496ea6d1
Make create_logger a static method
...
Allows us to share the super long type signature in impl.
2018-03-03 14:26:59 -07:00
Greg Fitzgerald
bebba7dc1f
Give logger its own crate
2018-03-03 14:24:32 -07:00
Greg Fitzgerald
afb2bf442c
Use Instant instead of SystemTime for more precise ticking
...
And convert log_event from function to method
2018-03-03 14:08:53 -07:00
Greg Fitzgerald
c7de48c982
Convert log_events from function to method
2018-03-03 14:00:37 -07:00
Greg Fitzgerald
f906112c03
Move logging thread's state into a struct
2018-03-03 13:52:57 -07:00
Greg Fitzgerald
1c9b5ab53c
Report performance of signature verification too
2018-03-03 11:59:34 -07:00
Greg Fitzgerald
c10faae3b5
More readable metrics
2018-03-03 11:52:50 -07:00
Greg Fitzgerald
2104dd5a0a
Fix benchmark
...
Was measuring the creation of the iterator, not running it.
2018-03-03 11:45:23 -07:00
Greg Fitzgerald
d8c50b150c
Move key generation and signing from transaction benchmark
...
Key generation, signing and verification are not the performance
bottleneck. Something is probably wrong here.
2018-03-03 11:11:46 -07:00
Greg Fitzgerald
a148454376
Update readme
2018-03-02 12:07:05 -07:00
Greg Fitzgerald
be518b569b
Remove cyclic dependency between event and log
2018-03-02 12:03:59 -07:00
Greg Fitzgerald
c998fbe2ae
Sign the owner's public key
...
Without this, the accountant will reject transfers from different
entities if they are for the same amount and to the same entity.
2018-03-02 11:56:42 -07:00
Greg Fitzgerald
9f12cd0c09
Purge the Claim event type
...
It's now represented as a Transaction from an unknown party.
2018-03-02 11:48:58 -07:00
Greg Fitzgerald
0d0fee1ca1
Sign Claim's 'to' field
...
Otherwise, the accountant will treat deposits of the same amount as
duplicates.
2018-03-02 11:46:22 -07:00
Greg Fitzgerald
a0410c4677
Pipe all Claim constructors through a function
2018-03-02 10:58:43 -07:00
Greg Fitzgerald
8fe464cfa3
Rename Claim's key field to match same field in Transaction
2018-03-02 10:47:21 -07:00
Greg Fitzgerald
3e2d6d9e8b
Generalize Transaction to express a Claim
...
If a Transaction doesn't have an existing address, it's being used
to create new funds.
2018-03-02 10:41:15 -07:00
Greg Fitzgerald
32d677787b
Reduce transactions sent by demo
...
We don't do retries yet, so keep tx count to something that won't
trigger any packet loss.
2018-03-02 10:35:38 -07:00
Greg Fitzgerald
dfd1c4eab3
Don't process transaction if channel.send() fails.
...
Do all input validation first, then log (which can fail). If all
goes swimmingly, process the transaction.
2018-03-02 10:17:52 -07:00
Greg Fitzgerald
36bb1f989d
More defense against a double-spend attack
...
Before this change, a client could spend funds before the accountant
processed a previous spend. With this change in place, the accountant
updates balances immediately, but that comes at an architectural cost.
The accountant now verifies signatures on behalf of the historian, so
that it can ensure logging will not fail.
2018-03-02 09:55:44 -07:00
Greg Fitzgerald
684f4c59e0
Delete commented out code
...
accountant crate shouldn't verify the log. Instead, it should
only add valid entries and leave verification to network nodes.
2018-03-02 08:51:29 -07:00
Greg Fitzgerald
1b77e8a69a
Move Event into its own crate
...
The log crate was starting to be the catch-all for all things
related to entries, events, signatures, and hashes. This split
shows us that:
* Event depends only on signatures, not on hashes [directly]
* All event testing was done via log testing (shame on me)
* Accounting depends only on events
2018-03-02 08:43:57 -07:00
Greg Fitzgerald
c935fdb12f
Move signature duplicate detection into the historian
2018-03-01 17:44:10 -07:00
Greg Fitzgerald
9e16937914
Delete the Discovery event
...
Not useful to the accountant.
2018-03-01 17:02:41 -07:00
Greg Fitzgerald
f705202381
No need to hash data that's already hashed to create the signature
2018-03-01 16:39:09 -07:00
Greg Fitzgerald
570e71f050
Check for duplicate signatures
...
TODO: have client add recent hash to each message
2018-03-01 14:07:39 -07:00
Greg Fitzgerald
c9cc4b4369
Switch to UDP from TCP
...
And remove all the sleep()'ing around.
2018-03-01 13:47:53 -07:00
Greg Fitzgerald
4610de8fdd
Switch to sync_channel to preserve order
2018-02-28 19:33:28 -07:00
Greg Fitzgerald
3fcc2dd944
Add testnode
...
Fixes #20
2018-02-28 18:05:20 -07:00
Greg Fitzgerald
8299bae2d4
Add accountant stub
2018-02-28 16:01:12 -07:00
Greg Fitzgerald
604ccf7552
Add network interface for accountant
2018-02-28 14:00:04 -07:00
Greg Fitzgerald
c3bb207488
Verify event signatures before adding log entries
2018-02-28 10:23:01 -07:00
Greg Fitzgerald
fa4d9e8bcb
Add more tests
2018-02-27 11:28:10 -07:00
Greg Fitzgerald
34b77efc87
Sleep longer for TravisCI
2018-02-27 11:08:28 -07:00
Greg Fitzgerald
5ca0ccbcd2
Add accountant
2018-02-27 10:54:06 -07:00
Greg Fitzgerald
f98e9a2ad7
Fix overuse of search-and-replace
2018-02-26 17:03:50 -07:00
Greg Fitzgerald
c6134cc25b
Allow the historian to track ownership of any type of data
2018-02-26 17:01:22 -07:00
Greg Fitzgerald
0443b39264
Allow event log to hold events of any serializable (hashable) type
2018-02-26 16:42:31 -07:00
Greg Fitzgerald
8b0b8efbcb
Allow Entry to hold events of any kind of data
2018-02-26 15:37:33 -07:00
Greg Fitzgerald
97449cee43
Allow events to hold any kind of data
2018-02-26 15:31:01 -07:00
Greg Fitzgerald
ab5252c750
Move entry verification out of Entry impl
2018-02-26 14:39:01 -07:00
Greg Fitzgerald
b02eab57d2
Extend the event log with a Transaction event to transfer possession
...
This implementation assumes 'from' is the current owner of 'data'.
Once that's verified, the signature ensures that nobody modified
'data' (the asset being transferred) or 'to' the entity taking
ownership.
Fixes #14
2018-02-26 11:09:11 -07:00
Greg Fitzgerald
b8d52cc3e4
Make the Discovery event into a struct instead of a tuple
2018-02-24 11:15:03 -07:00
Greg Fitzgerald
d78082f5e4
Test bad signature
2018-02-24 10:27:51 -07:00
Greg Fitzgerald
08e501e57b
Extend the event log with a Claim event to claim possession
...
Unlike a Discovery event, a Claim event associates a public key
with a hash. It's intended to to be used to claim ownership of
some hashable data. For example, a graphic designer could claim
copyright by hashing some image they created, signing it with
their private key, and publishing the hash-signature pair via
the historian. If someone else tries to claim it as their own,
the designer can point to the historian's log as cryptographically
secure evidence that the designer's copy existed before anyone
else's.
Note there's nothing here that verifies the first claim is the actual
content owner, only that the first claim almost certainly happened
before a second.
2018-02-24 10:09:49 -07:00
Greg Fitzgerald
29a607427d
Rename UserDataKey to Discovery
...
From the perspective of the log, when some data's hash is added,
that data is "discovered" by the historian. Another event
might be a "claim" that some signed data belongs to the owner of a
public key.
2018-02-24 05:25:19 -07:00
Greg Fitzgerald
c1326ac3d5
Up the time to sleep so that ticks are generated
2018-02-21 12:22:23 -07:00
Greg Fitzgerald
7871b38c80
Update demo to use self-ticking logger
2018-02-21 11:52:03 -07:00
Greg Fitzgerald
b34d2d7dee
Allow the logger to inject Tick events on its own
2018-02-21 11:33:42 -07:00
Greg Fitzgerald
fa4e232d73
Add serialization/deseriation support to event log
...
See bincode and serde_json for usage:
https://github.com/TyOverby/bincode
Fixes #1
2018-02-20 16:26:13 -07:00
Greg Fitzgerald
6e37f70d55
Test reorder attack
2018-02-20 14:46:36 -07:00
Greg Fitzgerald
d97112d7f0
Explain proof-of-history in the readme
...
Also:
* Hash userdata so that verification works as the readme describes.
* Drop itertools package. Found a way to use std::iter instead.
Fixes #8
2018-02-20 14:04:49 -07:00
Greg Fitzgerald
ba90e43f72
Update benchmark
...
* Add asm, though it doesn't make it faster. TODO: use avx instructions.
* Do 10x less hashes, since sha256 is more expensive.
2018-02-19 16:51:35 -07:00
Greg Fitzgerald
0297edaf1f
Use sha256 hashes instead of Rust's builtin hasher.
...
Causes a 20x performance degradation. Enabling asm did not
speed things up.
2018-02-19 16:23:53 -07:00
Greg Fitzgerald
bb22522e45
Remove assertions that fail in the kcov docker container
2018-02-19 12:54:01 -07:00
Greg Fitzgerald
bd3fe5fac9
Sleep a little longer to ensure Travis context switches
2018-02-19 12:33:33 -07:00
Greg Fitzgerald
10a70a238b
Cleanup demo
2018-02-19 12:25:57 -07:00
Greg Fitzgerald
4a7156de43
Move hash generation into stateless function
2018-02-19 12:09:58 -07:00
Greg Fitzgerald
d88d1b2a09
Reset historian's hasher between events
...
Hasher will generate different hashes for the same input if it
had already generated a hash.
Also add a binary to ensure the example in the README works.
2018-02-19 12:03:06 -07:00
Greg Fitzgerald
5e3c7816bd
Ensure verify_slice succeeds
2018-02-19 09:09:24 -07:00
Greg Fitzgerald
ceb65c2669
Better function names
2018-02-18 10:05:54 -07:00
Greg Fitzgerald
fd209ef1a9
Rename event crate to log
2018-02-18 09:59:33 -07:00
Greg Fitzgerald
471f036444
Better names
...
Event -> Entry
EventData -> Event
2018-02-18 09:53:40 -07:00
Greg Fitzgerald
4c94754661
More coverage
2018-02-17 21:13:52 -07:00
Greg Fitzgerald
831e2cbdc9
Add historian
...
A microservice that continuously generates hashes, only stopping to
tag messages with the latest hash.
Fixes #8
2018-02-17 20:58:23 -07:00
Greg Fitzgerald
69f70cfe72
Add separate benchmarks for seq and par versions of verify_slice
2018-02-16 09:38:12 -08:00
Greg Fitzgerald
1c2e0af69b
Docs cleanup
2018-02-16 09:56:10 -07:00
Greg Fitzgerald
a857ae514b
Test sequential version of verify_slice with same tests
2018-02-16 09:14:42 -07:00
Greg Fitzgerald
09ccc1ee6d
Use create_ticks() outside of benchmark for improved code coverage
2018-02-16 09:06:25 -07:00
Greg Fitzgerald
38485b09c7
Move tests to expose them to rustfmt and kcov
2018-02-15 17:47:54 -07:00
Greg Fitzgerald
fb168fcee0
Cleanup
...
Make it so the parallel and sequential verification implementations
are only different in one line.
For reasons I don't understand Rayon's `all()` isn't `mut`.
2018-02-15 16:00:53 -07:00
Greg Fitzgerald
b5645bc776
Rename project
2018-02-15 13:59:33 -07:00
Greg Fitzgerald
3cef50056b
Consistent naming
2018-02-15 11:50:48 -07:00
Greg Fitzgerald
a20e114a80
Cleanup tests
2018-02-15 11:48:18 -07:00
Greg Fitzgerald
0dc0ae506d
Better names
2018-02-15 11:45:04 -07:00
Greg Fitzgerald
9723c827f5
mut hash -> end_hash
2018-02-15 11:29:09 -07:00
Greg Fitzgerald
75d091bd3c
More descriptive event data
2018-02-15 10:57:32 -07:00
Greg Fitzgerald
d21ad9357c
More descriptive field names
2018-02-15 10:48:30 -07:00
Greg Fitzgerald
a74540470a
Rename Tick to Event
...
* Define a tick to be an event with no user data.
* Use the term "event log" for now.
** Reserve the word "entry" for hash entries, and "item" for array items.
** Reserve the word "blockchain" for when the event is a block of something.
** Reserve the word "ledger" for when the event is of a particular type,
such as transactions.
2018-02-15 10:13:59 -07:00
Greg Fitzgerald
beb4a643ad
Add back a more traditional version of new()
2018-02-14 16:52:09 -07:00
Greg Fitzgerald
cdf3cffcae
Rename Tick::new() to Tick::run()
2018-02-14 16:45:42 -07:00
Greg Fitzgerald
8a521ba163
Make space for user data
2018-02-14 16:18:06 -07:00
Greg Fitzgerald
31d79727b6
Parallelize verification
2018-02-14 15:23:13 -07:00
Greg Fitzgerald
8ff8e90c5e
Cleanup slice verification
2018-02-14 13:02:39 -07:00
Greg Fitzgerald
d23fda1936
First go at Proof of History
2018-02-14 11:00:01 -07:00
Greg Fitzgerald
bad95b7712
cargo init
2018-02-14 07:23:59 -07:00