Skip to content

Commit 6e85d67

Browse files
committed
Rename tweak to tweak32 in public API
1 parent f587f04 commit 6e85d67

File tree

2 files changed

+30
-30
lines changed

2 files changed

+30
-30
lines changed

include/secp256k1.h

+10-10
Original file line numberDiff line numberDiff line change
@@ -633,23 +633,23 @@ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_negate(
633633
* invalid according to secp256k1_ec_seckey_verify, this
634634
* function returns 0. seckey will be set to some unspecified
635635
* value if this function returns 0. (cannot be NULL)
636-
* In: tweak: pointer to a 32-byte tweak. If the tweak is invalid according to
636+
* In: tweak32: pointer to a 32-byte tweak. If the tweak is invalid according to
637637
* secp256k1_ec_seckey_verify, this function returns 0. For
638638
* uniformly random 32-byte arrays the chance of being invalid
639639
* is negligible (around 1 in 2^128) (cannot be NULL).
640640
*/
641641
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_seckey_tweak_add(
642642
const secp256k1_context* ctx,
643643
unsigned char *seckey,
644-
const unsigned char *tweak
644+
const unsigned char *tweak32
645645
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3);
646646

647647
/** Same as secp256k1_ec_seckey_tweak_add, but DEPRECATED. Will be removed in
648648
* future versions. */
649649
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_privkey_tweak_add(
650650
const secp256k1_context* ctx,
651651
unsigned char *seckey,
652-
const unsigned char *tweak
652+
const unsigned char *tweak32
653653
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3);
654654

655655
/** Tweak a public key by adding tweak times the generator to it.
@@ -661,15 +661,15 @@ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_privkey_tweak_add(
661661
* (cannot be NULL).
662662
* In/Out: pubkey: pointer to a public key object. pubkey will be set to an
663663
* invalid value if this function returns 0 (cannot be NULL).
664-
* In: tweak: pointer to a 32-byte tweak. If the tweak is invalid according to
664+
* In: tweak32: pointer to a 32-byte tweak. If the tweak is invalid according to
665665
* secp256k1_ec_seckey_verify, this function returns 0. For
666666
* uniformly random 32-byte arrays the chance of being invalid
667667
* is negligible (around 1 in 2^128) (cannot be NULL).
668668
*/
669669
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_tweak_add(
670670
const secp256k1_context* ctx,
671671
secp256k1_pubkey *pubkey,
672-
const unsigned char *tweak
672+
const unsigned char *tweak32
673673
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3);
674674

675675
/** Tweak a secret key by multiplying it by a tweak.
@@ -680,23 +680,23 @@ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_tweak_add(
680680
* invalid according to secp256k1_ec_seckey_verify, this
681681
* function returns 0. seckey will be set to some unspecified
682682
* value if this function returns 0. (cannot be NULL)
683-
* In: tweak: pointer to a 32-byte tweak. If the tweak is invalid according to
683+
* In: tweak32: pointer to a 32-byte tweak. If the tweak is invalid according to
684684
* secp256k1_ec_seckey_verify, this function returns 0. For
685685
* uniformly random 32-byte arrays the chance of being invalid
686686
* is negligible (around 1 in 2^128) (cannot be NULL).
687687
*/
688688
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_seckey_tweak_mul(
689689
const secp256k1_context* ctx,
690690
unsigned char *seckey,
691-
const unsigned char *tweak
691+
const unsigned char *tweak32
692692
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3);
693693

694694
/** Same as secp256k1_ec_seckey_tweak_mul, but DEPRECATED. Will be removed in
695695
* future versions. */
696696
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_privkey_tweak_mul(
697697
const secp256k1_context* ctx,
698698
unsigned char *seckey,
699-
const unsigned char *tweak
699+
const unsigned char *tweak32
700700
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3);
701701

702702
/** Tweak a public key by multiplying it by a tweak value.
@@ -706,15 +706,15 @@ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_privkey_tweak_mul(
706706
* (cannot be NULL).
707707
* In/Out: pubkey: pointer to a public key object. pubkey will be set to an
708708
* invalid value if this function returns 0 (cannot be NULL).
709-
* In: tweak: pointer to a 32-byte tweak. If the tweak is invalid according to
709+
* In: tweak32: pointer to a 32-byte tweak. If the tweak is invalid according to
710710
* secp256k1_ec_seckey_verify, this function returns 0. For
711711
* uniformly random 32-byte arrays the chance of being invalid
712712
* is negligible (around 1 in 2^128) (cannot be NULL).
713713
*/
714714
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_tweak_mul(
715715
const secp256k1_context* ctx,
716716
secp256k1_pubkey *pubkey,
717-
const unsigned char *tweak
717+
const unsigned char *tweak32
718718
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3);
719719

720720
/** Updates the context randomization to protect against side-channel leakage.

src/secp256k1.c

+20-20
Original file line numberDiff line numberDiff line change
@@ -623,72 +623,72 @@ int secp256k1_ec_pubkey_negate(const secp256k1_context* ctx, secp256k1_pubkey *p
623623
}
624624

625625

626-
static int secp256k1_ec_seckey_tweak_add_helper(secp256k1_scalar *sec, const unsigned char *tweak) {
626+
static int secp256k1_ec_seckey_tweak_add_helper(secp256k1_scalar *sec, const unsigned char *tweak32) {
627627
secp256k1_scalar term;
628628
int overflow = 0;
629629
int ret = 0;
630630

631-
secp256k1_scalar_set_b32(&term, tweak, &overflow);
631+
secp256k1_scalar_set_b32(&term, tweak32, &overflow);
632632
ret = (!overflow) & secp256k1_eckey_privkey_tweak_add(sec, &term);
633633
secp256k1_scalar_clear(&term);
634634
return ret;
635635
}
636636

637-
int secp256k1_ec_seckey_tweak_add(const secp256k1_context* ctx, unsigned char *seckey, const unsigned char *tweak) {
637+
int secp256k1_ec_seckey_tweak_add(const secp256k1_context* ctx, unsigned char *seckey, const unsigned char *tweak32) {
638638
secp256k1_scalar sec;
639639
int ret = 0;
640640
VERIFY_CHECK(ctx != NULL);
641641
ARG_CHECK(seckey != NULL);
642-
ARG_CHECK(tweak != NULL);
642+
ARG_CHECK(tweak32 != NULL);
643643

644644
ret = secp256k1_scalar_set_b32_seckey(&sec, seckey);
645-
ret &= secp256k1_ec_seckey_tweak_add_helper(&sec, tweak);
645+
ret &= secp256k1_ec_seckey_tweak_add_helper(&sec, tweak32);
646646
secp256k1_scalar_cmov(&sec, &secp256k1_scalar_zero, !ret);
647647
secp256k1_scalar_get_b32(seckey, &sec);
648648

649649
secp256k1_scalar_clear(&sec);
650650
return ret;
651651
}
652652

653-
int secp256k1_ec_privkey_tweak_add(const secp256k1_context* ctx, unsigned char *seckey, const unsigned char *tweak) {
654-
return secp256k1_ec_seckey_tweak_add(ctx, seckey, tweak);
653+
int secp256k1_ec_privkey_tweak_add(const secp256k1_context* ctx, unsigned char *seckey, const unsigned char *tweak32) {
654+
return secp256k1_ec_seckey_tweak_add(ctx, seckey, tweak32);
655655
}
656656

657-
static int secp256k1_ec_pubkey_tweak_add_helper(const secp256k1_ecmult_context* ecmult_ctx, secp256k1_ge *p, const unsigned char *tweak) {
657+
static int secp256k1_ec_pubkey_tweak_add_helper(const secp256k1_ecmult_context* ecmult_ctx, secp256k1_ge *p, const unsigned char *tweak32) {
658658
secp256k1_scalar term;
659659
int overflow = 0;
660-
secp256k1_scalar_set_b32(&term, tweak, &overflow);
660+
secp256k1_scalar_set_b32(&term, tweak32, &overflow);
661661
return !overflow && secp256k1_eckey_pubkey_tweak_add(ecmult_ctx, p, &term);
662662
}
663663

664-
int secp256k1_ec_pubkey_tweak_add(const secp256k1_context* ctx, secp256k1_pubkey *pubkey, const unsigned char *tweak) {
664+
int secp256k1_ec_pubkey_tweak_add(const secp256k1_context* ctx, secp256k1_pubkey *pubkey, const unsigned char *tweak32) {
665665
secp256k1_ge p;
666666
int ret = 0;
667667
VERIFY_CHECK(ctx != NULL);
668668
ARG_CHECK(secp256k1_ecmult_context_is_built(&ctx->ecmult_ctx));
669669
ARG_CHECK(pubkey != NULL);
670-
ARG_CHECK(tweak != NULL);
670+
ARG_CHECK(tweak32 != NULL);
671671

672672
ret = secp256k1_pubkey_load(ctx, &p, pubkey);
673673
memset(pubkey, 0, sizeof(*pubkey));
674-
ret = ret && secp256k1_ec_pubkey_tweak_add_helper(&ctx->ecmult_ctx, &p, tweak);
674+
ret = ret && secp256k1_ec_pubkey_tweak_add_helper(&ctx->ecmult_ctx, &p, tweak32);
675675
if (ret) {
676676
secp256k1_pubkey_save(pubkey, &p);
677677
}
678678

679679
return ret;
680680
}
681681

682-
int secp256k1_ec_seckey_tweak_mul(const secp256k1_context* ctx, unsigned char *seckey, const unsigned char *tweak) {
682+
int secp256k1_ec_seckey_tweak_mul(const secp256k1_context* ctx, unsigned char *seckey, const unsigned char *tweak32) {
683683
secp256k1_scalar factor;
684684
secp256k1_scalar sec;
685685
int ret = 0;
686686
int overflow = 0;
687687
VERIFY_CHECK(ctx != NULL);
688688
ARG_CHECK(seckey != NULL);
689-
ARG_CHECK(tweak != NULL);
689+
ARG_CHECK(tweak32 != NULL);
690690

691-
secp256k1_scalar_set_b32(&factor, tweak, &overflow);
691+
secp256k1_scalar_set_b32(&factor, tweak32, &overflow);
692692
ret = secp256k1_scalar_set_b32_seckey(&sec, seckey);
693693
ret &= (!overflow) & secp256k1_eckey_privkey_tweak_mul(&sec, &factor);
694694
secp256k1_scalar_cmov(&sec, &secp256k1_scalar_zero, !ret);
@@ -699,21 +699,21 @@ int secp256k1_ec_seckey_tweak_mul(const secp256k1_context* ctx, unsigned char *s
699699
return ret;
700700
}
701701

702-
int secp256k1_ec_privkey_tweak_mul(const secp256k1_context* ctx, unsigned char *seckey, const unsigned char *tweak) {
703-
return secp256k1_ec_seckey_tweak_mul(ctx, seckey, tweak);
702+
int secp256k1_ec_privkey_tweak_mul(const secp256k1_context* ctx, unsigned char *seckey, const unsigned char *tweak32) {
703+
return secp256k1_ec_seckey_tweak_mul(ctx, seckey, tweak32);
704704
}
705705

706-
int secp256k1_ec_pubkey_tweak_mul(const secp256k1_context* ctx, secp256k1_pubkey *pubkey, const unsigned char *tweak) {
706+
int secp256k1_ec_pubkey_tweak_mul(const secp256k1_context* ctx, secp256k1_pubkey *pubkey, const unsigned char *tweak32) {
707707
secp256k1_ge p;
708708
secp256k1_scalar factor;
709709
int ret = 0;
710710
int overflow = 0;
711711
VERIFY_CHECK(ctx != NULL);
712712
ARG_CHECK(secp256k1_ecmult_context_is_built(&ctx->ecmult_ctx));
713713
ARG_CHECK(pubkey != NULL);
714-
ARG_CHECK(tweak != NULL);
714+
ARG_CHECK(tweak32 != NULL);
715715

716-
secp256k1_scalar_set_b32(&factor, tweak, &overflow);
716+
secp256k1_scalar_set_b32(&factor, tweak32, &overflow);
717717
ret = !overflow && secp256k1_pubkey_load(ctx, &p, pubkey);
718718
memset(pubkey, 0, sizeof(*pubkey));
719719
if (ret) {

0 commit comments

Comments
 (0)