Skip to content

Commit

Permalink
Prettify code
Browse files Browse the repository at this point in the history
Signed-off-by: Denis Varlakov <[email protected]>
  • Loading branch information
survived committed Jul 24, 2024
1 parent 5a645bb commit dafad7e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
20 changes: 10 additions & 10 deletions givre/src/signing/aggregate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,23 +245,23 @@ fn aggregate_inner<C: Ciphersuite>(
*pk
};

// Taproot: Normalize the public key
// Taproot: Normalize the public key. Note that for non-taproot ciphersuites we still
// need PK to be normalized as functions below accept normalized PK. However, for
// non-taproot ciphersuites, normalization is an identity function
let pk = C::normalize_point(pk);

#[cfg(feature = "taproot")]
let pk = {
let pk = if C::IS_TAPROOT {
// Taproot: tweak the key share
let pk = if C::IS_TAPROOT {
let t = crate::signing::taproot::tweak::<C>(pk, taproot_merkle_root)
.ok_or(Reason::TaprootTweakUndefined)?;
let pk = *pk + Point::generator() * t;
NonZero::from_point(pk).ok_or(Reason::TaprootChildPkZero)?
} else {
*pk
};
let t = crate::signing::taproot::tweak::<C>(pk, taproot_merkle_root)
.ok_or(Reason::TaprootTweakUndefined)?;
let pk = *pk + Point::generator() * t;
let pk = NonZero::from_point(pk).ok_or(Reason::TaprootChildPkZero)?;

// Taproot: Normalize the public key again after taproot tweak
C::normalize_point(pk)
} else {
pk
};

let mut comm_list = signers
Expand Down
20 changes: 10 additions & 10 deletions givre/src/signing/round2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,23 +214,23 @@ fn sign_inner<C: Ciphersuite>(
(Cow::Borrowed(x), *pk)
};

// Taproot: Normalize the key share
// Taproot: Normalize the key share. Note that for non-taproot ciphersuites we still
// need key share to be normalized as functions below accept normalized PK. However, for
// non-taproot ciphersuites, normalization is an identity function
let (x, pk) = normalize_key_share(x, pk);

#[cfg(feature = "taproot")]
let (x, pk) = {
let (x, pk) = if C::IS_TAPROOT {
// Taproot: tweak the key share
let (x, pk) = if C::IS_TAPROOT {
let t = crate::signing::taproot::tweak::<C>(pk, taproot_merkle_root)
.ok_or(Reason::TaprootTweakUndefined)?;

apply_additive_shift(*i, vss_setup, x, *pk, t).map_err(Reason::TaprootShift)?
} else {
(x, *pk)
};
let t = crate::signing::taproot::tweak::<C>(pk, taproot_merkle_root)
.ok_or(Reason::TaprootTweakUndefined)?;
let (x, pk) =
apply_additive_shift(*i, vss_setup, x, *pk, t).map_err(Reason::TaprootShift)?;

// Taproot: Normalize the key share again after tweaking...
normalize_key_share(x, pk)
} else {
(x, pk)
};

if signers.len() < usize::from(t) {
Expand Down

0 comments on commit dafad7e

Please sign in to comment.