Skip to content
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

Prime field #47

Open
vherbert opened this issue Jun 18, 2020 · 4 comments
Open

Prime field #47

vherbert opened this issue Jun 18, 2020 · 4 comments
Labels

Comments

@vherbert
Copy link

vherbert commented Jun 18, 2020

Hi,

I would like to employ your lib with prime field as possible. But doc is missing, I obtain strange behaviour with my usage.

#include <cstdint>
#include <stdexcept>
#include <libff/algebra/fields/fp.hpp>

using namespace std;

const mp_size_t limbcount = 4;
libff::bigint<limbcount> mod= libff::bigint<limbcount>("21888242871839275222246405745257275088548364400416034343698204186575808495617");
typedef libff::Fp_model<limbcount, mod> FieldT;

int main()
{
	assert(FieldT::modulus_is_valid());
	FieldT x = FieldT::random_element();
	FieldT y = FieldT::one();
	FieldT z = x + y;
	mod.print();
	x.print();
	y.print();
	z.print();
        FieldT::one().print()
	assert(FieldT::zero() != FieldT::one());	
}

fail

Help would be appreciated. Thanks.

`

@vherbert
Copy link
Author

It seems to require to define at least inv and Rsquared class members, resp. equal to modulus^(-1) mod W, where W = 2^(word size) and R^2, where R = W^k, where k = ??

@AthrunArthur
Copy link

Same problem here. Any suggestion about how to fix this?

@AthrunArthur
Copy link

Seems missed defining values here is <fp.hpp>

template<mp_size_t n, const bigint<n>& modulus>
size_t Fp_model<n, modulus>::num_bits;

template<mp_size_t n, const bigint<n>& modulus>
bigint<n> Fp_model<n, modulus>::euler;

template<mp_size_t n, const bigint<n>& modulus>
size_t Fp_model<n, modulus>::s;

template<mp_size_t n, const bigint<n>& modulus>
bigint<n> Fp_model<n, modulus>::t;

template<mp_size_t n, const bigint<n>& modulus>
bigint<n> Fp_model<n, modulus>::t_minus_1_over_2;

template<mp_size_t n, const bigint<n>& modulus>
Fp_model<n, modulus> Fp_model<n, modulus>::nqr;

template<mp_size_t n, const bigint<n>& modulus>
Fp_model<n, modulus> Fp_model<n, modulus>::nqr_to_t;

template<mp_size_t n, const bigint<n>& modulus>
Fp_model<n, modulus> Fp_model<n, modulus>::multiplicative_generator;

template<mp_size_t n, const bigint<n>& modulus>
Fp_model<n, modulus> Fp_model<n, modulus>::root_of_unity;

template<mp_size_t n, const bigint<n>& modulus>
mp_limb_t Fp_model<n, modulus>::inv;

template<mp_size_t n, const bigint<n>& modulus>
bigint<n> Fp_model<n, modulus>::Rsquared;

template<mp_size_t n, const bigint<n>& modulus>
bigint<n> Fp_model<n, modulus>::Rcubed;

@AthrunArthur
Copy link

Just in case anyone have the same problem, you may check this repo:

https://github.com/niekbouman/libff_init.git

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants