Skip to content

Commit ec5fb69

Browse files
authored
Use curv from crates.io and bump version (#44)
* Bump curv version to 0.7 and centipede to 0.2.12 * Fix code after updating curv to 0.7 * Bump version to 0.4.4
1 parent 384d904 commit ec5fb69

File tree

6 files changed

+21
-20
lines changed

6 files changed

+21
-20
lines changed

Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "multi-party-schnorr"
3-
version = "0.4.3"
3+
version = "0.4.4"
44
authors = [
55
66
@@ -13,11 +13,11 @@ crate-type = ["lib"]
1313
[dependencies]
1414
serde = "1.0"
1515
serde_derive = "1.0"
16-
curv = { git = "https://github.com/KZen-networks/curv" , tag = "v0.5.9"}
16+
curv = { package = "curv-kzen", version = "0.7" }
1717

1818
[dependencies.centipede]
1919
git = "https://github.com/KZen-networks/centipede"
20-
tag = "v0.2.9"
20+
tag = "v0.2.12"
2121

2222
[dev-dependencies]
2323
hex = "0.3.2"

src/protocols/aggsig/musig_three_rounds.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ impl EphemeralKey {
150150
pub fn create_from_private_key(x1: &KeyPair, message: &[u8]) -> EphemeralKey {
151151
let base_point: GE = ECPoint::generator();
152152
let hash_private_key_message =
153-
HSha256::create_hash(&[&x1.private_key.to_big_int(), &BigInt::from(message)]);
153+
HSha256::create_hash(&[&x1.private_key.to_big_int(), &BigInt::from_bytes(message)]);
154154
let ephemeral_private_key: FE = ECScalar::from(&hash_private_key_message);
155155
let ephemeral_public_key = base_point.scalar_mul(&ephemeral_private_key.get_element());
156156
let (commitment, blind_factor) =
@@ -183,13 +183,13 @@ impl EphemeralKey {
183183
&BigInt::from(0),
184184
&r_hat.x_coor().unwrap(),
185185
&apk.bytes_compressed_to_big_int(),
186-
&BigInt::from(message),
186+
&BigInt::from_bytes(message),
187187
])
188188
} else {
189189
HSha256::create_hash(&[
190190
&r_hat.x_coor().unwrap(),
191191
&apk.bytes_compressed_to_big_int(),
192-
&BigInt::from(message),
192+
&BigInt::from_bytes(message),
193193
])
194194
}
195195
}
@@ -227,13 +227,13 @@ pub fn verify(
227227
&BigInt::from(0),
228228
&r_x,
229229
&apk.bytes_compressed_to_big_int(),
230-
&BigInt::from(message),
230+
&BigInt::from_bytes(message),
231231
])
232232
} else {
233233
HSha256::create_hash(&[
234234
r_x,
235235
&apk.bytes_compressed_to_big_int(),
236-
&BigInt::from(message),
236+
&BigInt::from_bytes(message),
237237
])
238238
};
239239

