Skip to content

Commit

Permalink
chore: migration: use Scalar in key multiplication
Browse files Browse the repository at this point in the history
  • Loading branch information
sander2 committed Oct 6, 2022
1 parent c3508e2 commit a5b3cc6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion bitcoin/src/addr.rs
@@ -1,8 +1,10 @@
use bitcoincore_rpc::bitcoin::secp256k1::Scalar;

use crate::{secp256k1::SecretKey, Error};

pub fn calculate_deposit_secret_key(vault_key: SecretKey, issue_key: SecretKey) -> Result<SecretKey, Error> {
let mut deposit_key = vault_key;
deposit_key.mul_assign(&issue_key[..])?;
deposit_key.mul_assign(&Scalar::from(issue_key))?;
Ok(deposit_key)
}

Expand Down
4 changes: 2 additions & 2 deletions bitcoin/src/light/mod.rs
Expand Up @@ -2,7 +2,7 @@ mod error;
mod wallet;

pub use crate::{Error as BitcoinError, *};
use bitcoincore_rpc::bitcoin::blockdata::constants::WITNESS_SCALE_FACTOR;
use bitcoincore_rpc::bitcoin::{blockdata::constants::WITNESS_SCALE_FACTOR, secp256k1::Scalar};
pub use error::Error;

use async_trait::async_trait;
Expand Down Expand Up @@ -158,7 +158,7 @@ impl BitcoinCoreApi for BitcoinLight {
async fn add_new_deposit_key(&self, _public_key: PublicKey, secret_key: Vec<u8>) -> Result<(), BitcoinError> {
fn mul_secret_key(vault_key: SecretKey, issue_key: SecretKey) -> Result<SecretKey, BitcoinError> {
let mut deposit_key = vault_key;
deposit_key.mul_assign(&issue_key[..])?;
deposit_key.mul_assign(&Scalar::from(issue_key))?;
Ok(deposit_key)
}

Expand Down

0 comments on commit a5b3cc6

Please sign in to comment.