Skip to content

Commit 6fdd873

Browse files
committed
run cargo fmt on frost-secp256k1-tr
1 parent cee25a8 commit 6fdd873

File tree

1 file changed

+17
-33
lines changed

1 file changed

+17
-33
lines changed

frost-secp256k1-tr/src/lib.rs

+17-33
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@ use std::collections::BTreeMap;
1010
use frost_rerandomized::RandomizedCiphersuite;
1111
use k256::{
1212
elliptic_curve::{
13-
bigint::{U256},
13+
bigint::U256,
1414
group::prime::PrimeCurveAffine,
1515
hash2curve::{hash_to_field, ExpandMsgXmd},
16-
sec1::{FromEncodedPoint, ToEncodedPoint},
17-
Field as FFField, PrimeField,
18-
ScalarPrimitive,
1916
point::{AffineCoordinates, DecompactPoint},
17+
sec1::{FromEncodedPoint, ToEncodedPoint},
18+
Field as FFField, PrimeField, ScalarPrimitive,
2019
},
2120
AffinePoint, ProjectivePoint, Scalar,
2221
};
@@ -29,8 +28,9 @@ use frost_core as frost;
2928
mod tests;
3029

3130
// Re-exports in our public API
32-
pub use frost_core::{serde, Ciphersuite, Field, FieldError, Group, GroupError,
33-
Element, Challenge};
31+
pub use frost_core::{
32+
serde, Challenge, Ciphersuite, Element, Field, FieldError, Group, GroupError,
33+
};
3434

3535
pub use rand_core;
3636

@@ -190,8 +190,7 @@ pub struct Secp256K1Sha256;
190190

191191
/// Digest the hasher to a Scalar
192192
pub fn hasher_to_scalar(hasher: Sha256) -> Scalar {
193-
let sp = ScalarPrimitive::new(U256::from_be_slice(&hasher.finalize()))
194-
.unwrap();
193+
let sp = ScalarPrimitive::new(U256::from_be_slice(&hasher.finalize())).unwrap();
195194
Scalar::from(&sp)
196195
}
197196

@@ -209,7 +208,7 @@ pub fn tagged_hash(tag: &str) -> Sha256 {
209208
/// Create a BIP341 compliant taproot tweak
210209
pub fn tweak(
211210
public_key: &<<Secp256K1Sha256 as Ciphersuite>::Group as Group>::Element,
212-
merkle_root: &[u8]
211+
merkle_root: &[u8],
213212
) -> Scalar {
214213
let mut hasher = tagged_hash("TapTweak");
215214
hasher.update(public_key.to_affine().x());
@@ -305,8 +304,7 @@ impl Ciphersuite for Secp256K1Sha256 {
305304
}
306305

307306
/// Generates the challenge as is required for Schnorr signatures.
308-
fn challenge(R: &Element<S>, verifying_key: &VerifyingKey, msg: &[u8]) -> Challenge<S>
309-
{
307+
fn challenge(R: &Element<S>, verifying_key: &VerifyingKey, msg: &[u8]) -> Challenge<S> {
310308
let mut preimage = vec![];
311309
let tweaked_public_key = tweaked_public_key(&verifying_key.to_element(), &[]);
312310
preimage.extend_from_slice(&R.to_affine().x());
@@ -325,8 +323,7 @@ impl Ciphersuite for Secp256K1Sha256 {
325323
z: <<Self::Group as Group>::Field as Field>::Scalar,
326324
challenge: &Challenge<S>,
327325
verifying_key: &Element<S>,
328-
) -> <<Self::Group as Group>::Field as Field>::Scalar
329-
{
326+
) -> <<Self::Group as Group>::Field as Field>::Scalar {
330327
let t = tweak(&verifying_key, &[]);
331328
z + t * challenge.clone().to_scalar()
332329
}
@@ -339,8 +336,7 @@ impl Ciphersuite for Secp256K1Sha256 {
339336
lambda_i: <<Self::Group as Group>::Field as Field>::Scalar,
340337
key_package: &frost::keys::KeyPackage<S>,
341338
challenge: Challenge<S>,
342-
) -> round2::SignatureShare
343-
{
339+
) -> round2::SignatureShare {
344340
let mut sn = signer_nonces.clone();
345341
if group_commitment.y_is_odd() {
346342
sn.negate_nonces();
@@ -351,13 +347,7 @@ impl Ciphersuite for Secp256K1Sha256 {
351347
kp.negate_signing_share();
352348
}
353349

354-
frost::round2::compute_signature_share(
355-
&sn,
356-
binding_factor,
357-
lambda_i,
358-
&kp,
359-
challenge,
360-
)
350+
frost::round2::compute_signature_share(&sn, binding_factor, lambda_i, &kp, challenge)
361351
}
362352

363353
/// calculate tweaked public key
@@ -368,27 +358,23 @@ impl Ciphersuite for Secp256K1Sha256 {
368358
}
369359

370360
/// calculate tweaked R
371-
fn tweaked_R(
372-
R: &<Self::Group as Group>::Element,
373-
) -> <Self::Group as Group>::Element {
361+
fn tweaked_R(R: &<Self::Group as Group>::Element) -> <Self::Group as Group>::Element {
374362
AffinePoint::decompact(&R.to_affine().x()).unwrap().into()
375363
}
376364

377365
/// tweaked secret
378366
fn tweaked_secret_key(
379367
secret: <<Self::Group as Group>::Field as Field>::Scalar,
380368
public: &Element<Self>,
381-
) -> <<Self::Group as Group>::Field as Field>::Scalar
382-
{
369+
) -> <<Self::Group as Group>::Field as Field>::Scalar {
383370
tweaked_secret_key(secret, &public, &[])
384371
}
385372

386373
/// tweaked nonce
387374
fn tweaked_nonce(
388375
nonce: <<Self::Group as Group>::Field as Field>::Scalar,
389376
R: &Element<Self>,
390-
) -> <<Self::Group as Group>::Field as Field>::Scalar
391-
{
377+
) -> <<Self::Group as Group>::Field as Field>::Scalar {
392378
if R.to_affine().y_is_odd().into() {
393379
-nonce
394380
} else {
@@ -399,8 +385,7 @@ impl Ciphersuite for Secp256K1Sha256 {
399385
fn tweaked_group_commitment_share(
400386
group_commitment_share: &Element<Self>,
401387
group_commitment: &Element<Self>,
402-
) -> Element<Self>
403-
{
388+
) -> Element<Self> {
404389
if group_commitment.to_affine().y_is_odd().into() {
405390
-group_commitment_share
406391
} else {
@@ -411,8 +396,7 @@ impl Ciphersuite for Secp256K1Sha256 {
411396
fn tweaked_verifying_share(
412397
verifying_share: &<Self::Group as Group>::Element,
413398
verifying_key: &<Self::Group as Group>::Element,
414-
) -> <Self::Group as Group>::Element
415-
{
399+
) -> <Self::Group as Group>::Element {
416400
let mut vs = verifying_share.clone();
417401
if verifying_key.to_affine().y_is_odd().into() {
418402
vs = -vs;

0 commit comments

Comments
 (0)