src/protocols/aggsig/musig_two_rounds.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ impl State {
241241
for i in 0..Nv {
242242
hnon_preimage.push(R_j_vec[i].bytes_compressed_to_big_int());
243243
}
244-
hnon_preimage.push(BigInt::from(message));
244+
hnon_preimage.push(BigInt::from_bytes(message));
245245
hnon_preimage.push(BigInt::from(j as i32));
246246
let b_j = HSha256::create_hash(&hnon_preimage.iter().collect::<Vec<_>>());
247247
b_coefficients.push(b_j);

src/protocols/multisig/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
//! Schnorr {n,n}-Signatures based on Accountable-Subgroup Multisignatures
1919
//!
2020
//See (https://pdfs.semanticscholar.org/6bf4/f9450e7a8e31c106a8670b961de4735589cf.pdf)
21+
use curv::arithmetic::Converter;
2122
use curv::elliptic::curves::traits::*;
2223
use curv::BigInt;
2324

@@ -180,7 +181,7 @@ impl EphKey {
180181
.iter()
181182
.fold(first_eph_pub_key, |acc, x| acc.add_point(&x.get_element()));
182183
//TODO: maybe there is a better way?
183-
let m_fe: FE = ECScalar::from(&BigInt::from(message));
184+
let m_fe: FE = ECScalar::from(&BigInt::from_bytes(message));
184185
let base_point: GE = GE::generator();
185186
let m_ge = base_point.scalar_mul(&m_fe.get_element());
186187
let e = multisig::hash_4(&[&sum_pub_eph, &m_ge, &sum_pub]);

src/protocols/thresholdsig/bitcoin_schnorr.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,11 @@ impl LocalSig {
188188
let message_len_bits = message.len() * 8;
189189
let R = local_ephemeral_key.y.bytes_compressed_to_big_int();
190190
let X = local_private_key.y.bytes_compressed_to_big_int();
191-
let X_vec = BigInt::to_vec(&X);
191+
let X_vec = BigInt::to_bytes(&X);
192192
let X_vec_len_bits = X_vec.len() * 8;
193193
let e_bn = HSha256::create_hash_from_slice(
194-
&BigInt::to_vec(
195-
&((((R << X_vec_len_bits) + X) << message_len_bits) + BigInt::from(message)),
194+
&BigInt::to_bytes(
195+
&((((R << X_vec_len_bits) + X) << message_len_bits) + BigInt::from_bytes(message)),
196196
)[..],
197197
);
198198

@@ -284,7 +284,7 @@ impl Signature {
284284
let e_bn = HSha256::create_hash(&[
285285
&self.v.bytes_compressed_to_big_int(),
286286
&pubkey_y.bytes_compressed_to_big_int(),
287-
&BigInt::from(message),
287+
&BigInt::from_bytes(message),
288288
]);
289289
let e: FE = ECScalar::from(&e_bn);
290290

src/protocols/thresholdsig/zilliqa_schnorr.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -221,13 +221,13 @@ impl LocalSig {
221221
/*
222222
let hash_in_concat = local_ephemaral_key.y.bytes_compressed_to_big_int()
223223
+ (local_private_key.y.bytes_compressed_to_big_int() << 264)
224-
+ (BigInt::from(message) << 528);
224+
+ (BigInt::from_bytes(message) << 528);
225225
let e_bn = HSha256::create_hash(&[&hash_in_concat]);
226226
*/
227227
let e_bn = HSha256::create_hash(&[
228228
&local_ephemaral_key.y.bytes_compressed_to_big_int(),
229229
&local_private_key.y.bytes_compressed_to_big_int(),
230-
&BigInt::from(message),
230+
&BigInt::from_bytes(message),
231231
]);
232232

233233
let e: FE = ECScalar::from(&e_bn);
@@ -322,13 +322,13 @@ impl Signature {
322322
/*
323323
let hash_in_concat = v.bytes_compressed_to_big_int()
324324
+ (Y.bytes_compressed_to_big_int() << 264)
325-
+ (BigInt::from(message) << 528);
325+
+ (BigInt::from_bytes(message) << 528);
326326
let r = HSha256::create_hash(&[&hash_in_concat]);
327327
*/
328328
let r = HSha256::create_hash(&[
329329
&v.bytes_compressed_to_big_int(),
330330
&Y.bytes_compressed_to_big_int(),
331-
&BigInt::from(message),
331+
&BigInt::from_bytes(message),
332332
]);
333333

334334
Signature {
@@ -345,14 +345,14 @@ impl Signature {
345345
/*
346346
let hash_in_concat = sg_plus_ey.bytes_compressed_to_big_int()
347347
+ (pubkey_y.bytes_compressed_to_big_int() << 264)
348-
+ (BigInt::from(message) << 528);
348+
+ (BigInt::from_bytes(message) << 528);
349349
let r = HSha256::create_hash(&[&hash_in_concat]);
350350
*/
351351

352352
let r = HSha256::create_hash(&[
353353
&sg_plus_ey.bytes_compressed_to_big_int(),
354354
&pubkey_y.bytes_compressed_to_big_int(),
355-
&BigInt::from(message),
355+
&BigInt::from_bytes(message),
356356
]);
357357
let r: FE = ECScalar::from(&r);
358358

0 commit comments

Comments
 (0)