Downgrade secp256k1 to 0.24 (#15)
This commit is contained in:
parent
9f835ffc8d
commit
bd7962db21
|
@ -9,7 +9,7 @@ crate-type = ["lib"]
|
|||
|
||||
[dependencies]
|
||||
# bdk = {version = "0.20.0", features= ["all-keys"] }
|
||||
secp256k1 = {version = "0.27", features = ["bitcoin-hashes-std"] }
|
||||
secp256k1 = {version = "0.24", features = ["bitcoin-hashes-std"] }
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
hex = "0.4"
|
||||
|
|
|
@ -180,7 +180,7 @@ pub fn verify_and_calculate_signatures(
|
|||
) -> Result<Vec<OutputWithSignature>> {
|
||||
let secp = secp256k1::Secp256k1::new();
|
||||
let msg = Message::from_hashed_data::<secp256k1::hashes::sha256::Hash>(b"message");
|
||||
let aux = secp256k1::hashes::sha256::Hash::hash(b"random auxiliary data").to_byte_array();
|
||||
let aux = secp256k1::hashes::sha256::Hash::hash(b"random auxiliary data").into_inner();
|
||||
|
||||
let mut res: Vec<OutputWithSignature> = vec![];
|
||||
for output in add_to_wallet {
|
||||
|
|
|
@ -7,7 +7,7 @@ use crate::{error::Error, structs::Outpoint};
|
|||
pub type Result<T> = std::result::Result<T, Error>;
|
||||
|
||||
pub fn sha256(message: &[u8]) -> [u8; 32] {
|
||||
sha256::Hash::hash(message).to_byte_array()
|
||||
sha256::Hash::hash(message).into_inner()
|
||||
}
|
||||
|
||||
pub fn ser_uint32(u: u32) -> Vec<u8> {
|
||||
|
@ -35,5 +35,5 @@ pub fn hash_outpoints(sending_data: &HashSet<Outpoint>) -> Result<[u8; 32]> {
|
|||
engine.write_all(&v).unwrap();
|
||||
}
|
||||
|
||||
Ok(sha256::Hash::from_engine(engine).to_byte_array())
|
||||
Ok(sha256::Hash::from_engine(engine).into_inner())
|
||||
}
|
||||
|
|
|
@ -1,6 +1,14 @@
|
|||
use std::{collections::HashSet, fs::File, io::{Read, Write}, str::FromStr};
|
||||
use std::{
|
||||
collections::HashSet,
|
||||
fs::File,
|
||||
io::{Read, Write},
|
||||
str::FromStr,
|
||||
};
|
||||
|
||||
use secp256k1::{PublicKey, SecretKey, XOnlyPublicKey, hashes::{sha256, Hash}, Scalar};
|
||||
use secp256k1::{
|
||||
hashes::{sha256, Hash},
|
||||
PublicKey, Scalar, SecretKey, XOnlyPublicKey,
|
||||
};
|
||||
use serde_json::from_str;
|
||||
use silentpayments::structs::Outpoint;
|
||||
|
||||
|
@ -86,7 +94,11 @@ pub fn get_a_sum_secret_keys(input: &Vec<(SecretKey, bool)>) -> SecretKey {
|
|||
result
|
||||
}
|
||||
|
||||
pub fn compute_ecdh_shared_secret(a_sum: SecretKey, B_scan: PublicKey, outpoints_hash: Scalar) -> PublicKey {
|
||||
pub fn compute_ecdh_shared_secret(
|
||||
a_sum: SecretKey,
|
||||
B_scan: PublicKey,
|
||||
outpoints_hash: Scalar,
|
||||
) -> PublicKey {
|
||||
let secp = secp256k1::Secp256k1::new();
|
||||
|
||||
let diffie_hellman = B_scan.mul_tweak(&secp, &a_sum.into()).unwrap();
|
||||
|
@ -114,5 +126,5 @@ pub fn hash_outpoints(sending_data: &HashSet<Outpoint>) -> [u8; 32] {
|
|||
engine.write_all(&v).unwrap();
|
||||
}
|
||||
|
||||
sha256::Hash::from_engine(engine).to_byte_array()
|
||||
sha256::Hash::from_engine(engine).into_inner()
|
||||
}
|
||||
|
|
|
@ -5,18 +5,21 @@ use silentpayments::receiving;
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::{collections::{HashSet, HashMap}, str::FromStr};
|
||||
use std::{
|
||||
collections::{HashMap, HashSet},
|
||||
str::FromStr,
|
||||
};
|
||||
|
||||
use secp256k1::{SecretKey, PublicKey, Scalar};
|
||||
use secp256k1::{PublicKey, Scalar, SecretKey};
|
||||
use silentpayments::sending::{decode_scan_pubkey, generate_recipient_pubkeys};
|
||||
|
||||
use crate::{
|
||||
common::{
|
||||
structs::TestData,
|
||||
utils::{
|
||||
self, decode_input_pub_keys, decode_outpoints,
|
||||
self, compute_ecdh_shared_secret, decode_input_pub_keys, decode_outpoints,
|
||||
decode_outputs_to_check, decode_priv_keys, decode_recipients,
|
||||
get_a_sum_secret_keys, hash_outpoints, compute_ecdh_shared_secret,
|
||||
get_a_sum_secret_keys, hash_outpoints,
|
||||
},
|
||||
},
|
||||
receiving::{
|
||||
|
@ -61,7 +64,8 @@ mod tests {
|
|||
let ecdh_shared_secret = compute_ecdh_shared_secret(a_sum, B_scan, outpoints_hash);
|
||||
ecdh_shared_secrets.insert(B_scan, ecdh_shared_secret);
|
||||
}
|
||||
let outputs = generate_recipient_pubkeys(silent_addresses, ecdh_shared_secrets).unwrap();
|
||||
let outputs =
|
||||
generate_recipient_pubkeys(silent_addresses, ecdh_shared_secrets).unwrap();
|
||||
|
||||
for output_pubkeys in &outputs {
|
||||
for pubkey in output_pubkeys.1 {
|
||||
|
|
Loading…
Reference in New Issue