Skip to content

Commit ab60096

Browse files
committed
give more consistent names to taproot functions
1 parent d0145d9 commit ab60096

File tree

7 files changed

+42
-40
lines changed

7 files changed

+42
-40
lines changed

frost-core/src/batch.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ where
120120
let z = item.sig.z;
121121
let mut R = item.sig.R;
122122
let mut vk = item.vk.element;
123-
if <C>::is_need_tweaking() {
124-
R = <C>::tweaked_R(&item.sig.R);
123+
if <C>::is_taproot_compat() {
124+
R = <C>::taproot_compat_R(&item.sig.R);
125125
vk = <C>::tweaked_public_key(&item.vk.element);
126126
}
127127

frost-core/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ where
588588
z = z + signature_share.share;
589589
}
590590

591-
if <C>::is_need_tweaking() {
591+
if <C>::is_taproot_compat() {
592592
let challenge = <C>::challenge(
593593
&group_commitment.0,
594594
&pubkeys.verifying_key,

frost-core/src/round2.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,12 @@ where
9595
) -> Result<(), Error<C>> {
9696
let mut commitment_share = group_commitment_share.0;
9797
let mut vsh = verifying_share.0;
98-
if <C>::is_need_tweaking() {
99-
commitment_share = <C>::tweaked_group_commitment_share(
98+
if <C>::is_taproot_compat() {
99+
commitment_share = <C>::taproot_compat_commitment_share(
100100
&group_commitment_share.0,
101101
&group_commitment.0
102102
);
103-
vsh = <C>::tweaked_verifying_share(
103+
vsh = <C>::taproot_compat_verifying_share(
104104
&verifying_share.0,
105105
&verifying_key.element
106106
);
@@ -233,8 +233,8 @@ pub fn sign<C: Ciphersuite>(
233233
);
234234

235235
// Compute the Schnorr signature share.
236-
if <C>::is_need_tweaking() {
237-
let signature_share = <C>::compute_tweaked_signature_share(
236+
if <C>::is_taproot_compat() {
237+
let signature_share = <C>::compute_taproot_compat_signature_share(
238238
signer_nonces,
239239
binding_factor,
240240
group_commitment,

frost-core/src/signing_key.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,19 @@ where
4747
pub fn sign<R: RngCore + CryptoRng>(&self, mut rng: R, msg: &[u8]) -> Signature<C> {
4848
let public = VerifyingKey::<C>::from(*self);
4949
let mut secret = self.scalar;
50-
if <C>::is_need_tweaking() {
50+
if <C>::is_taproot_compat() {
5151
secret = <C>::tweaked_secret_key(secret, &public.element);
5252
}
5353
let mut k = random_nonzero::<C, R>(&mut rng);
5454
let R = <C::Group>::generator() * k;
55-
if <C>::is_need_tweaking() {
56-
k = <C>::tweaked_nonce(k, &R);
55+
if <C>::is_taproot_compat() {
56+
k = <C>::taproot_compat_nonce(k, &R);
5757
}
5858

5959
// Generate Schnorr challenge
6060
let c: Challenge<C> = <C>::challenge(&R, &public, msg);
6161

62-
if <C>::is_need_tweaking() {
62+
if <C>::is_taproot_compat() {
6363
let z = <C>::tweaked_z(k, secret, c.0, &public.element);
6464
Signature { R, z }
6565
} else {

frost-core/src/traits.rs

+16-16
Original file line numberDiff line numberDiff line change
@@ -256,12 +256,12 @@ pub trait Ciphersuite: Copy + Clone + PartialEq + Debug {
256256
challenge(R, verifying_key, msg)
257257
}
258258

259-
/// determine tweak is need
260-
fn is_need_tweaking() -> bool {
259+
/// determine code is taproot compatible (used in frost-sepc256k1-tr)
260+
fn is_taproot_compat() -> bool {
261261
false
262262
}
263263

264-
/// aggregate tweak z
264+
/// aggregate tweak z (used in frost-sepc256k1-tr)
265265
#[allow(unused)]
266266
fn aggregate_tweak_z(
267267
z: <<Self::Group as Group>::Field as Field>::Scalar,
@@ -272,7 +272,7 @@ pub trait Ciphersuite: Copy + Clone + PartialEq + Debug {
272272
panic!("Not implemented");
273273
}
274274

275-
/// tweaked z for SigningKey sign
275+
/// tweaked z for SigningKey sign (used in frost-sepc256k1-tr)
276276
#[allow(unused)]
277277
fn tweaked_z(
278278
k: <<Self::Group as Group>::Field as Field>::Scalar,
@@ -284,9 +284,9 @@ pub trait Ciphersuite: Copy + Clone + PartialEq + Debug {
284284
panic!("Not implemented");
285285
}
286286

287-
/// signature_share tweak
287+
/// signature_share compatible with taproot (used in frost-sepc256k1-tr)
288288
#[allow(unused)]
289-
fn compute_tweaked_signature_share(
289+
fn compute_taproot_compat_signature_share(
290290
signer_nonces: &crate::round1::SigningNonces<Self>,
291291
binding_factor: crate::BindingFactor<Self>,
292292
group_commitment: crate::GroupCommitment<Self>,
@@ -298,23 +298,23 @@ pub trait Ciphersuite: Copy + Clone + PartialEq + Debug {
298298
panic!("Not implemented");
299299
}
300300

301-
/// calculate tweaked public key
301+
/// calculate tweaked public key (used in frost-sepc256k1-tr)
302302
#[allow(unused)]
303303
fn tweaked_public_key(
304304
public_key: &<Self::Group as Group>::Element,
305305
) -> <Self::Group as Group>::Element {
306306
panic!("Not implemented");
307307
}
308308

309-
/// calculate tweaked R
309+
/// calculate taproot compatible R (used in frost-sepc256k1-tr)
310310
#[allow(unused)]
311-
fn tweaked_R(
311+
fn taproot_compat_R(
312312
public_key: &<Self::Group as Group>::Element,
313313
) -> <Self::Group as Group>::Element {
314314
panic!("Not implemented");
315315
}
316316

317-
/// tweaked secret
317+
/// tweaked secret (used in frost-sepc256k1-tr)
318318
#[allow(unused)]
319319
fn tweaked_secret_key(
320320
secret: <<Self::Group as Group>::Field as Field>::Scalar,
@@ -324,29 +324,29 @@ pub trait Ciphersuite: Copy + Clone + PartialEq + Debug {
324324
panic!("Not implemented");
325325
}
326326

327-
/// tweaked nonce
327+
/// calculate taproot compatible nonce (used in frost-sepc256k1-tr)
328328
#[allow(unused)]
329-
fn tweaked_nonce(
329+
fn taproot_compat_nonce(
330330
nonce: <<Self::Group as Group>::Field as Field>::Scalar,
331331
R: &Element<Self>,
332332
) -> <<Self::Group as Group>::Field as Field>::Scalar
333333
{
334334
panic!("Not implemented");
335335
}
336336

337-
/// tweaked group commitment
337+
/// calculate taproot compatible commitment share (used in frost-sepc256k1-tr)
338338
#[allow(unused)]
339-
fn tweaked_group_commitment_share(
339+
fn taproot_compat_commitment_share(
340340
group_commitment_share: &<Self::Group as Group>::Element,
341341
group_commitment: &<Self::Group as Group>::Element,
342342
) -> <Self::Group as Group>::Element
343343
{
344344
panic!("Not implemented");
345345
}
346346

347-
/// tweaked verifying share
347+
/// calculate taproot compatible verifying share (used in frost-sepc256k1-tr)
348348
#[allow(unused)]
349-
fn tweaked_verifying_share(
349+
fn taproot_compat_verifying_share(
350350
verifying_share: &<Self::Group as Group>::Element,
351351
verifying_key: &<Self::Group as Group>::Element,
352352
) -> <Self::Group as Group>::Element

frost-core/src/verifying_key.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ where
7070
// where h is the cofactor
7171
let mut R = signature.R;
7272
let mut vk = self.element;
73-
if <C>::is_need_tweaking() {
74-
R = <C>::tweaked_R(&signature.R);
73+
if <C>::is_taproot_compat() {
74+
R = <C>::taproot_compat_R(&signature.R);
7575
vk = <C>::tweaked_public_key(&self.element);
7676
}
7777
let zB = C::Group::generator() * signature.z;

frost-secp256k1-tr/src/lib.rs

+12-10
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,8 @@ impl Ciphersuite for Secp256K1Sha256 {
324324
Challenge::from_scalar(S::H2(&preimage[..]))
325325
}
326326

327-
/// determine tweak is need
328-
fn is_need_tweaking() -> bool {
327+
/// determine code is taproot compatible
328+
fn is_taproot_compat() -> bool {
329329
true
330330
}
331331

@@ -360,8 +360,8 @@ impl Ciphersuite for Secp256K1Sha256 {
360360
}
361361
}
362362

363-
/// compute tweaked signature_share
364-
fn compute_tweaked_signature_share(
363+
/// signature_share compatible with taproot
364+
fn compute_taproot_compat_signature_share(
365365
signer_nonces: &round1::SigningNonces,
366366
binding_factor: frost::BindingFactor<S>,
367367
group_commitment: frost_core::GroupCommitment<S>,
@@ -395,8 +395,8 @@ impl Ciphersuite for Secp256K1Sha256 {
395395
real_tweaked_pubkey(public_key, &[])
396396
}
397397

398-
/// calculate tweaked R
399-
fn tweaked_R(R: &<Self::Group as Group>::Element) -> <Self::Group as Group>::Element {
398+
/// calculate taproot compatible R
399+
fn taproot_compat_R(R: &<Self::Group as Group>::Element) -> <Self::Group as Group>::Element {
400400
AffinePoint::decompact(&R.to_affine().x()).unwrap().into()
401401
}
402402

@@ -408,8 +408,8 @@ impl Ciphersuite for Secp256K1Sha256 {
408408
tweaked_secret_key(secret, &public, &[])
409409
}
410410

411-
/// tweaked nonce
412-
fn tweaked_nonce(
411+
/// calculate taproot compatible nonce
412+
fn taproot_compat_nonce(
413413
nonce: <<Self::Group as Group>::Field as Field>::Scalar,
414414
R: &Element<Self>,
415415
) -> <<Self::Group as Group>::Field as Field>::Scalar {
@@ -420,7 +420,8 @@ impl Ciphersuite for Secp256K1Sha256 {
420420
}
421421
}
422422

423-
fn tweaked_group_commitment_share(
423+
/// calculate taproot compatible commitment share
424+
fn taproot_compat_commitment_share(
424425
group_commitment_share: &Element<Self>,
425426
group_commitment: &Element<Self>,
426427
) -> Element<Self> {
@@ -431,7 +432,8 @@ impl Ciphersuite for Secp256K1Sha256 {
431432
}
432433
}
433434

434-
fn tweaked_verifying_share(
435+
/// calculate taproot compatible verifying share
436+
fn taproot_compat_verifying_share(
435437
verifying_share: &<Self::Group as Group>::Element,
436438
verifying_key: &<Self::Group as Group>::Element,
437439
) -> <Self::Group as Group>::Element {

0 commit comments

Comments
 (0)