Skip to content

Commit

Permalink
cast from proto enum
Browse files Browse the repository at this point in the history
  • Loading branch information
milapsheth committed Jul 10, 2024
1 parent 009ac2b commit 8eaef4f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 15 deletions.
7 changes: 2 additions & 5 deletions src/multisig/key_presence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@ impl MultisigService {
&self,
request: proto::KeyPresenceRequest,
) -> TofndResult<proto::key_presence_response::Response> {
let algorithm = match request.algorithm {
0 => Algorithm::Ecdsa,
1 => Algorithm::Ed25519,
_ => return Err(anyhow!("Invalid algorithm: {}", request.algorithm)),
};
let algorithm = Algorithm::from_i32(request.algorithm)
.ok_or_else(|| anyhow!("Invalid algorithm: {}", request.algorithm))?;

// check if mnemonic is available
let _ = self
Expand Down
7 changes: 2 additions & 5 deletions src/multisig/keygen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@ use anyhow::anyhow;

impl MultisigService {
pub(super) async fn handle_keygen(&self, request: &KeygenRequest) -> TofndResult<Vec<u8>> {
let algorithm = match request.algorithm {
0 => Algorithm::Ecdsa,
1 => Algorithm::Ed25519,
_ => return Err(anyhow!("Invalid algorithm: {}", request.algorithm)),
};
let algorithm = Algorithm::from_i32(request.algorithm)
.ok_or_else(|| anyhow!("Invalid algorithm: {}", request.algorithm))?;
let secret_recovery_key = self.kv_manager.seed().await?;

Ok(
Expand Down
7 changes: 2 additions & 5 deletions src/multisig/sign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,8 @@ use tofn::sdk::api::SecretRecoveryKey;

impl MultisigService {
pub(super) async fn handle_sign(&self, request: &SignRequest) -> TofndResult<Vec<u8>> {
let algorithm = match request.algorithm {
0 => Algorithm::Ecdsa,
1 => Algorithm::Ed25519,
_ => return Err(anyhow!("Invalid algorithm: {}", request.algorithm)),
};
let algorithm = Algorithm::from_i32(request.algorithm)
.ok_or_else(|| anyhow!("Invalid algorithm: {}", request.algorithm))?;

// re-generate secret key from seed, then sign
let secret_recovery_key = self
Expand Down

0 comments on commit 8eaef4f

Please sign in to comment.