Skip to content
This repository has been archived by the owner on Apr 20, 2021. It is now read-only.

[RSA Accumulator] Use Fermat Primality Test for verifying prime number #73

Open
hskang9 opened this issue Jan 21, 2019 · 3 comments
Open

Comments

@hskang9
Copy link

hskang9 commented Jan 21, 2019

Instead of testing with listed primes like this solidity prime tester, I propose other primality test here.

Fermat's Primality Test

in Fermat's primality test, if p is prime and a is an random integer,

a**(p-1) mod p = 1

For example, if a = 2, p = 17,

2**(17 - 1) mod 17 = 1 (prime)

Whereas a = 2, p = 16,

2**(16 - 1) mod 16 = 0 (not prime)

I just set a = 2 without varying it.

Conclusion

All I am worried for this algorithm is when calculating exponents which are bigger than uint256 can handle, but I see there is already functions for handling that.

Is there any way that we can implement this algorithm? If there is a blocking, what is it?

Cute Animal Picture

bird

@nrryuya
Copy link
Member

nrryuya commented Jan 21, 2019

@hskang9
Thank you!

Is there any way that we can implement this algorithm? If there is a blocking, what is it?

Nothing! I'm welcome to your pull-request ;)
As I mentioned in #71, it might suffer from the code size problem.
It'd be better to have another isPrime.vy contract.

@nrryuya
Copy link
Member

nrryuya commented Jan 21, 2019

@hskang9 hskang9 mentioned this issue Jan 21, 2019
@hskang9
Copy link
Author

hskang9 commented Jan 21, 2019

Thank you for your acceptance and information! Please review this PR I made.

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

Successfully merging a pull request may close this issue.

2 participants