-
Notifications
You must be signed in to change notification settings - Fork 208
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
question: Build library without standard IO functions #262
Comments
This is related to the callbacks, see the docs for You need to configure with secp256k1-zkp/include/secp256k1.h Lines 277 to 285 in bfeae12
These should abort your program (but without printing an error message). |
@real-or-random Thanks for the quick answer. I am now compiling with The libsecp256k1 compiled successfully, but I got the error below when calling its functions.
The code is: void counting_illegal_callback_fn(const char* str, void* data) {
/* Dummy callback function that just counts. */
int32_t *p;
(void)str;
p = (int32_t *) data;
(*p)++;
}
int test_secp256k1_zkp() {
unsigned char seckey[32];
secp256k1_context* ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY);
int32_t ecount = 0;
int32_t ecount2 = 10;
secp256k1_context_set_illegal_callback(ctx, counting_illegal_callback_fn, &ecount);
secp256k1_context_set_illegal_callback(ctx, counting_illegal_callback_fn, &ecount2);
// ...
secp256k1_context_destroy(ctx);
return 1;
} |
As I quoted above, you have to define functions
I don't see them in your code. |
Thanks for the detailed explanation @real-or-random I managed to solve it with the following code: extern "C" {
#include "../secp256k1-zkp/include/secp256k1.h"
#include "../secp256k1-zkp/include/secp256k1_schnorrsig.h"
#include "../secp256k1-zkp/include/secp256k1_musig.h"
void secp256k1_default_illegal_callback_fn(const char* str, void* data) {
(void)str;
(void)data;
abort();
}
void secp256k1_default_error_callback_fn(const char* str, void* data) {
(void)str;
(void)data;
abort();
}
} |
…th x specified as n/d 0f86420 Add exhaustive tests for ecmult_const_xonly (Pieter Wuille) 4485926 Add x-only ecmult_const version for x=n/d (Pieter Wuille) Pull request description: This implements a generalization of Peter Dettman's sqrt-less x-only random-base multiplication algorithm from #262, using the Jacobi symbol algorithm from #979. The generalization is to permit the X coordinate of the base point to be specified as a fraction $n/d$: To compute $x(q \cdot P)$, where $x(P) = n/d$: * Compute $g=n^3 + 7d^3$. * Let $P' = (ng, g^2, 1)$ (the Jacobian coordinates of $P$ mapped to the isomorphic curve $y^2 = x^3 + 7(dg)^3$). * Compute the Jacobian coordinates $(X',Y',Z') = q \cdot P'$ on the isomorphic curve. * Return $X'/(dgZ'^2)$, which is the affine x coordinate on the isomorphic curve $X/Z'^2$ mapped back to secp256k1. This ability to specify the X coordinate as a fraction is useful in the context of x-only [Elligator Swift](https://eprint.iacr.org/2022/759), which can decode to X coordinates on the curve without inversions this way. ACKs for top commit: jonasnick: ACK 0f86420 real-or-random: ACK 0f86420 Tree-SHA512: eeedb3045bfabcb4bcaf3a1738067c83a5ea9a79b150b8fd1c00dc3f68505d34c19654885a90e2292ae40ddf40a58dfb27197d98eebcf5d6d9e25897e07ae595
I'm using
secp256k1-zkp
as a library in an Intel SGX Enclave project.When any
secp256k1-zkp
function is called in the untrusted environment, the project builds successfully.But I got the error below when
secp256k1-zkp
functions are called in Enclave trusted environment.The reason, I think, is taht the
secp256k1-zkp
library seems to have references to fprintf and stderr, which are standard C library functions and global variables.In the context of Intel SGX enclaves, the standard C library is not directly accessible in the same manner as regular applications.
So the linker (/usr/local/bin/ld) is unable to find references for stderr and __fprintf_chk, causing the "undefined reference" error.
Is there a way to compile the
secp256k1-zkp
library in a way that doesn't reference any functionality that isn't supported inside an enclave, like standard IO functions?I am building the
secp256k1-zkp
lib with--enable-module-schnorrsig --enable-experimental --enable-module-musig
flags and including./secp256k1-zkp/.libs/libsecp256k1.a
in the main project build.The text was updated successfully, but these errors were encountered: