mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 12:19:24 +00:00
Move additional_key.rs to serai-processor-view-keys
I don't love this. I wanted to simply add this function to `processor/key-gen`, but then anyone who wants a view key needs to pull in Bulletproofs which is a mess of code. They'd also be subject to an AGPL licensed library. This is so small it should be a primitive elsewhere, yet there is no primitives library eligible. Maybe serai-client since that has the code to make transactions to Serai (and will have this as a dependency)? Except then the processor has to import serai-client when this rewrite removed it as a dependency.
This commit is contained in:
1
.github/workflows/tests.yml
vendored
1
.github/workflows/tests.yml
vendored
@@ -40,6 +40,7 @@ jobs:
|
|||||||
-p serai-message-queue \
|
-p serai-message-queue \
|
||||||
-p serai-processor-messages \
|
-p serai-processor-messages \
|
||||||
-p serai-processor-key-gen \
|
-p serai-processor-key-gen \
|
||||||
|
-p serai-processor-view-keys \
|
||||||
-p serai-processor-frost-attempt-manager \
|
-p serai-processor-frost-attempt-manager \
|
||||||
-p serai-processor-primitives \
|
-p serai-processor-primitives \
|
||||||
-p serai-processor-scanner \
|
-p serai-processor-scanner \
|
||||||
|
|||||||
7
Cargo.lock
generated
7
Cargo.lock
generated
@@ -8760,6 +8760,13 @@ dependencies = [
|
|||||||
"serai-processor-scheduler-primitives",
|
"serai-processor-scheduler-primitives",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serai-processor-view-keys"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"ciphersuite",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serai-reproducible-runtime-tests"
|
name = "serai-reproducible-runtime-tests"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ members = [
|
|||||||
|
|
||||||
"processor/messages",
|
"processor/messages",
|
||||||
"processor/key-gen",
|
"processor/key-gen",
|
||||||
|
"processor/view-keys",
|
||||||
"processor/frost-attempt-manager",
|
"processor/frost-attempt-manager",
|
||||||
|
|
||||||
"processor/primitives",
|
"processor/primitives",
|
||||||
|
|||||||
@@ -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<N: Network>(k: u64) -> <N::Curve as Ciphersuite>::F {
|
|
||||||
<N::Curve as Ciphersuite>::hash_to_F(
|
|
||||||
b"Serai DEX Additional Key",
|
|
||||||
&[N::ID.as_bytes(), &k.to_le_bytes()].concat(),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
@@ -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;
|
|
||||||
@@ -27,9 +27,6 @@ use serai_env as env;
|
|||||||
|
|
||||||
use message_queue::{Service, client::MessageQueue};
|
use message_queue::{Service, client::MessageQueue};
|
||||||
|
|
||||||
mod plan;
|
|
||||||
pub use plan::*;
|
|
||||||
|
|
||||||
mod networks;
|
mod networks;
|
||||||
use networks::{Block, Network};
|
use networks::{Block, Network};
|
||||||
#[cfg(feature = "bitcoin")]
|
#[cfg(feature = "bitcoin")]
|
||||||
@@ -39,9 +36,6 @@ use networks::Ethereum;
|
|||||||
#[cfg(feature = "monero")]
|
#[cfg(feature = "monero")]
|
||||||
use networks::Monero;
|
use networks::Monero;
|
||||||
|
|
||||||
mod additional_key;
|
|
||||||
pub use additional_key::additional_key;
|
|
||||||
|
|
||||||
mod db;
|
mod db;
|
||||||
pub use db::*;
|
pub use db::*;
|
||||||
|
|
||||||
|
|||||||
@@ -4,5 +4,5 @@ pub enum MultisigEvent<N: Network> {
|
|||||||
// Batches to publish
|
// Batches to publish
|
||||||
Batches(Option<(<N::Curve as Ciphersuite>::G, <N::Curve as Ciphersuite>::G)>, Vec<Batch>),
|
Batches(Option<(<N::Curve as Ciphersuite>::G, <N::Curve as Ciphersuite>::G)>, Vec<Batch>),
|
||||||
// Eventuality completion found on-chain
|
// Eventuality completion found on-chain
|
||||||
Completed(Vec<u8>, [u8; 32], <N::Eventu
|
Completed(Vec<u8>, [u8; 32], N::Eventuality),
|
||||||
}
|
}
|
||||||
|
|||||||
19
processor/view-keys/Cargo.toml
Normal file
19
processor/view-keys/Cargo.toml
Normal file
@@ -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 <lukeparker5132@gmail.com>"]
|
||||||
|
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"] }
|
||||||
21
processor/view-keys/LICENSE
Normal file
21
processor/view-keys/LICENSE
Normal file
@@ -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.
|
||||||
6
processor/view-keys/README.md
Normal file
6
processor/view-keys/README.md
Normal file
@@ -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.
|
||||||
13
processor/view-keys/src/lib.rs
Normal file
13
processor/view-keys/src/lib.rs
Normal file
@@ -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<C: Ciphersuite>(k: u64) -> C::F {
|
||||||
|
C::hash_to_F(b"Serai DEX View Key", &k.to_le_bytes())
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user