PyZPK
PyZPK copied to clipboard
Getting Error while binding functions which use libff::random_element()
Description
Getting Segmentation fault while binding, functions which use random_element()
random_element() is defined in Libff: a C++ library for Finite Fields and Elliptic Curves
and it returns a random element of Fp_model
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff40b7c8c in libff::Fp_model<5l, libff::mnt46_modulus_B>::random_element() ()
at /home/PyZPK/third_party/libsnark/depends/libff/libff/algebra/fields/fp.tcc:712
712 r.mont_repr.data[part] &= ~(1ul<<bit);
(gdb) p part
$1 = 288230376151711743
(gdb) p r.mont_repr.data
$2 = {0, 0, 0, 0, 0}
One of the functions which use libff::random_element()
is generate_r1cs_example_with_field_input and it is wrapped here
Expected Behavior
The value of part
should be <5
for the data array
= {0, 0, 0, 0, 0}
It was tested in libsnark library directly where it was working fine without any error.
System Information
- OS: Ubuntu
- OS Version: 18.04
- Language Version: Python 3.7
How to test
The following test must pass after solving this error, currently generate_r1cs_example_with_field_input
is producing the error mentioned above.
import pyzpk
qap_degree = 1 << pyzpk.mnt6_Fr_s # basic_domain_size
num_inputs = 10
num_constraints = qap_degree - num_inputs - 1
# For Field input
example = pyzpk.generate_r1cs_example_with_field_input(num_constraints, num_inputs)
assert example.constraint_system.is_satisfied(example.primary_input, example.auxiliary_input)