-
Notifications
You must be signed in to change notification settings - Fork 302
Description
Hi @real-or-random As you suggested I created a separate issue here in rust-secp256k1.
I'm on very very tiny Linux from Poky/Yocto project and have full std but only with 256KB of RAM available for my app. If I set some very small numbers to define size of precompiled tables like
ctx->prec = (secp256k1_ge_storage (*)[ECMULT_GEN_PREC_N][ECMULT_GEN_PREC_G])manual_alloc(prealloc, prealloc_size, base, prealloc_size);
so it effectively becomes
ctx->prec = (secp256k1_ge_storage (*)[16][16])manual_alloc(prealloc, 256, base, 256);
where prealloc_size
is 256 due to SECP256K1_ECMULT_GEN_CONTEXT_PREALLOCATED_SIZE
resolves to 256 in
size_t const C= SECP256K1_ECMULT_GEN_CONTEXT_PREALLOCATED_SIZE;
Without those black magik tricks even with ECMULT_WINDOW_SIZE
4 - prealloc_size
at some step is 65536 and causes SEGFAULT for me. With those small numbers, I'm able to run my code to the point where pure rust libsecp256k1 runs. But with those small numbers all major rust-secp256k1 sign/verify tests fail
though all tests in my repo pass. As I understand to avoid black magik I have to switch to static prec defining USE_ECMULT_STATIC_PRECOMPUTATION
and generating ecmult_static_context.h
with the smallest possible table size. Or since I neither use signing nor verify - just scalar and point math maybe I should disable pre-comp at all if I can? I saw SECP256K1_CONTEXT_NONE
and in your PR Changes necessary for usage on Trezor secp256k1-zkp#53 and there is no method for context none in rust-secp256k1 lib.rs
- just All, SignOnly, VerifyOnly.
Thanx)