-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce a SignatoryManager service.
The SignatoryManager manager provides an API to interact with keysets, private keys, and all key-related operations, offering segregation between the mint and the most sensible part of the mind: the private keys. Although the default signatory runs in memory, it is completely isolated from the rest of the system and can only be communicated through the interface offered by the signatory manager. Only messages can be sent from the mintd to the Signatory trait through the Signatory Manager. This pull request sets the foundation for eventually being able to run the Signatory and all the key-related operations in a separate service, possibly in a foreign service, to offload risks, as described in #476. The Signatory manager is concurrent and deferred any mechanism needed to handle concurrency to the Signatory trait.
- Loading branch information
Showing
17 changed files
with
883 additions
and
516 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
//! Signatory mod | ||
//! | ||
//! This module abstract all the key related operations, defining an interface for the necessary | ||
//! operations, to be implemented by the different signatory implementations. | ||
//! | ||
//! 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 std::collections::HashMap; | ||
|
||
use bitcoin::bip32::DerivationPath; | ||
use cashu::{ | ||
BlindSignature, BlindedMessage, CurrencyUnit, Id, KeySet, KeysResponse, KeysetResponse, Proof, | ||
}; | ||
|
||
use super::error::Error; | ||
|
||
#[async_trait::async_trait] | ||
/// Signatory trait | ||
pub trait Signatory { | ||
/// Blind sign a message | ||
async fn blind_sign(&self, blinded_message: BlindedMessage) -> Result<BlindSignature, Error>; | ||
|
||
/// Verify [`Proof`] meets conditions and is signed | ||
async fn verify_proof(&self, proof: Proof) -> Result<(), Error>; | ||
|
||
/// Retrieve a keyset by id | ||
async fn keyset(&self, keyset_id: Id) -> Result<Option<KeySet>, Error>; | ||
|
||
/// Retrieve the public keys of a keyset | ||
async fn keyset_pubkeys(&self, keyset_id: Id) -> Result<KeysResponse, Error>; | ||
|
||
/// Retrieve the public keys of the active keyset for distribution to wallet | ||
/// clients | ||
async fn pubkeys(&self) -> Result<KeysResponse, Error>; | ||
|
||
/// Return a list of all supported keysets | ||
async fn keysets(&self) -> Result<KeysetResponse, Error>; | ||
|
||
/// Add current keyset to inactive keysets | ||
/// Generate new keyset | ||
async fn rotate_keyset( | ||
&self, | ||
unit: CurrencyUnit, | ||
derivation_path_index: u32, | ||
max_order: u8, | ||
input_fee_ppk: u64, | ||
custom_paths: HashMap<CurrencyUnit, DerivationPath>, | ||
) -> Result<(), Error>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[package] | ||
name = "cdk-signatory" | ||
version = "0.6.0" | ||
edition = "2021" | ||
description = "CDK signatory default implementation" | ||
|
||
[dependencies] | ||
async-trait = "0.1.83" | ||
bitcoin = { version = "0.32.2", features = [ | ||
"base64", | ||
"serde", | ||
"rand", | ||
"rand-std", | ||
] } | ||
cdk-common = { path = "../cdk-common", default-features = false, features = [ | ||
"mint", | ||
] } | ||
tracing = "0.1.41" | ||
tokio = { version = "1.21", features = ["rt", "macros", "sync", "time"] } |
Oops, something went wrong.