Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add frost-secp256k1-tr crate (BIP340/BIP341) [moved] #730

Merged
merged 14 commits into from
Nov 14, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 11 additions & 15 deletions frost-secp256k1-tr/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -518,10 +518,10 @@ impl Ciphersuite for Secp256K1Sha256TR {
// > key should commit to an unspendable script path instead of having
// > no script path. This can be achieved by computing the output key
// > point as Q = P + int(hashTapTweak(bytes(P)))G.
let merkle_root = key_package.verifying_key().to_element().to_affine().x();
let merkle_root = [0u8; 0];
Ok((
key_package.tweak(Some(merkle_root)),
public_key_package.tweak(Some(merkle_root)),
key_package.tweak(Some(&merkle_root)),
public_key_package.tweak(Some(&merkle_root)),
))
}
}
Expand Down Expand Up @@ -749,7 +749,7 @@ pub mod keys {
}

/// Trait for tweaking a key component following BIP-341
pub trait Tweak: EvenY {
pub trait Tweak {
/// Convert the given type to add a tweak.
fn tweak<T: AsRef<[u8]>>(self, merkle_root: Option<T>) -> Self;
}
Expand All @@ -758,12 +758,10 @@ pub mod keys {
fn tweak<T: AsRef<[u8]>>(self, merkle_root: Option<T>) -> Self {
let t = tweak(&self.verifying_key().to_element(), merkle_root);
let tp = ProjectivePoint::GENERATOR * t;
let public_key_package = self.into_even_y(None);
let verifying_key =
VerifyingKey::new(public_key_package.verifying_key().to_element() + tp);
let verifying_key = VerifyingKey::new(self.verifying_key().to_element() + tp);
conradoplg marked this conversation as resolved.
Show resolved Hide resolved
// Recreate verifying share map with negated VerifyingShares
// values.
let verifying_shares: BTreeMap<_, _> = public_key_package
let verifying_shares: BTreeMap<_, _> = self
.verifying_shares()
.iter()
.map(|(i, vs)| {
Expand All @@ -779,17 +777,15 @@ pub mod keys {
fn tweak<T: AsRef<[u8]>>(self, merkle_root: Option<T>) -> Self {
let t = tweak(&self.verifying_key().to_element(), merkle_root);
let tp = ProjectivePoint::GENERATOR * t;
let key_package = self.into_even_y(None);
let verifying_key = VerifyingKey::new(key_package.verifying_key().to_element() + tp);
let signing_share = SigningShare::new(key_package.signing_share().to_scalar() + t);
let verifying_share =
VerifyingShare::new(key_package.verifying_share().to_element() + tp);
let verifying_key = VerifyingKey::new(self.verifying_key().to_element() + tp);
let signing_share = SigningShare::new(self.signing_share().to_scalar() + t);
let verifying_share = VerifyingShare::new(self.verifying_share().to_element() + tp);
KeyPackage::new(
*key_package.identifier(),
*self.identifier(),
signing_share,
verifying_share,
verifying_key,
*key_package.min_signers(),
*self.min_signers(),
)
}
}
Expand Down