Make coin a dedicated library

Closes https://github.com/serai-dex/serai/issues/128.
This commit is contained in:
Luke Parker
2022-10-15 23:21:43 -04:00
parent f50148d17a
commit 65664dafa4
9 changed files with 119 additions and 42 deletions

View File

@@ -5,8 +5,9 @@ use thiserror::Error;
use frost::{curve::Curve, FrostError};
mod coin;
pub use serai_coin as coin;
use coin::{CoinError, Coin};
mod wallet;
#[cfg(test)]
@@ -29,10 +30,3 @@ pub enum SignError {
#[error("network had an error {0}")]
NetworkError(NetworkError),
}
// Generate a static view 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, for more modern privacy protocols which use multiple view keys
pub fn view_key<C: Coin>(k: u64) -> <C::Curve as Curve>::F {
C::Curve::hash_to_F(b"Serai DEX View Key", &[C::ID, &k.to_le_bytes()].concat())
}