Selaa lähdekoodia

Use a single database for the signatory

Store all keys, even auth keys, in a single database. Leave the MintAuthDatabse
trait implementation for the CDK but not the signagtory

This commit also moves the cli mod to its own file
Cesar Rodas 8 kuukautta sitten
vanhempi
säilyke
a26783ce85

+ 0 - 1
crates/cdk-signatory/Cargo.toml

@@ -12,7 +12,6 @@ grpc = ["dep:tonic", "tokio/full", "dep:prost", "dep:tonic-build"]
 
 [dependencies]
 async-trait.workspace = true
-cashu.workspace = true
 bitcoin.workspace = true
 cdk-common = { workspace = true, default-features=false, features = [
     "mint", "auth",

+ 1 - 182
crates/cdk-signatory/src/bin/signatory.rs

@@ -1,184 +1,3 @@
-#[cfg(not(target_arch = "wasm32"))]
-mod cli {
-    use std::collections::HashMap;
-    use std::net::SocketAddr;
-    use std::path::PathBuf;
-    use std::str::FromStr;
-    use std::sync::Arc;
-    use std::{env, fs};
-
-    use anyhow::{bail, Result};
-    use bip39::rand::{thread_rng, Rng};
-    use bip39::Mnemonic;
-    use cashu::CurrencyUnit;
-    use cdk_common::database::{MintAuthDatabase, MintKeysDatabase};
-    #[cfg(feature = "redb")]
-    use cdk_redb::MintRedbDatabase;
-    use cdk_signatory::{db_signatory, grpc_server};
-    use cdk_sqlite::mint::MintSqliteAuthDatabase;
-    use cdk_sqlite::MintSqliteDatabase;
-    use clap::Parser;
-    use tracing::Level;
-    use tracing_subscriber::EnvFilter;
-
-    const DEFAULT_WORK_DIR: &str = ".cdk-signatory";
-    const ENV_MNEMONIC: &str = "CDK_MINTD_MNEMONIC";
-
-    /// Simple CLI application to interact with cashu
-    #[derive(Parser)]
-    #[command(name = "cashu-signatory")]
-    #[command(author = "thesimplekid <tsk@thesimplekid.com>")]
-    #[command(version = "0.1.0")]
-    #[command(author, version, about, long_about = None)]
-    struct Cli {
-        /// Database engine to use (sqlite/redb)
-        #[arg(short, long, default_value = "sqlite")]
-        engine: String,
-        /// Database password for sqlcipher
-        #[arg(long)]
-        password: Option<String>,
-        /// Path to working dir
-        #[arg(short, long)]
-        work_dir: Option<PathBuf>,
-        /// Logging level
-        #[arg(short, long, default_value = "error")]
-        log_level: Level,
-        #[arg(long, default_value = "127.0.0.1")]
-        listen_addr: String,
-        #[arg(long, default_value = "15060")]
-        listen_port: u32,
-        #[arg(long, short)]
-        certs: Option<String>,
-        /// Supported units with the format of name,fee and max_order
-        #[arg(long, short, default_value = "sat,0,32")]
-        units: Vec<String>,
-    }
-
-    pub async fn main() -> Result<()> {
-        let args: Cli = Cli::parse();
-        let default_filter = args.log_level;
-        let supported_units = args
-            .units
-            .into_iter()
-            .map(|unit| {
-                let mut parts = unit.split(",").collect::<Vec<_>>();
-                parts.reverse();
-                let unit: CurrencyUnit = parts.pop().unwrap_or_default().parse()?;
-                let fee = parts
-                    .pop()
-                    .map(|x| x.parse())
-                    .transpose()?
-                    .unwrap_or_default();
-                let max_order = parts.pop().map(|x| x.parse()).transpose()?.unwrap_or(32);
-                Ok::<(_, (_, _)), anyhow::Error>((unit, (fee, max_order)))
-            })
-            .collect::<Result<HashMap<_, _>, _>>()?;
-
-        let sqlx_filter = "sqlx=warn,hyper_util=warn,reqwest=warn";
-
-        let env_filter = EnvFilter::new(format!("{default_filter},{sqlx_filter}"));
-
-        // Parse input
-        tracing_subscriber::fmt().with_env_filter(env_filter).init();
-
-        let work_dir = match &args.work_dir {
-            Some(work_dir) => work_dir.clone(),
-            None => {
-                let home_dir = home::home_dir().unwrap();
-                home_dir.join(DEFAULT_WORK_DIR)
-            }
-        };
-
-        let certs = Some(
-            args.certs
-                .map(|x| x.into())
-                .unwrap_or_else(|| work_dir.clone()),
-        );
-
-        fs::create_dir_all(&work_dir)?;
-
-        let (localstore, auth_localstore): (
-            Arc<dyn MintKeysDatabase<Err = cdk_common::database::Error> + Send + Sync>,
-            Arc<dyn MintAuthDatabase<Err = cdk_common::database::Error> + Send + Sync>,
-        ) = match args.engine.as_str() {
-            "sqlite" => {
-                let sql_path = work_dir.join("cdk-cli.sqlite");
-                #[cfg(not(feature = "sqlcipher"))]
-                let db = (
-                    MintSqliteDatabase::new(&sql_path).await?,
-                    MintSqliteAuthDatabase::new(&sql_path).await?,
-                );
-                #[cfg(feature = "sqlcipher")]
-                let db = {
-                    match args.password {
-                        Some(pass) => (
-                            MintSqliteDatabase::new(&sql_path, pass).await?,
-                            MintSqliteAuthDatabase::new(&sql_path).await?,
-                        ),
-                        None => bail!("Missing database password"),
-                    }
-                };
-
-                (Arc::new(db.0), Arc::new(db.1))
-            }
-            "redb" => {
-                #[cfg(feature = "redb")]
-                {
-                    let redb_path = work_dir.join("cdk-cli.redb");
-                    let db = Arc::new(MintRedbDatabase::new(&redb_path)?);
-                    (db.clone(), db)
-                }
-                #[cfg(not(feature = "redb"))]
-                {
-                    bail!("redb feature not enabled");
-                }
-            }
-            _ => bail!("Unknown DB engine"),
-        };
-
-        let seed_path = work_dir.join("seed");
-
-        let mnemonic = if let Ok(mnemonic) = env::var(ENV_MNEMONIC) {
-            Mnemonic::from_str(&mnemonic)?
-        } else {
-            match fs::metadata(seed_path.clone()) {
-                Ok(_) => {
-                    let contents = fs::read_to_string(seed_path.clone())?;
-                    Mnemonic::from_str(&contents)?
-                }
-                Err(_e) => {
-                    let mut rng = thread_rng();
-                    let random_bytes: [u8; 32] = rng.gen();
-
-                    let mnemonic = Mnemonic::from_entropy(&random_bytes)?;
-                    tracing::info!("Creating new seed");
-
-                    fs::write(seed_path, mnemonic.to_string())?;
-
-                    mnemonic
-                }
-            }
-        };
-        let seed = mnemonic.to_seed_normalized("");
-
-        let signatory = db_signatory::DbSignatory::new(
-            localstore,
-            Some(auth_localstore),
-            &seed,
-            supported_units,
-            Default::default(),
-        )
-        .await?;
-
-        let socket_addr =
-            SocketAddr::from_str(&format!("{}:{}", args.listen_addr, args.listen_port))?;
-
-        grpc_server(signatory, socket_addr, certs).await?;
-
-        Ok(())
-    }
-}
-
 fn main() {
     #[cfg(target_arch = "wasm32")]
     println!("Not supported in wasm32");
@@ -187,7 +6,7 @@ fn main() {
         use tokio::runtime::Runtime;
         let rt = Runtime::new().unwrap();
         rt.block_on(async {
-            cli::main().await.unwrap();
+            cdk_signatory::cli::main().await.unwrap();
         });
     }
 }

+ 167 - 0
crates/cdk-signatory/src/cli.rs

@@ -0,0 +1,167 @@
+//! Signatory CLI main logic
+//!
+//! This logic is in this file to be excluded for wasm
+use std::collections::HashMap;
+use std::net::SocketAddr;
+use std::path::PathBuf;
+use std::str::FromStr;
+use std::sync::Arc;
+use std::{env, fs};
+
+use anyhow::{bail, Result};
+use bip39::rand::{thread_rng, Rng};
+use bip39::Mnemonic;
+use cdk_common::database::MintKeysDatabase;
+use cdk_common::CurrencyUnit;
+#[cfg(feature = "redb")]
+use cdk_redb::MintRedbDatabase;
+use cdk_sqlite::MintSqliteDatabase;
+use clap::Parser;
+use tracing::Level;
+use tracing_subscriber::EnvFilter;
+
+use crate::{db_signatory, grpc_server};
+
+const DEFAULT_WORK_DIR: &str = ".cdk-signatory";
+const ENV_MNEMONIC: &str = "CDK_MINTD_MNEMONIC";
+
+/// Simple CLI application to interact with cashu
+#[derive(Parser)]
+#[command(name = "cashu-signatory")]
+#[command(author = "thesimplekid <tsk@thesimplekid.com>")]
+#[command(version = "0.1.0")]
+#[command(author, version, about, long_about = None)]
+struct Cli {
+    /// Database engine to use (sqlite/redb)
+    #[arg(short, long, default_value = "sqlite")]
+    engine: String,
+    /// Database password for sqlcipher
+    #[arg(long)]
+    password: Option<String>,
+    /// Path to working dir
+    #[arg(short, long)]
+    work_dir: Option<PathBuf>,
+    /// Logging level
+    #[arg(short, long, default_value = "error")]
+    log_level: Level,
+    #[arg(long, default_value = "127.0.0.1")]
+    listen_addr: String,
+    #[arg(long, default_value = "15060")]
+    listen_port: u32,
+    #[arg(long, short)]
+    certs: Option<String>,
+    /// Supported units with the format of name,fee and max_order
+    #[arg(long, short, default_value = "sat,0,32")]
+    units: Vec<String>,
+}
+
+/// Main function for the signatory standalone binary
+pub async fn main() -> Result<()> {
+    let args: Cli = Cli::parse();
+    let default_filter = args.log_level;
+    let supported_units = args
+        .units
+        .into_iter()
+        .map(|unit| {
+            let mut parts = unit.split(",").collect::<Vec<_>>();
+            parts.reverse();
+            let unit: CurrencyUnit = parts.pop().unwrap_or_default().parse()?;
+            let fee = parts
+                .pop()
+                .map(|x| x.parse())
+                .transpose()?
+                .unwrap_or_default();
+            let max_order = parts.pop().map(|x| x.parse()).transpose()?.unwrap_or(32);
+            Ok::<(_, (_, _)), anyhow::Error>((unit, (fee, max_order)))
+        })
+        .collect::<Result<HashMap<_, _>, _>>()?;
+
+    let sqlx_filter = "sqlx=warn,hyper_util=warn,reqwest=warn";
+
+    let env_filter = EnvFilter::new(format!("{default_filter},{sqlx_filter}"));
+
+    // Parse input
+    tracing_subscriber::fmt().with_env_filter(env_filter).init();
+
+    let work_dir = match &args.work_dir {
+        Some(work_dir) => work_dir.clone(),
+        None => {
+            let home_dir = home::home_dir().unwrap();
+            home_dir.join(DEFAULT_WORK_DIR)
+        }
+    };
+
+    let certs = Some(
+        args.certs
+            .map(|x| x.into())
+            .unwrap_or_else(|| work_dir.clone()),
+    );
+
+    fs::create_dir_all(&work_dir)?;
+
+    let localstore: Arc<dyn MintKeysDatabase<Err = cdk_common::database::Error> + Send + Sync> =
+        match args.engine.as_str() {
+            "sqlite" => {
+                let sql_path = work_dir.join("cdk-cli.sqlite");
+                #[cfg(not(feature = "sqlcipher"))]
+                let db = MintSqliteDatabase::new(&sql_path).await?;
+                #[cfg(feature = "sqlcipher")]
+                let db = {
+                    match args.password {
+                        Some(pass) => MintSqliteDatabase::new(&sql_path, pass).await?,
+                        None => bail!("Missing database password"),
+                    }
+                };
+
+                Arc::new(db)
+            }
+            "redb" => {
+                #[cfg(feature = "redb")]
+                {
+                    let redb_path = work_dir.join("cdk-cli.redb");
+                    let db = Arc::new(MintRedbDatabase::new(&redb_path)?);
+                    db
+                }
+                #[cfg(not(feature = "redb"))]
+                {
+                    bail!("redb feature not enabled");
+                }
+            }
+            _ => bail!("Unknown DB engine"),
+        };
+
+    let seed_path = work_dir.join("seed");
+
+    let mnemonic = if let Ok(mnemonic) = env::var(ENV_MNEMONIC) {
+        Mnemonic::from_str(&mnemonic)?
+    } else {
+        match fs::metadata(seed_path.clone()) {
+            Ok(_) => {
+                let contents = fs::read_to_string(seed_path.clone())?;
+                Mnemonic::from_str(&contents)?
+            }
+            Err(_e) => {
+                let mut rng = thread_rng();
+                let random_bytes: [u8; 32] = rng.gen();
+
+                let mnemonic = Mnemonic::from_entropy(&random_bytes)?;
+                tracing::info!("Creating new seed");
+
+                fs::write(seed_path, mnemonic.to_string())?;
+
+                mnemonic
+            }
+        }
+    };
+    let seed = mnemonic.to_seed_normalized("");
+
+    let signatory =
+        db_signatory::DbSignatory::new(localstore, &seed, supported_units, Default::default())
+            .await?;
+
+    let socket_addr = SocketAddr::from_str(&format!("{}:{}", args.listen_addr, args.listen_port))?;
+
+    grpc_server(signatory, socket_addr, certs).await?;
+
+    Ok(())
+}

+ 4 - 52
crates/cdk-signatory/src/db_signatory.rs

@@ -6,11 +6,10 @@ use std::sync::Arc;
 
 use bitcoin::bip32::{DerivationPath, Xpriv};
 use bitcoin::secp256k1::{self, Secp256k1};
-use cashu::PublicKey;
 use cdk_common::dhke::{sign_message, verify_message};
 use cdk_common::mint::MintKeySetInfo;
 use cdk_common::nuts::{BlindSignature, BlindedMessage, CurrencyUnit, Id, MintKeySet, Proof};
-use cdk_common::{database, Error};
+use cdk_common::{database, Error, PublicKey};
 use tokio::sync::RwLock;
 use tracing::instrument;
 
@@ -26,10 +25,7 @@ use crate::signatory::{RotateKeyArguments, Signatory, SignatoryKeySet, Signatory
 pub struct DbSignatory {
     keysets: RwLock<HashMap<Id, (MintKeySetInfo, MintKeySet)>>,
     active_keysets: RwLock<HashMap<CurrencyUnit, Id>>,
-    /// TODO: Merge localstore with auth_localstore (use the same db). It makes sense in CDK but not here.
     localstore: Arc<dyn database::MintKeysDatabase<Err = database::Error> + Send + Sync>,
-    auth_localstore:
-        Option<Arc<dyn database::MintAuthDatabase<Err = database::Error> + Send + Sync>>,
     secp_ctx: Secp256k1<secp256k1::All>,
     custom_paths: HashMap<CurrencyUnit, DerivationPath>,
     xpriv: Xpriv,
@@ -40,11 +36,8 @@ impl DbSignatory {
     /// Creates a new MemorySignatory instance
     pub async fn new(
         localstore: Arc<dyn database::MintKeysDatabase<Err = database::Error> + Send + Sync>,
-        auth_localstore: Option<
-            Arc<dyn database::MintAuthDatabase<Err = database::Error> + Send + Sync>,
-        >,
         seed: &[u8],
-        supported_units: HashMap<CurrencyUnit, (u64, u8)>,
+        mut supported_units: HashMap<CurrencyUnit, (u64, u8)>,
         custom_paths: HashMap<CurrencyUnit, DerivationPath>,
     ) -> Result<Self, Error> {
         let secp_ctx = Secp256k1::new();
@@ -59,29 +52,7 @@ impl DbSignatory {
         )
         .await?;
 
-        if let Some(auth_localstore) = auth_localstore.as_ref() {
-            tracing::info!("Auth enabled creating auth keysets");
-            let derivation_path = match custom_paths.get(&CurrencyUnit::Auth) {
-                Some(path) => path.clone(),
-                None => derivation_path_from_unit(CurrencyUnit::Auth, 0)
-                    .ok_or(Error::UnsupportedUnit)?,
-            };
-
-            let (keyset, keyset_info) = create_new_keyset(
-                &secp_ctx,
-                xpriv,
-                derivation_path,
-                Some(0),
-                CurrencyUnit::Auth,
-                1,
-                0,
-            );
-
-            let id = keyset_info.id;
-            auth_localstore.add_keyset_info(keyset_info).await?;
-            auth_localstore.set_active_keyset(id).await?;
-            active_keysets.insert(id, keyset);
-        }
+        supported_units.entry(CurrencyUnit::Auth).or_insert((0, 1));
 
         // Create new keysets for supported units that aren't covered by the current keysets
         for (unit, (fee, max_order)) in supported_units {
@@ -113,7 +84,6 @@ impl DbSignatory {
         let keys = Self {
             keysets: Default::default(),
             active_keysets: Default::default(),
-            auth_localstore,
             localstore,
             custom_paths,
             xpub: xpriv.to_keypair(&secp_ctx).public_key().into(),
@@ -150,23 +120,6 @@ impl DbSignatory {
             keysets.insert(id, (info, keyset));
         }
 
-        if let Some(auth_db) = self.auth_localstore.clone() {
-            let active_auth_keyset = auth_db.get_active_keyset_id().await?;
-            for mut info in auth_db.get_keyset_infos().await? {
-                let id = info.id;
-                let keyset = self.generate_keyset(&info);
-                if info.unit != CurrencyUnit::Auth {
-                    continue;
-                }
-                info.active = active_auth_keyset == Some(info.id);
-                tracing::info!("Loading auth key from {} {:?}", id, info);
-                if info.active {
-                    active_keysets.insert(info.unit.clone(), id);
-                }
-                keysets.insert(id, (info, keyset));
-            }
-        }
-
         Ok(())
     }
 
@@ -300,8 +253,7 @@ mod test {
 
     use bitcoin::key::Secp256k1;
     use bitcoin::Network;
-    use cashu::{Amount, PublicKey};
-    use cdk_common::MintKeySet;
+    use cdk_common::{Amount, MintKeySet, PublicKey};
 
     use super::*;
 

+ 1 - 2
crates/cdk-signatory/src/embedded.rs

@@ -2,8 +2,7 @@
 //! run the Signatory in another thread, isolated form the main CDK, communicating through messages
 use std::sync::Arc;
 
-use cashu::{BlindSignature, BlindedMessage, Proof};
-use cdk_common::Error;
+use cdk_common::{BlindSignature, BlindedMessage, Error, Proof};
 use tokio::sync::{mpsc, oneshot};
 use tokio::task::JoinHandle;
 

+ 3 - 0
crates/cdk-signatory/src/lib.rs

@@ -19,3 +19,6 @@ mod common;
 pub mod db_signatory;
 pub mod embedded;
 pub mod signatory;
+
+#[cfg(not(target_arch = "wasm32"))]
+pub mod cli;

+ 24 - 25
crates/cdk-signatory/src/proto/convert.rs

@@ -1,10 +1,9 @@
 //! Type conversions between Rust types and the generated protobuf types.
 use std::collections::BTreeMap;
 
-use cashu::secret::Secret;
-use cashu::util::hex;
-use cashu::{Amount, PublicKey};
-use cdk_common::{HTLCWitness, P2PKWitness};
+use cdk_common::secret::Secret;
+use cdk_common::util::hex;
+use cdk_common::{Amount, HTLCWitness, P2PKWitness, PublicKey};
 use tonic::Status;
 
 use super::*;
@@ -311,35 +310,35 @@ impl TryInto<()> for EmptyRequest {
     }
 }
 
-impl From<cashu::CurrencyUnit> for CurrencyUnit {
-    fn from(value: cashu::CurrencyUnit) -> Self {
+impl From<cdk_common::CurrencyUnit> for CurrencyUnit {
+    fn from(value: cdk_common::CurrencyUnit) -> Self {
         match value {
-            cashu::CurrencyUnit::Sat => CurrencyUnit {
+            cdk_common::CurrencyUnit::Sat => CurrencyUnit {
                 currency_unit: Some(currency_unit::CurrencyUnit::Unit(
                     CurrencyUnitType::Sat.into(),
                 )),
             },
-            cashu::CurrencyUnit::Msat => CurrencyUnit {
+            cdk_common::CurrencyUnit::Msat => CurrencyUnit {
                 currency_unit: Some(currency_unit::CurrencyUnit::Unit(
                     CurrencyUnitType::Msat.into(),
                 )),
             },
-            cashu::CurrencyUnit::Usd => CurrencyUnit {
+            cdk_common::CurrencyUnit::Usd => CurrencyUnit {
                 currency_unit: Some(currency_unit::CurrencyUnit::Unit(
                     CurrencyUnitType::Usd.into(),
                 )),
             },
-            cashu::CurrencyUnit::Eur => CurrencyUnit {
+            cdk_common::CurrencyUnit::Eur => CurrencyUnit {
                 currency_unit: Some(currency_unit::CurrencyUnit::Unit(
                     CurrencyUnitType::Eur.into(),
                 )),
             },
-            cashu::CurrencyUnit::Auth => CurrencyUnit {
+            cdk_common::CurrencyUnit::Auth => CurrencyUnit {
                 currency_unit: Some(currency_unit::CurrencyUnit::Unit(
                     CurrencyUnitType::Auth.into(),
                 )),
             },
-            cashu::CurrencyUnit::Custom(name) => CurrencyUnit {
+            cdk_common::CurrencyUnit::Custom(name) => CurrencyUnit {
                 currency_unit: Some(currency_unit::CurrencyUnit::CustomUnit(name)),
             },
             _ => unreachable!(),
@@ -347,36 +346,36 @@ impl From<cashu::CurrencyUnit> for CurrencyUnit {
     }
 }
 
-impl TryInto<cashu::CurrencyUnit> for CurrencyUnit {
+impl TryInto<cdk_common::CurrencyUnit> for CurrencyUnit {
     type Error = Status;
 
-    fn try_into(self) -> Result<cashu::CurrencyUnit, Self::Error> {
+    fn try_into(self) -> Result<cdk_common::CurrencyUnit, Self::Error> {
         match self.currency_unit {
             Some(currency_unit::CurrencyUnit::Unit(u)) => match u
                 .try_into()
                 .map_err(|_| Status::invalid_argument("Invalid currency unit"))?
             {
-                CurrencyUnitType::Sat => Ok(cashu::CurrencyUnit::Sat),
-                CurrencyUnitType::Msat => Ok(cashu::CurrencyUnit::Msat),
-                CurrencyUnitType::Usd => Ok(cashu::CurrencyUnit::Usd),
-                CurrencyUnitType::Eur => Ok(cashu::CurrencyUnit::Eur),
-                CurrencyUnitType::Auth => Ok(cashu::CurrencyUnit::Auth),
+                CurrencyUnitType::Sat => Ok(cdk_common::CurrencyUnit::Sat),
+                CurrencyUnitType::Msat => Ok(cdk_common::CurrencyUnit::Msat),
+                CurrencyUnitType::Usd => Ok(cdk_common::CurrencyUnit::Usd),
+                CurrencyUnitType::Eur => Ok(cdk_common::CurrencyUnit::Eur),
+                CurrencyUnitType::Auth => Ok(cdk_common::CurrencyUnit::Auth),
                 CurrencyUnitType::Unspecified => {
                     Err(Status::invalid_argument("Current unit is not specified"))
                 }
             },
             Some(currency_unit::CurrencyUnit::CustomUnit(name)) => {
-                Ok(cashu::CurrencyUnit::Custom(name))
+                Ok(cdk_common::CurrencyUnit::Custom(name))
             }
             None => Err(Status::invalid_argument("Currency unit not set")),
         }
     }
 }
 
-impl TryInto<cashu::KeySet> for KeySet {
+impl TryInto<cdk_common::KeySet> for KeySet {
     type Error = cdk_common::error::Error;
-    fn try_into(self) -> Result<cashu::KeySet, Self::Error> {
-        Ok(cashu::KeySet {
+    fn try_into(self) -> Result<cdk_common::KeySet, Self::Error> {
+        Ok(cdk_common::KeySet {
             id: self
                 .id
                 .parse()
@@ -386,13 +385,13 @@ impl TryInto<cashu::KeySet> for KeySet {
                 .ok_or(cdk_common::error::Error::Custom(INTERNAL_ERROR.to_owned()))?
                 .try_into()
                 .map_err(|_| cdk_common::Error::Custom("Invalid unit encoding".to_owned()))?,
-            keys: cashu::Keys::new(
+            keys: cdk_common::Keys::new(
                 self.keys
                     .ok_or(cdk_common::error::Error::Custom(INTERNAL_ERROR.to_owned()))?
                     .keys
                     .into_iter()
                     .map(|(k, v)| cdk_common::PublicKey::from_slice(&v).map(|pk| (k.into(), pk)))
-                    .collect::<Result<BTreeMap<cashu::Amount, cdk_common::PublicKey>, _>>()?,
+                    .collect::<Result<BTreeMap<cdk_common::Amount, cdk_common::PublicKey>, _>>()?,
             ),
         })
     }

+ 3 - 3
crates/cdk-signatory/src/signatory.rs

@@ -6,11 +6,11 @@
 //! There is an in memory implementation, when the keys are stored in memory, in the same process,
 //! but it is isolated from the rest of the application, and they communicate through a channel with
 //! the defined API.
-use cashu::{
-    BlindSignature, BlindedMessage, CurrencyUnit, Id, KeySet, Keys, MintKeySet, Proof, PublicKey,
-};
 use cdk_common::error::Error;
 use cdk_common::mint::MintKeySetInfo;
+use cdk_common::{
+    BlindSignature, BlindedMessage, CurrencyUnit, Id, KeySet, Keys, MintKeySet, Proof, PublicKey,
+};
 
 #[derive(Debug)]
 /// Type alias to make the keyset info API more useful, queryable by unit and Id

+ 0 - 7
crates/cdk/src/mint/builder.rs

@@ -344,15 +344,8 @@ impl MintBuilder {
             signatory.clone()
         } else {
             let seed = self.seed.as_ref().ok_or(anyhow!("Mint seed not set"))?;
-            #[cfg(feature = "auth")]
-            let auth_localstore = self.auth_localstore.clone();
-
-            #[cfg(not(feature = "auth"))]
-            let auth_localstore = None;
-
             let in_memory_signatory = cdk_signatory::db_signatory::DbSignatory::new(
                 self.keystore.clone().ok_or(anyhow!("keystore not set"))?,
-                auth_localstore,
                 seed,
                 self.supported_units.clone(),
                 HashMap::new(),

+ 1 - 1
crates/cdk/src/mint/issue/issue_nut04.rs

@@ -309,7 +309,7 @@ impl Mint {
         let mut blind_signatures = Vec::with_capacity(mint_request.outputs.len());
 
         for blinded_message in mint_request.outputs.iter() {
-            let blind_signature = self.blind_sign(blinded_message).await?;
+            let blind_signature = self.blind_sign(blinded_message.clone()).await?;
             blind_signatures.push(blind_signature);
         }
 

+ 1 - 1
crates/cdk/src/mint/melt.rs

@@ -701,7 +701,7 @@ impl Mint {
                 for (amount, blinded_message) in amounts.iter().zip(&mut outputs) {
                     blinded_message.amount = *amount;
 
-                    let blinded_signature = self.blind_sign(blinded_message).await?;
+                    let blinded_signature = self.blind_sign(blinded_message.clone()).await?;
                     change_sigs.push(blinded_signature)
                 }
 

+ 4 - 4
crates/cdk/src/mint/mod.rs

@@ -362,10 +362,10 @@ impl Mint {
     #[tracing::instrument(skip_all)]
     pub async fn blind_sign(
         &self,
-        blinded_message: &BlindedMessage,
+        blinded_message: BlindedMessage,
     ) -> Result<BlindSignature, Error> {
         self.signatory
-            .blind_sign(vec![blinded_message.to_owned()])
+            .blind_sign(vec![blinded_message])
             .await?
             .pop()
             .ok_or(Error::Internal)
@@ -373,7 +373,7 @@ impl Mint {
 
     /// Verify [`Proof`] meets conditions and is signed
     #[tracing::instrument(skip_all)]
-    pub async fn verify_proofs(&self, proofs: &Proofs) -> Result<(), Error> {
+    pub async fn verify_proofs(&self, proofs: Proofs) -> Result<(), Error> {
         proofs
             .iter()
             .map(|proof| {
@@ -400,7 +400,7 @@ impl Mint {
             })
             .collect::<Result<Vec<()>, Error>>()?;
 
-        self.signatory.verify_proofs(proofs.to_owned()).await
+        self.signatory.verify_proofs(proofs).await
     }
 
     /// Verify melt request is valid

+ 1 - 1
crates/cdk/src/mint/swap.rs

@@ -32,7 +32,7 @@ impl Mint {
         let mut promises = Vec::with_capacity(swap_request.outputs().len());
 
         for blinded_message in swap_request.outputs() {
-            let blinded_signature = self.blind_sign(blinded_message).await?;
+            let blinded_signature = self.blind_sign(blinded_message.clone()).await?;
             promises.push(blinded_signature);
         }
 

+ 1 - 1
crates/cdk/src/mint/verification.rs

@@ -203,7 +203,7 @@ impl Mint {
         let unit = self.verify_inputs_keyset(inputs).await?;
         let amount = inputs.total_amount()?;
 
-        self.verify_proofs(inputs).await?;
+        self.verify_proofs(inputs.clone()).await?;
 
         Ok(Verification {
             amount,