Skip to content

Commit 30cad09

Browse files
authored
fix multiple definition link errors (#182)
1 parent 3d2a62c commit 30cad09

37 files changed

+631
-631
lines changed

go-ethereum/crypto/secp256k1/ext.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
// Use of this source code is governed by a BSD-style license that can be found in
33
// the LICENSE file.
44

5-
// secp256k1_context_create_sign_verify creates a context for signing and signature verification.
6-
static secp256k1_context* secp256k1_context_create_sign_verify() {
7-
return secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY);
5+
// ethkit_secp256k1_context_create_sign_verify creates a context for signing and signature verification.
6+
static secp256k1_context* ethkit_secp256k1_context_create_sign_verify() {
7+
return ethkit_secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY);
88
}
99

1010
// secp256k1_ext_ecdsa_recover recovers the public key of an encoded compact signature.
@@ -21,17 +21,17 @@ static int secp256k1_ext_ecdsa_recover(
2121
const unsigned char *sigdata,
2222
const unsigned char *msgdata
2323
) {
24-
secp256k1_ecdsa_recoverable_signature sig;
24+
ethkit_secp256k1_ecdsa_recoverable_signature sig;
2525
secp256k1_pubkey pubkey;
2626

27-
if (!secp256k1_ecdsa_recoverable_signature_parse_compact(ctx, &sig, sigdata, (int)sigdata[64])) {
27+
if (!ethkit_ethkit_secp256k1_ecdsa_recoverable_signature_parse_compact(ctx, &sig, sigdata, (int)sigdata[64])) {
2828
return 0;
2929
}
30-
if (!secp256k1_ecdsa_recover(ctx, &pubkey, &sig, msgdata)) {
30+
if (!ethkit_secp256k1_ecdsa_recover(ctx, &pubkey, &sig, msgdata)) {
3131
return 0;
3232
}
3333
size_t outputlen = 65;
34-
return secp256k1_ec_pubkey_serialize(ctx, pubkey_out, &outputlen, &pubkey, SECP256K1_EC_UNCOMPRESSED);
34+
return ethkit_secp256k1_ec_pubkey_serialize(ctx, pubkey_out, &outputlen, &pubkey, SECP256K1_EC_UNCOMPRESSED);
3535
}
3636

3737
// secp256k1_ext_ecdsa_verify verifies an encoded compact signature.
@@ -50,16 +50,16 @@ static int secp256k1_ext_ecdsa_verify(
5050
const unsigned char *pubkeydata,
5151
size_t pubkeylen
5252
) {
53-
secp256k1_ecdsa_signature sig;
53+
ethkit_secp256k1_ecdsa_signature sig;
5454
secp256k1_pubkey pubkey;
5555

56-
if (!secp256k1_ecdsa_signature_parse_compact(ctx, &sig, sigdata)) {
56+
if (!ethkit_ethkit_secp256k1_ecdsa_signature_parse_compact(ctx, &sig, sigdata)) {
5757
return 0;
5858
}
59-
if (!secp256k1_ec_pubkey_parse(ctx, &pubkey, pubkeydata, pubkeylen)) {
59+
if (!ethkit_secp256k1_ec_pubkey_parse(ctx, &pubkey, pubkeydata, pubkeylen)) {
6060
return 0;
6161
}
62-
return secp256k1_ecdsa_verify(ctx, &sig, msgdata, &pubkey);
62+
return ethkit_secp256k1_ecdsa_verify(ctx, &sig, msgdata, &pubkey);
6363
}
6464

6565
// secp256k1_ext_reencode_pubkey decodes then encodes a public key. It can be used to
@@ -82,14 +82,14 @@ static int secp256k1_ext_reencode_pubkey(
8282
) {
8383
secp256k1_pubkey pubkey;
8484

85-
if (!secp256k1_ec_pubkey_parse(ctx, &pubkey, pubkeydata, pubkeylen)) {
85+
if (!ethkit_secp256k1_ec_pubkey_parse(ctx, &pubkey, pubkeydata, pubkeylen)) {
8686
return 0;
8787
}
8888
unsigned int flag = (outlen == 33) ? SECP256K1_EC_COMPRESSED : SECP256K1_EC_UNCOMPRESSED;
89-
return secp256k1_ec_pubkey_serialize(ctx, out, &outlen, &pubkey, flag);
89+
return ethkit_secp256k1_ec_pubkey_serialize(ctx, out, &outlen, &pubkey, flag);
9090
}
9191

92-
// secp256k1_ext_scalar_mul multiplies a point by a scalar in constant time.
92+
// ethkit_secp256k1_ext_scalar_mul multiplies a point by a scalar in constant time.
9393
//
9494
// Returns: 1: multiplication was successful
9595
// 0: scalar was invalid (zero or overflow)
@@ -98,7 +98,7 @@ static int secp256k1_ext_reencode_pubkey(
9898
// In: point: pointer to a 64-byte public point,
9999
// encoded as two 256bit big-endian numbers.
100100
// scalar: a 32-byte scalar with which to multiply the point
101-
int secp256k1_ext_scalar_mul(const secp256k1_context* ctx, unsigned char *point, const unsigned char *scalar) {
101+
int ethkit_secp256k1_ext_scalar_mul(const secp256k1_context* ctx, unsigned char *point, const unsigned char *scalar) {
102102
int ret = 0;
103103
int overflow = 0;
104104
secp256k1_fe feX, feY;

go-ethereum/crypto/secp256k1/libsecp256k1/CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ The ABI is backward compatible with versions 0.4.x and 0.3.x.
6060

6161
#### Changed
6262
- The point multiplication algorithm used for ECDH operations (module `ecdh`) was replaced with a slightly faster one.
63-
- Optional handwritten x86_64 assembly for field operations was removed because modern C compilers are able to output more efficient assembly. This change results in a significant speedup of some library functions when handwritten x86_64 assembly is enabled (`--with-asm=x86_64` in GNU Autotools, `-DSECP256K1_ASM=x86_64` in CMake), which is the default on x86_64. Benchmarks with GCC 10.5.0 show a 10% speedup for `secp256k1_ecdsa_verify` and `secp256k1_schnorrsig_verify`.
63+
- Optional handwritten x86_64 assembly for field operations was removed because modern C compilers are able to output more efficient assembly. This change results in a significant speedup of some library functions when handwritten x86_64 assembly is enabled (`--with-asm=x86_64` in GNU Autotools, `-DSECP256K1_ASM=x86_64` in CMake), which is the default on x86_64. Benchmarks with GCC 10.5.0 show a 10% speedup for `ethkit_secp256k1_ecdsa_verify` and `secp256k1_schnorrsig_verify`.
6464

6565
#### ABI Compatibility
6666
The ABI is backward compatible with versions 0.4.0 and 0.3.x.
@@ -147,7 +147,7 @@ Due to changes in the API regarding `secp256k1_context_static` described above,
147147

148148
#### Changed
149149
- Enabled modules `schnorrsig`, `extrakeys` and `ecdh` by default in `./configure`.
150-
- The `secp256k1_nonce_function_rfc6979` nonce function, used by default by `secp256k1_ecdsa_sign`, now reduces the message hash modulo the group order to match the specification. This only affects improper use of ECDSA signing API.
150+
- The `ethkit_secp256k1_nonce_function_rfc6979` nonce function, used by default by `ethkit_secp256k1_ecdsa_sign`, now reduces the message hash modulo the group order to match the specification. This only affects improper use of ECDSA signing API.
151151

152152
#### Deprecated
153153
- Deprecated context flags `SECP256K1_CONTEXT_VERIFY` and `SECP256K1_CONTEXT_SIGN`. Use `SECP256K1_CONTEXT_NONE` instead.

go-ethereum/crypto/secp256k1/libsecp256k1/CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ The Contributor Workflow & Peer Review in libsecp256k1 are similar to Bitcoin Co
4444

4545
In addition, libsecp256k1 tries to maintain the following coding conventions:
4646

47-
* No runtime heap allocation (e.g., no `malloc`) unless explicitly requested by the caller (via `secp256k1_context_create` or `secp256k1_scratch_space_create`, for example). Moreover, it should be possible to use the library without any heap allocations.
47+
* No runtime heap allocation (e.g., no `malloc`) unless explicitly requested by the caller (via `ethkit_secp256k1_context_create` or `secp256k1_scratch_space_create`, for example). Moreover, it should be possible to use the library without any heap allocations.
4848
* The tests should cover all lines and branches of the library (see [Test coverage](#coverage)).
4949
* Operations involving secret data should be tested for being constant time with respect to the secrets (see [src/ctime_tests.c](src/ctime_tests.c)).
5050
* Local variables containing secret data should be cleared explicitly to try to delete secrets from memory.

go-ethereum/crypto/secp256k1/libsecp256k1/contrib/lax_der_parsing.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88

99
#include "lax_der_parsing.h"
1010

11-
int ecdsa_signature_parse_der_lax(const secp256k1_context* ctx, secp256k1_ecdsa_signature* sig, const unsigned char *input, size_t inputlen) {
11+
int ecdsa_signature_parse_der_lax(const secp256k1_context* ctx, ethkit_secp256k1_ecdsa_signature* sig, const unsigned char *input, size_t inputlen) {
1212
size_t rpos, rlen, spos, slen;
1313
size_t pos = 0;
1414
size_t lenbyte;
1515
unsigned char tmpsig[64] = {0};
1616
int overflow = 0;
1717

1818
/* Hack to initialize sig with a correctly-parsed but invalid signature. */
19-
secp256k1_ecdsa_signature_parse_compact(ctx, sig, tmpsig);
19+
ethkit_ethkit_secp256k1_ecdsa_signature_parse_compact(ctx, sig, tmpsig);
2020

2121
/* Sequence tag byte */
2222
if (pos == inputlen || input[pos] != 0x30) {
@@ -137,11 +137,11 @@ int ecdsa_signature_parse_der_lax(const secp256k1_context* ctx, secp256k1_ecdsa_
137137
}
138138

139139
if (!overflow) {
140-
overflow = !secp256k1_ecdsa_signature_parse_compact(ctx, sig, tmpsig);
140+
overflow = !ethkit_ethkit_secp256k1_ecdsa_signature_parse_compact(ctx, sig, tmpsig);
141141
}
142142
if (overflow) {
143143
memset(tmpsig, 0, 64);
144-
secp256k1_ecdsa_signature_parse_compact(ctx, sig, tmpsig);
144+
ethkit_ethkit_secp256k1_ecdsa_signature_parse_compact(ctx, sig, tmpsig);
145145
}
146146
return 1;
147147
}

go-ethereum/crypto/secp256k1/libsecp256k1/contrib/lax_der_parsing.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
* certain violations are easily supported. You may need to adapt it.
2727
*
2828
* Do not use this for new systems. Use well-defined DER or compact signatures
29-
* instead if you have the choice (see secp256k1_ecdsa_signature_parse_der and
30-
* secp256k1_ecdsa_signature_parse_compact).
29+
* instead if you have the choice (see ethkit_ethkit_secp256k1_ecdsa_signature_parse_der and
30+
* ethkit_ethkit_secp256k1_ecdsa_signature_parse_compact).
3131
*
3232
* The supported violations are:
3333
* - All numbers are parsed as nonnegative integers, even though X.609-0207
@@ -85,7 +85,7 @@ extern "C" {
8585
*/
8686
int ecdsa_signature_parse_der_lax(
8787
const secp256k1_context* ctx,
88-
secp256k1_ecdsa_signature* sig,
88+
ethkit_secp256k1_ecdsa_signature* sig,
8989
const unsigned char *input,
9090
size_t inputlen
9191
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3);

go-ethereum/crypto/secp256k1/libsecp256k1/contrib/lax_der_privatekey_parsing.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ int ec_privkey_import_der(const secp256k1_context* ctx, unsigned char *out32, co
4545
return 0;
4646
}
4747
if (privkey[1]) memcpy(out32 + 32 - privkey[1], privkey + 2, privkey[1]);
48-
if (!secp256k1_ec_seckey_verify(ctx, out32)) {
48+
if (!ethkit_secp256k1_ec_seckey_verify(ctx, out32)) {
4949
memset(out32, 0, 32);
5050
return 0;
5151
}
@@ -55,7 +55,7 @@ int ec_privkey_import_der(const secp256k1_context* ctx, unsigned char *out32, co
5555
int ec_privkey_export_der(const secp256k1_context *ctx, unsigned char *privkey, size_t *privkeylen, const unsigned char *key32, int compressed) {
5656
secp256k1_pubkey pubkey;
5757
size_t pubkeylen = 0;
58-
if (!secp256k1_ec_pubkey_create(ctx, &pubkey, key32)) {
58+
if (!ethkit_secp256k1_ec_pubkey_create(ctx, &pubkey, key32)) {
5959
*privkeylen = 0;
6060
return 0;
6161
}
@@ -79,7 +79,7 @@ int ec_privkey_export_der(const secp256k1_context *ctx, unsigned char *privkey,
7979
memcpy(ptr, key32, 32); ptr += 32;
8080
memcpy(ptr, middle, sizeof(middle)); ptr += sizeof(middle);
8181
pubkeylen = 33;
82-
secp256k1_ec_pubkey_serialize(ctx, ptr, &pubkeylen, &pubkey, SECP256K1_EC_COMPRESSED);
82+
ethkit_secp256k1_ec_pubkey_serialize(ctx, ptr, &pubkeylen, &pubkey, SECP256K1_EC_COMPRESSED);
8383
ptr += pubkeylen;
8484
*privkeylen = ptr - privkey;
8585
} else {
@@ -104,7 +104,7 @@ int ec_privkey_export_der(const secp256k1_context *ctx, unsigned char *privkey,
104104
memcpy(ptr, key32, 32); ptr += 32;
105105
memcpy(ptr, middle, sizeof(middle)); ptr += sizeof(middle);
106106
pubkeylen = 65;
107-
secp256k1_ec_pubkey_serialize(ctx, ptr, &pubkeylen, &pubkey, SECP256K1_EC_UNCOMPRESSED);
107+
ethkit_secp256k1_ec_pubkey_serialize(ctx, ptr, &pubkeylen, &pubkey, SECP256K1_EC_UNCOMPRESSED);
108108
ptr += pubkeylen;
109109
*privkeylen = ptr - privkey;
110110
}

go-ethereum/crypto/secp256k1/libsecp256k1/doc/musig.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Therefore, users of the musig module must take great care to make sure of the fo
2222
## Key Aggregation and (Taproot) Tweaking
2323

2424
Given a set of public keys, the aggregate public key is computed with `secp256k1_musig_pubkey_agg`.
25-
A plain tweak can be added to the resulting public key with `secp256k1_ec_pubkey_tweak_add` by setting the `tweak32` argument to the hash defined in BIP 32. Similarly, a Taproot tweak can be added with `secp256k1_xonly_pubkey_tweak_add` by setting the `tweak32` argument to the TapTweak hash defined in BIP 341.
25+
A plain tweak can be added to the resulting public key with `ethkit_secp256k1_ec_pubkey_tweak_add` by setting the `tweak32` argument to the hash defined in BIP 32. Similarly, a Taproot tweak can be added with `secp256k1_xonly_pubkey_tweak_add` by setting the `tweak32` argument to the TapTweak hash defined in BIP 341.
2626
Both types of tweaking can be combined and invoked multiple times if the specific application requires it.
2727

2828
## Signing

0 commit comments

Comments
 (0)