I'm working with one-way accumulators, but I'm not knowledgable in cryptography. Is there an easy peasy way to hash numbers (or whatever) into prime numbers? Obviously I'd like it to be collision resistant and all that, but this project is huge, I'm alone and I'm confident someone else in the field will pick up from there. Also, primality tests are linear in n or what? Thanks
Asked
Active
Viewed 1,513 times
1
-
Please expand your question with more detail, it's hard to tell what you're asking for. Also, what does the size of the project have to do with anything? – pg1989 Apr 16 '14 at 03:21
-
possible duplicate of How can I generate large prime numbers for RSA? – rath Apr 16 '14 at 03:50
-
2@gurghet I think the question is how to deterministically and efficiently map a given interger to a prime such that you can safely accumulate it in an RSA based accumulator? – DrLecter Apr 16 '14 at 05:16
-
3Hashing to primes is easy. Just seed a PRNG with the hash of the input and use it to generate a prime with any standard algorithm. – CodesInChaos Apr 16 '14 at 07:09
-
@CodesInChaos yes!! thank you. if you post it as an answer I will gladly pick it. – gurghet Apr 16 '14 at 07:10
-
Addition: the Rabin-Miller probabilistic primality tests has cost in $\mathcal O(\log(n)^3)$ (with the straightforward multiplication algorithm and vanishingly low odds of letting a composite creep). – fgrieu Apr 16 '14 at 07:17
-
1Welcome to Cryptography Stack Exchange. From your question, it seems like you have some more needs which are not clearly stated in the question. Maybe you could expand your question a bit? – Paŭlo Ebermann Apr 18 '14 at 13:50
2 Answers
1
Thank you for your answers but I think I found a better method.
- Take the hash of your input $h(x)$, preferably with random oracle approximation
- Sample the interval $[2^kh(x), 2^k(h(x)+1)]$ and pick only primes, for each of them
- Hash it with an universal hashing function $f$ until you find that $f(p)=h(x)$
- Write to memory: $H(x)=p$
Done!
notes:
The random oracle makes collisions infeasible
Universal hashing gives high density of primes with high probability (there is a theorem out there but the principle is that, for a given prime, I have multiple hash outputs, so the probability that one of them is my input increases. See: Gennaro et al. - Secure hash-and-sign signatures without the Random Oracle, lemma 2)
-
What is $k$? Why the universal hashing function? I don't see how this is "better" than the standard PRNG method CodesInChaos suggested in the comments. – Thomas Apr 16 '14 at 07:46
-
Why $h(x)$? If this works there are only $k$ bits to play with in step 2. Thus only $2^k$ tests in the worst case. – gurghet Apr 16 '14 at 07:52
-
k is just a small int. The random oracle protects me from collisions @Thomas – gurghet Apr 16 '14 at 07:53
-
@gurghet Again, what advantage does this scheme have over using a PRNG? You can't claim it's "better" without giving any explanation, you should elaborate so future people reading this can understand why. – Thomas Apr 16 '14 at 08:24
-
@Thomas I've updated the answer. I just have to find the theorem for the second statement, I'm sure I have seen it somewhere but can't remember where :( – gurghet Apr 16 '14 at 13:19
-
Sounds needlessly complicated. I see no advantage over the straight forward approach. – CodesInChaos Apr 16 '14 at 14:06
-
@CodesInChaos, there is no immediate advantage, in fact I'm using your solution now for testing purposes. Sooner or later though, this thing will go in production, and a key space of 32 bit will not be sufficiently large! (for starters) – gurghet Apr 16 '14 at 14:29
-
@gurghet With a PRNG I mean a cryptographically secure stream cipher which obviously has keys of at least 128 bits. So I don't know where your 32 bit key space comes from. – CodesInChaos Apr 16 '14 at 14:41
-
2You state without reference "Universal hashing gives high density of primes with high probability". I fail to see why, and doubt it. And I fail to see why it would matter, for the input of the universal hash is prime in your method, not the output. -- Trying $p$ until $f(p)=h(x)$ is expected to require $2^{w-1}$ steps where $w$ is the output width of $h$, and thus impractical. -- The method outlined by CodesInChaos seems just fine to me. – fgrieu Apr 16 '14 at 14:48
-
Well, if the density is high, say it's 0.01, I only need 100 samples, this is why it's important. @fgrieu as soon as I find the theorem, I will publish the reference to it. – gurghet Apr 16 '14 at 15:31
-
@gurghet Just a small heads-up: don’t forget to accept your own answer if it satisfies your needs. ;) – e-sushi May 15 '14 at 23:11
-1
Misiec´s conjecture:
Let
$$x= \frac{1}{n \cdot n^{\frac{1}{2} + n \cdot 2 \cdot i}}$$
if $n$ is a prime number then the $\sin(x)=x$, and if not the number is not a prime number.
Even though the conjecture does not hold true the $x$ value obtained turns a non-prime number into a complex prime number.

Maarten Bodewes
- 92,551
- 13
- 161
- 313
-
-
1Welcome, Luis. Can you check the algorithm for correctness? MathJax explanation is here. Please also provide a reference to the conjecture, it seems hard to find. – Maarten Bodewes Jan 20 '20 at 16:46
-
5
-
The equality seems to always hold, thus the conjecture looks false: https://bit.ly/2tr9xJq Zooming on the prime 7, the curves do not join, so I guess the difference between the curves comes from computation errors: https://bit.ly/2G6OnD5 – A. Hersean Jan 20 '20 at 17:53
-
sorry i do not have a proof as it came to me by verifying that the sumation of the zeta function when divided by n when n is a prime all the numbers expressed by the equation f(x) you get a result where the sin of x is equal x, – luis felipe massena misiec Apr 10 '20 at 22:03
-
if you may just use the google search bar and type any number in the form shoen above for x and you get numbers that respect the squeeze theorem for the limit of x going to zero, it just rounds up the numbers, so it is something to consider because as far as i know sinx=x gives x= zero, but the numbers obtained are squeezed between 0 and the given complex number obtained, as if they had only a relation to them selves and 1. For instance 1/4747^(1/2+4747i))=-0.112984719 - 0.0922553474 i and sin(1/4747^(1/2+4747i)))=-0.113224614 - 0.0917972145 – luis felipe massena misiec Apr 10 '20 at 22:03
-
i given an interval of confidence they are equal just rounded up. check for riemanns hypothesis solution update for the graphs you will see that the graph of the sin of the summation of the numbers given by x are exactly the same as the graph for the summation only – luis felipe massena misiec Apr 10 '20 at 22:04
-
I made a mistake in the typing consider 1/2+ 2ni for 1/2+nni – luis felipe massena misiec Apr 10 '20 at 22:26