Skip to content

Commit

Permalink
handle message start with 0
Browse files Browse the repository at this point in the history
  • Loading branch information
ZenGo authored and ZenGo committed Feb 10, 2020
1 parent 3a4bf00 commit 8a3e0a1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "multi-party-schnorr"
version = "0.3.2"
version = "0.3.3"
authors = [
"Omer <[email protected]>",
"Gary <[email protected]>"
Expand All @@ -12,11 +12,11 @@ crate-type = ["lib"]
[dependencies]
serde = "1.0"
serde_derive = "1.0"
curv = { git = "https://github.com/KZen-networks/curv" , tag = "v0.2.3", features = ["ec_secp256k1","merkle"]}
curv = { git = "https://github.com/KZen-networks/curv" , tag = "v0.2.4", features = ["ec_secp256k1","merkle"]}

[dependencies.centipede]
git = "https://github.com/KZen-networks/centipede"
tag = "v0.2.2"
tag = "v0.2.3"

[dev-dependencies]
hex = "0.3.2"
Expand Down
21 changes: 13 additions & 8 deletions src/protocols/thresholdsig/bitcoin_schnorr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,20 +176,25 @@ pub struct LocalSig {
impl LocalSig {
pub fn compute(
message: &[u8],
local_ephemaral_key: &SharedKeys,
local_ephemeral_key: &SharedKeys,
local_private_key: &SharedKeys,
) -> LocalSig {
let beta_i = local_ephemaral_key.x_i.clone();
let beta_i = local_ephemeral_key.x_i.clone();
let alpha_i = local_private_key.x_i.clone();

let e_bn = HSha256::create_hash(&[
&local_ephemaral_key.y.bytes_compressed_to_big_int(),
&local_private_key.y.bytes_compressed_to_big_int(),
&BigInt::from(message),
]);
let message_len_bits = message.len() * 8;
let R = local_ephemeral_key.y.bytes_compressed_to_big_int();
let X = local_private_key.y.bytes_compressed_to_big_int();
let X_vec = BigInt::to_vec(&X);
let X_vec_len_bits = X_vec.len() * 8;
let e_bn = HSha256::create_hash_from_slice(
&BigInt::to_vec(
&((((R << X_vec_len_bits) + X) << message_len_bits) + BigInt::from(message)),
)[..],
);

let e: FE = ECScalar::from(&e_bn);
let gamma_i = beta_i + e.clone() * alpha_i;
// let gamma_i = e.clone() * alpha_i ;

LocalSig { gamma_i, e }
}
Expand Down

0 comments on commit 8a3e0a1

Please sign in to comment.