Skip to content

Commit

Permalink
better import for libsecp256k1 (#894)
Browse files Browse the repository at this point in the history
  • Loading branch information
rockcoolsaint committed May 13, 2024
1 parent a803f1a commit 73a7850
Show file tree
Hide file tree
Showing 12 changed files with 1,218 additions and 55 deletions.
3 changes: 2 additions & 1 deletion benches/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

88 changes: 82 additions & 6 deletions common/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ repository = "https://github.com/stratum-mining/stratum"

[dependencies]
bitcoin = {version="0.29.1",optional=true}
secp256k1 = { version = "0.28.2", default-features = false, features =["alloc","rand","rand-std"] }
1 change: 1 addition & 0 deletions common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
//! and manage the shared dependencies and utils across stratum crates.
#[cfg(feature = "bitcoin")]
pub use bitcoin;
pub use secp256k1;
43 changes: 22 additions & 21 deletions protocols/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions roles/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion roles/jd-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,5 @@ serde_json = { version = "1.0", default-features = false, features = ["alloc","r
serde = { version = "1.0.89", features = ["derive", "alloc"], default-features = false }
hashbrown = { version = "0.11", default-features = false, features = ["ahash", "serde"] }
key-utils = { version = "^1.0.0", path = "../../utils/key-utils" }
secp256k1 = { version = "0.28.2", default-features = false, features =["alloc","rand","rand-std"] }
rpc_sv2 = { version = "1.0.0", path = "../roles-utils/rpc" }
hex = "0.4.3"
13 changes: 3 additions & 10 deletions roles/jd-server/src/lib/job_declarator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use async_channel::{Receiver, Sender};
use binary_sv2::{B0255, U256};
use codec_sv2::{Frame, HandshakeRole, Responder};
use error_handling::handle_result;
use key_utils::{Secp256k1PublicKey, Secp256k1SecretKey};
use key_utils::{Secp256k1PublicKey, Secp256k1SecretKey, SignatureService};
use network_helpers_sv2::noise_connection_tokio::Connection;
use nohash_hasher::BuildNoHashHasher;
use roles_logic_sv2::{
Expand All @@ -14,7 +14,6 @@ use roles_logic_sv2::{
parsers::{JobDeclaration, PoolMessages as JdsMessages},
utils::{Id, Mutex},
};
use secp256k1::{Keypair, Message as SecpMessage, Secp256k1};
use std::{collections::HashMap, convert::TryInto, sync::Arc};
use tokio::{net::TcpListener, time::Duration};
use tracing::{debug, error, info};
Expand Down Expand Up @@ -395,15 +394,9 @@ pub fn signed_token(
_pub_key: &Secp256k1PublicKey,
prv_key: &Secp256k1SecretKey,
) -> B0255<'static> {
let secp = Secp256k1::signing_only();
let secp = SignatureService::default();

// Create the SecretKey and PublicKey instances
let secret_key = prv_key.0;
let kp = Keypair::from_secret_key(&secp, &secret_key);

let message: Vec<u8> = tx_hash_list_hash.to_vec();

let signature = secp.sign_schnorr(&SecpMessage::from_digest_slice(&message).unwrap(), &kp);
let signature = secp.sign(tx_hash_list_hash.to_vec(), prv_key.0);

// Sign message
signature.as_ref().to_vec().try_into().unwrap()
Expand Down
1 change: 0 additions & 1 deletion roles/pool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ async-recursion = "1.0.0"
error_handling = { version = "1.0.0", path = "../../utils/error-handling" }
nohash-hasher = "0.2.0"
key-utils = { version = "^1.0.0", path = "../../utils/key-utils" }
secp256k1 = { version = "0.28.2", default-features = false, features =["alloc","rand","rand-std"] }

[dev-dependencies]
hex = "0.4.3"
Expand Down

0 comments on commit 73a7850

Please sign in to comment.