diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a6260579..1c37eb55 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -40,6 +40,7 @@ jobs: -p serai-message-queue \ -p serai-processor-messages \ -p serai-processor-key-gen \ + -p serai-processor-view-keys \ -p serai-processor-frost-attempt-manager \ -p serai-processor-primitives \ -p serai-processor-scanner \ diff --git a/Cargo.lock b/Cargo.lock index b3fa4e36..8662be6f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8760,6 +8760,13 @@ dependencies = [ "serai-processor-scheduler-primitives", ] +[[package]] +name = "serai-processor-view-keys" +version = "0.1.0" +dependencies = [ + "ciphersuite", +] + [[package]] name = "serai-reproducible-runtime-tests" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index a2d86c82..eb98c263 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -71,6 +71,7 @@ members = [ "processor/messages", "processor/key-gen", + "processor/view-keys", "processor/frost-attempt-manager", "processor/primitives", diff --git a/processor/src/additional_key.rs b/processor/src/additional_key.rs deleted file mode 100644 index f875950d..00000000 --- a/processor/src/additional_key.rs +++ /dev/null @@ -1,14 +0,0 @@ -use ciphersuite::Ciphersuite; - -use crate::networks::Network; - -// Generate a static additional key for a given chain in a globally consistent manner -// Doesn't consider the current group key to increase the simplicity of verifying Serai's status -// Takes an index, k, to support protocols which use multiple secondary keys -// Presumably a view key -pub fn additional_key(k: u64) -> ::F { - ::hash_to_F( - b"Serai DEX Additional Key", - &[N::ID.as_bytes(), &k.to_le_bytes()].concat(), - ) -} diff --git a/processor/src/lib.rs b/processor/src/lib.rs deleted file mode 100644 index bbff33f6..00000000 --- a/processor/src/lib.rs +++ /dev/null @@ -1,15 +0,0 @@ -#![allow(dead_code)] - -mod plan; -pub use plan::*; - -mod db; -pub(crate) use db::*; - -use serai_processor_key_gen as key_gen; - -pub mod networks; -pub(crate) mod multisigs; - -mod additional_key; -pub use additional_key::additional_key; diff --git a/processor/src/main.rs b/processor/src/main.rs index 49406aaf..10406729 100644 --- a/processor/src/main.rs +++ b/processor/src/main.rs @@ -27,9 +27,6 @@ use serai_env as env; use message_queue::{Service, client::MessageQueue}; -mod plan; -pub use plan::*; - mod networks; use networks::{Block, Network}; #[cfg(feature = "bitcoin")] @@ -39,9 +36,6 @@ use networks::Ethereum; #[cfg(feature = "monero")] use networks::Monero; -mod additional_key; -pub use additional_key::additional_key; - mod db; pub use db::*; diff --git a/processor/src/multisigs/mod.rs b/processor/src/multisigs/mod.rs index c20a922c..1c4adabf 100644 --- a/processor/src/multisigs/mod.rs +++ b/processor/src/multisigs/mod.rs @@ -4,5 +4,5 @@ pub enum MultisigEvent { // Batches to publish Batches(Option<(::G, ::G)>, Vec), // Eventuality completion found on-chain - Completed(Vec, [u8; 32], , [u8; 32], N::Eventuality), } diff --git a/processor/view-keys/Cargo.toml b/processor/view-keys/Cargo.toml new file mode 100644 index 00000000..6fdd9134 --- /dev/null +++ b/processor/view-keys/Cargo.toml @@ -0,0 +1,19 @@ +[package] +name = "serai-processor-view-keys" +version = "0.1.0" +description = "View keys for the Serai processor" +license = "MIT" +repository = "https://github.com/serai-dex/serai/tree/develop/processor/view-keys" +authors = ["Luke Parker "] +keywords = [] +edition = "2021" + +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + +[lints] +workspace = true + +[dependencies] +ciphersuite = { version = "0.4", path = "../../crypto/ciphersuite", default-features = false, features = ["std"] } diff --git a/processor/view-keys/LICENSE b/processor/view-keys/LICENSE new file mode 100644 index 00000000..91d893c1 --- /dev/null +++ b/processor/view-keys/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022-2024 Luke Parker + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/processor/view-keys/README.md b/processor/view-keys/README.md new file mode 100644 index 00000000..4354eed6 --- /dev/null +++ b/processor/view-keys/README.md @@ -0,0 +1,6 @@ +# Serai Processor View Keys + +View keys for the Serai processor. + +This is a MIT-licensed library made available for anyone to generate Serai's +view keys, as necessary for auditing reasons and for sending coins to Serai. diff --git a/processor/view-keys/src/lib.rs b/processor/view-keys/src/lib.rs new file mode 100644 index 00000000..c0d4c68e --- /dev/null +++ b/processor/view-keys/src/lib.rs @@ -0,0 +1,13 @@ +#![cfg_attr(docsrs, feature(doc_auto_cfg))] +#![doc = include_str!("../README.md")] +#![deny(missing_docs)] + +use ciphersuite::Ciphersuite; + +/// Generate a view key for usage within Serai. +/// +/// `k` is the index of the key to generate (enabling generating multiple view keys within a +/// single context). +pub fn view_key(k: u64) -> C::F { + C::hash_to_F(b"Serai DEX View Key", &k.to_le_bytes()) +}