Commit Graph

64 Commits

Author SHA1 Message Date
Luke Parker
af63c3e5d2 Bump Substrate dependency
Fixes #147.
2022-11-04 07:54:18 -04:00
Luke Parker
2315b3c79b Localize the LibP2P protocol to the blockchain
Follows convention by doing so. Theoretically enables running multiple 
blockchains over a single LibP2P connection.
2022-11-03 00:20:50 -04:00
Luke Parker
e3fc3f28fb Configure node for a multi-node testnet 2022-11-01 23:10:36 -04:00
Luke Parker
5832007a45 Take in a Keystore and validator ID 2022-11-01 20:06:42 -04:00
Luke Parker
aa0a4cf106 Implement proper checking of inherents 2022-11-01 16:37:50 -04:00
Luke Parker
91ae2b7112 Move serai_runtime specific code from tendermint/client to node
Renames serai-consensus to sc_tendermint
2022-10-30 10:54:17 -04:00
Luke Parker
3d7c12adcd Create a dedicated file for being a Tendermint authority 2022-10-30 10:08:35 -04:00
Luke Parker
6838d5c922 Clean generics in Tendermint with a monolith with associated types 2022-10-30 03:26:31 -04:00
Luke Parker
9a54317743 Basic Gossip Validator 2022-10-30 01:21:10 -04:00
Luke Parker
f31c457c2c Merge branch 'develop' into tendermint 2022-10-29 06:02:00 -04:00
Luke Parker
aa4b5e2ca3 Update Cargo.lock 2022-10-29 06:01:32 -04:00
Luke Parker
aec36377c0 Merge branch 'develop' into tendermint 2022-10-29 05:10:21 -04:00
Luke Parker
2379855b31 Create a dedicated crate for the DKG (#141)
* Add dkg crate

* Remove F_len and G_len

They're generally no longer used.

* Replace hash_to_vec with a provided method around associated type H: Digest

Part of trying to minimize this trait so it can be moved elsewhere. Vec, 
which isn't std, may have been a blocker.

* Encrypt secret shares within the FROST library

Reduces requirements on callers in order to be correct.

* Update usage of Zeroize within FROST

* Inline functions in key_gen

There was no reason to have them separated as they were. sign probably 
has the same statement available, yet that isn't the focus right now.

* Add a ciphersuite package which provides hash_to_F

* Set the Ciphersuite version to something valid

* Have ed448 export Scalar/FieldElement/Point at the top level

* Move FROST over to Ciphersuite

* Correct usage of ff in ciphersuite

* Correct documentation handling

* Move Schnorr signatures to their own crate

* Remove unused feature from schnorr

* Fix Schnorr tests

* Split DKG into a separate crate

* Add serialize to Commitments and SecretShare

Helper for buf = vec![]; .write(buf).unwrap(); buf

* Move FROST over to the new dkg crate

* Update Monero lib to latest FROST

* Correct ethereum's usage of features

* Add serialize to GeneratorProof

* Add serialize helper function to FROST

* Rename AddendumSerialize to WriteAddendum

* Update processor

* Slight fix to processor
2022-10-29 03:54:42 -05:00
Luke Parker
5c08fa9701 TendermintApi, compilation fixes 2022-10-27 08:44:53 -04:00
Luke Parker
4c2dd9b306 Partial work on correcting pallet calls 2022-10-27 06:29:56 -04:00
Luke Parker
fa7a03bf60 Update node to use pallet sessions 2022-10-27 05:23:53 -04:00
Luke Parker
49ab26209d Add pallet sessions to runtime, create pallet-tendermint 2022-10-27 05:05:41 -04:00
Luke Parker
cbceaff678 Create dedicated message structures for FROST messages (#140)
* Create message types for FROST key gen

Taking in reader borrows absolutely wasn't feasible. Now, proper types
which can be read (and then passed directly, without a mutable borrow)
exist for key_gen. sign coming next.

* Move FROST signing to messages, not Readers/Writers/Vec<u8>

Also takes the nonce handling code and makes a dedicated file for it, 
aiming to resolve complex types and make the code more legible by 
replacing its previously inlined state.

* clippy

* Update FROST tests

* read_signature_share

* Update the Monero library to the new FROST packages

* Update processor to latest FROST

* Tweaks to terminology and documentation
2022-10-25 23:17:25 -05:00
Luke Parker
8a682cd25c Announce blocks
By claiming File, they're not sent ovber the P2P network before they 
have a justification, as desired. Unfortunately, they never were. This 
works around that.
2022-10-22 07:36:13 -04:00
Luke Parker
9b0dca06d0 Provide a way to create the machine
The BasicQueue returned obscures the TendermintImport struct. 
Accordingly, a Future scoped with access is returned upwards, which when 
awaited will create the machine. This makes creating the machine 
optional while maintaining scope boundaries.

Is sufficient to create a 1-node net which produces and finalizes 
blocks.
2022-10-22 03:41:49 -04:00
Luke Parker
bf5bdb89c2 Implement block proposal logic 2022-10-21 23:36:24 -04:00
Luke Parker
e8df74e295 Merge branch 'develop' into tendermint 2022-10-21 22:02:45 -04:00
Luke Parker
b72af5e185 cargo update
The new ink release should enable using the latest Rust nightly, without 
issue.
2022-10-21 21:40:50 -04:00
Luke Parker
976948e9d9 Update Cargo.tomls for substrate packages 2022-10-21 03:17:02 -04:00
Luke Parker
5c46edbe98 Implement tendermint_machine::Block for Substrate Blocks
Unfortunately, this immediately makes Tendermint machine capable of 
deployment as  crate since it uses a git reference. In the future, a 
Cargo.toml patch section for serai/substrate should be investigated. 
This is being done regardless as it's the quickest way forward and this 
is for Serai.
2022-10-21 02:06:48 -04:00
Luke Parker
eb59dd5a55 Initial work on an import queue 2022-10-20 03:50:06 -04:00
Luke Parker
cc8284ad40 Merge branch 'develop' into tendermint 2022-10-20 01:34:59 -04:00
Luke Parker
6c996fb3cd Update substrate
Also removes the patch for zip since a new release was issued.

Closes https://github.com/serai-dex/serai/issues/81.

Contracts RPC purged as according to 
https://github.com/paritytech/substrate/pull/12358.
2022-10-20 01:05:36 -04:00
Luke Parker
6b56510da9 Remove async recursion
Greatly increases safety as well by ensuring only one message is 
processed at once.
2022-10-17 12:04:59 -04:00
Luke Parker
ec7d8ac67b Remove coin crate
Effective reversion of past few commits by request.
2022-10-16 13:11:32 -04:00
Luke Parker
987aa5189a Implement serialization via parity's scale codec
Ideally, this would be generic. Unfortunately, the generic API serde 
doesn't natively support borsh, nor SCALE, and while there is a serde 
SCALE crate, it's old. While it may be complete, it's not worth working 
with.

While we could still grab bincode, and a variety of other formats, it 
wasn't worth it to go custom and for Serai, we'll be using SCALE almost 
everywhere anyways.
2022-10-16 10:06:27 -04:00
Luke Parker
77ba1c00e2 Successfully compiling 2022-10-16 07:30:11 -04:00
Luke Parker
a5f1ddaf1b Refactor out external parts to generics
Also creates a dedicated file for the message log.
2022-10-16 03:29:55 -04:00
Luke Parker
65664dafa4 Make coin a dedicated library
Closes https://github.com/serai-dex/serai/issues/128.
2022-10-15 23:21:56 -04:00
Luke Parker
a0a54eb0de Update to FROST v11
Ensures random functions never return zero. This, combined with a check 
commitments aren't 0, causes no serialized elements to be 0.

Also directly reads their vectors.
2022-10-13 00:38:36 -04:00
Luke Parker
482a8ec209 Update to the latest Serai Substrate (#125)
* Update to the latest Serai Substrate

* Add Protobuf to build dependencies

Docker shouldn't need updating as this should've been added to the image 
in 
2dbace5b01.

* Get substrate to build

* Correct protoc build step

* Remove the benchmarking code

There's some macro resolution error that isn't apparent. I worked on it 
for about half an hour but...

* Remove unnecessary clone

* Correct runtime-benchmarks flag usage
2022-09-29 13:33:09 -05:00
Luke Parker
503ae02cae Version bump monero-generators to consolidate a dependency 2022-09-29 10:36:40 -04:00
Luke Parker
695f7ec5f9 Version bump Monero for documentation purposes 2022-09-29 10:35:11 -04:00
Luke Parker
8da0743361 Use sha3 in monero-generators 2022-09-29 08:08:49 -04:00
Luke Parker
2b7c9378c0 Update to FROST v10
Further expands documentation to near-completion.
2022-09-29 07:08:20 -04:00
Luke Parker
8b0f0a3713 Publish an alpha version of the Monero crate (#123)
* Label the version as an alpha

* Add versions to Cargo.tomls

* Update to Zeroize 1.5

* Drop patch versions from monero-serai Cargo.toml

* Add a repository field

* Move generators to OUT_DIR

IIRC, I didn't do this originally as it constantly re-generated them. 
Unfortunately, since cargo is complaining about .generators, we have to.

* Remove Timelock::fee_weight

Transaction::fee_weight's has a comment, "Assumes Timelock::None since 
this library won't let you create a TX with a timelock". Accordingly, 
this is dead code.
2022-09-29 01:24:33 -05:00
Luke Parker
49749d96a0 Replace tiny_keccak with sha3 in Monero 2022-09-28 09:29:58 -04:00
Luke Parker
5a4eb0a076 cargo update
Removes the potential applicability of CVE-2021-3520.
2022-09-18 15:30:38 -04:00
Luke Parker
d6a31863c4 Version bump dalek-ff-group 2022-08-29 03:46:48 -04:00
Luke Parker
081b9a1975 FROST Ed448 (#107)
* Theoretical ed448 impl

* Fixes

* Basic tests

* More efficient scalarmul

Precomputes a table to minimize additions required.

* Add a torsion test

* Split into a constant and variable time backend

The variable time one is still far too slow, at 53s for the tests (~5s a 
scalarmul). It should be usable as a PoC though.

* Rename unsafe Ed448

It's not only unworthy of the Serai branding and deserves more clarity
in the name.

* Add wide reduction to ed448

* Add Zeroize to Ed448

* Rename Ed448 group.rs to point.rs

* Minor lint to FROST

* Ed448 ciphersuite with 8032 test vector

* Macro out the backend fields

* Slight efficiency improvement to point decompression

* Disable the multiexp test in FROST for Ed448

* fmt + clippy ed448

* Fix an infinite loop in the constant time ed448 backend

* Add b"chal" to the 8032 context string for Ed448

Successfully tests against proposed vectors for the FROST IETF draft.

* Fix fmt and clippy

* Use a tabled pow algorithm in ed448's const backend

* Slight tweaks to variable time backend

Stop from_repr(MODULUS) from passing.

* Use extended points

Almost two orders of magnitude faster.

* Efficient ed448 doubling

* Remove the variable time backend

With the recent performance improvements, the constant time backend is 
now 4x faster than the variable time backend was. While the variable 
time backend remains much faster, and the constant time backend is still 
slow compared to other libraries, it's sufficiently performant now.

The FROST test, which runs a series of multiexps over the curve, does 
take 218.26s while Ristretto takes 1 and secp256k1 takes 4.57s.

While 50x slower than secp256k1 is horrible, it's ~1.5 orders of 
magntiude, which is close enough to the desire stated in 
https://github.com/serai-dex/serai/issues/108 to meet it.

Largely makes this library safe to use.

* Correct constants in ed448

* Rename unsafe-ed448 to minimal-ed448

Enables all FROST tests against it.

* No longer require the hazmat feature to use ed448

* Remove extraneous as_refs
2022-08-29 02:32:59 -05:00
Luke Parker
33ee6b7a02 Bump FROST version 2022-08-26 09:09:18 -04:00
Luke Parker
c5beee5648 Fix #48
Removes monero, yet we still use monero-rs's base58 and epee libraries.
2022-08-21 08:41:19 -04:00
Luke Parker
603a3f8c9f Generate Bulletproofs(+) generators at compile time
Creates a new monero-generators crate so the monero crate can run the 
code in question at build time.

Saves several seconds from running the tests.

Closes https://github.com/serai-dex/serai/issues/101.
2022-08-21 06:36:53 -04:00
Luke Parker
c53e7ad6c7 Bump dalek-ff-group version 2022-08-18 17:11:55 -04:00
Luke Parker
f809827acd cargo update
Fixes https://github.com/serai-dex/serai/issues/82.
2022-08-16 03:44:32 -04:00