Post
Topic
Board Bitcoin Discussion
Re: Bitcoin puzzle transaction ~32 BTC prize to who solves it
by
nomachine
on 13/01/2024, 10:20:14 UTC
result
0230210c23b1a047bc9bdbb13448e67deddc108946de6de639bcc75d47c0216b1b
 Grin


Check each function separately. Starting with void point_add().
Missing intermediate variables.
   mpz_t imod;
   mpz_t l;
   mpz_t lsq;
   mpz_t lsq2;
   mpz_t lsq3;
   mpz_t mul;
   mpz_t x3;
   mpz_t xmx3;
   mpz_t xsub;
   mpz_t ymul;
   mpz_t ys;
   mpz_t ysub;

Should the results be stored in temporary variables?
For example:
mpz_sub(ysub, other.m_y, m_y);
mpz_sub(xsub, other.m_x, m_x);
mpz_invert(imod, xsub, m_curve.m_p);
mpz_mul(mul, ysub, imod);
mpz_mod(l, mul, m_curve.m_p);
mpz_pow_ui(lsq, l, 2);
mpz_sub(lsq2, lsq, m_x);
mpz_sub(lsq3, lsq2, other.m_x);
mpz_mod(x3, lsq3, m_curve.m_p);
mpz_sub(xmx3, m_x, x3);
mpz_mul(ymul, l, xmx3);
mpz_sub(ys, ymul, m_y);
mpz_mod(m_y, ys, m_curve.m_p);
mpz_set(m_x, x3);
mpz_set_ui(m_o, 0);

Did it. Now I have
# ./test.bin
Floating point exception

now I'm debugging to find out why
# gdb ./test.bin ./core.9180
GNU gdb (Debian 10.1-1.7) 10.1.90.20210103-git
Copyright (C) 2021 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./test.bin...
[New LWP 9180]
Core was generated by `./test.bin'.
Program terminated with signal SIGFPE, Arithmetic exception.
#0  0x00007f962643fce1 in raise () from /lib/x86_64-linux-gnu/libc.so.6
(gdb) bt
#0  0x00007f962643fce1 in raise () from /lib/x86_64-linux-gnu/libc.so.6
#1  0x00007f96267b4867 in __gmp_exception () from /lib/x86_64-linux-gnu/libgmp.so.10
#2  0x00007f96267b488e in __gmp_divide_by_zero () from /lib/x86_64-linux-gnu/libgmp.so.10
#3  0x00007f96267ce4f5 in __gmpz_tdiv_r () from /lib/x86_64-linux-gnu/libgmp.so.10
#4  0x00007f96267c7760 in __gmpz_mod () from /lib/x86_64-linux-gnu/libgmp.so.10
#5  0x000055685a4666d6 in point_double (x=0x7ffdcc41f870, y=0x7ffdcc41f860, lmbda=0x7ffdcc41f850,
    x3=0x7ffdcc41f840, y3=0x7ffdcc41f830, p=0x55685a469240 <p>) at test.cpp:97
#6  0x000055685a4665b8 in point_multiply (Qx=0x7ffdcc41f8e0, Qy=0x7ffdcc41f8d0, x=0x55685a469220 <Gx>,
    y=0x55685a469230 <Gy>, k=0x7ffdcc41f8c0, p=0x55685a469240 <p>) at test.cpp:74
#7  0x000055685a466350 in private_key_to_public_key (private_key=0x55685a46712b "30568377312064202855",
    compressed_public_key=0x7ffdcc41f900 "\001") at test.cpp:29
#8  0x000055685a466eb6 in main () at test.cpp:201
(gdb)

This is pain in ass  Grin