作为一个非密码学家,有一件事总是让我震惊:为什么使用质数如此重要?是什么让它们在密码学中如此特别?
有人能简单解释一下吗?(我知道有很多入门知识,应用密码学是圣经,但如我所说:我不打算实现我自己的加密算法,我发现的东西只是让我的大脑爆炸-请不要十页的数学公式)。
作为一个非密码学家,有一件事总是让我震惊:为什么使用质数如此重要?是什么让它们在密码学中如此特别?
有人能简单解释一下吗?(我知道有很多入门知识,应用密码学是圣经,但如我所说:我不打算实现我自己的加密算法,我发现的东西只是让我的大脑爆炸-请不要十页的数学公式)。
这里有一个非常简单和常见的例子。
RSA加密算法通常用于安全的商业网站,它是基于这样一个事实:取两个(非常大的)素数并将它们相乘很容易,而做相反的事情则非常困难——这意味着:取一个非常大的数,给定它只有两个素数因子,并找到它们。
简单的?是的。
如果你把两个大素数相乘,你会得到一个只有两个(大)素数因数的巨大非素数。
分解这个数字是一个非平凡的操作,这一事实是许多密码学算法的来源。有关更多信息,请参阅单向函数。
附录: 再解释一下。两个质数的乘积可以用作公钥,而质数本身可以用作私钥。对数据所做的任何操作,如果只能通过知道这两个因素中的一个来撤销,那么解密起来就不是简单的了。
有一些很好的资源可以加强加密。这里有一个:
http://research.microsoft.com/en-us/groups/crypto/firstcrypto.aspx
从那一页开始:
In the most commonly used public-key cryptography system, invented by Ron Rivest, Adi Shamir, and Len Adleman in 1977, both the public and the private keys are derived from a pair of large prime numbers according to a relatively simple mathematical formula. In theory, it might be possible to derive the private key from the public key by working the formula backwards. But only the product of the large prime numbers is public, and factoring numbers of that size into primes is so hard that even the most powerful supercomputers in the world cant break an ordinary public key.
布鲁斯·施奈尔的《应用密码学》是另一本。我强烈推荐这本书;读起来很有趣。
Cryptographic algorithms generally rely for their security on having a "difficult problem". Most modern algorithms seem to use the factoring of very large numbers as their difficult problem - if you multiply two large numbers together, computing their factors is "difficult" (i.e. time-consuming). If those two numbers are prime numbers, then there is only one answer, which makes it even more difficult, and also guarantees that when you find the answer, it's the right one, not some other answer that just happens to give the same result.
最基本和一般的解释:密码学都是关于数论的,所有的整数(除了0和1)都是由质数组成的,所以你在数论中要处理很多质数。
More specifically, some important cryptographic algorithms such as RSA critically depend on the fact that prime factorization of large numbers takes a long time. Basically you have a "public key" consisting of a product of two large primes used to encrypt a message, and a "secret key" consisting of those two primes used to decrypt the message. You can make the public key public, and everyone can use it to encrypt messages to you, but only you know the prime factors and can decrypt the messages. Everyone else would have to factor the number, which takes too long to be practical, given the current state of the art of number theory.
我认为在密码学中重要的不是质数本身,而是质因数分解问题的难点
假设你有一个非常非常大的整数,已知是两个质数m和n的乘积,要找出m和n是什么并不容易。RSA等算法就是基于这个事实。
顺便说一下,有一篇发表的算法论文可以在可接受的时间内使用量子计算机“解决”这个质因数分解问题。因此,当量子计算机问世时,新的密码学算法可能不再依赖质因数分解的“困难”:)
质数本身并不重要,重要的是处理质数的算法。特别是求一个数(任何一个数)的因式。
如你所知,任何数字至少有两个因数。质数有一个独特的性质,它只有两个因数:1和质数本身。
The reason factoring is so important is mathematicians and computer scientists don't know how to factor a number without simply trying every possible combination. That is, first try dividing by 2, then by 3, then by 4, and so forth. If you try to factor a prime number--especially a very large one--you'll have to try (essentially) every possible number between 2 and that large prime number. Even on the fastest computers, it will take years (even centuries) to factor the kinds of prime numbers used in cryptography.
事实上,我们不知道如何有效地分解一个大数字,这赋予了密码算法的优势。如果有一天,有人想出了如何做到这一点,我们目前使用的所有加密算法都将过时。这仍然是一个开放的研究领域。
为了更具体地说明RSA如何使用素数的性质,RSA算法主要依赖于欧拉定理,该定理指出,对于相对素数“a”和“N”,a^e等于1模N,其中e是N的欧拉totient函数。
质数是怎么进来的?为了有效地计算N的欧拉totient函数,需要知道N的质因数分解。在RSA算法中,对于一些质数“p”和“q”,N = pq,那么e = (p - 1)(q - 1) = N - p - q + 1。但是如果不知道p和q, e的计算是非常困难的。
更抽象地说,许多密码学协议使用各种活板门函数,这些函数易于计算但难以反演。数论是这类活板门函数的丰富来源(例如大素数的乘法),而素数是数论的绝对中心。
我建议你读《代码中的数学之旅》这本书。这本书有一种很好的接地气的感觉,这是令人惊讶的,因为它是关于密码学的。这本书总结了Sarah Flannery从一个孩子学习谜题到在16岁时创建Cayley-Purser (CP)算法的旅程。它对单向函数、数论、质数以及它们与密码学的关系给出了令人惊讶的详细解释。
让这本书更具体地回答你的问题的是Sarah试图使用矩阵实现一个新的公钥算法。它比使用质数要快得多,但发现了一个可以利用它的循环漏洞。事实证明她的算法更适合作为私人加密机制。这本书是使用质数进行加密的一个很好的证明,因为它经受住了时间的考验和非常聪明的人的挑战。
我不是数学家或密码学家,所以这里有一个外行的观察(没有花哨的方程,抱歉)。
这整个线程充满了关于如何在密码学中使用质数的解释,很难在这个线程中找到任何人以简单的方式解释为什么使用质数…很可能是因为每个人都认为这些知识是理所当然的。
只有从外部看问题才能产生这样的反应;但是如果他们使用两个质数的和,为什么不创建一个列表,列出任何两个质数可以产生的所有可能的和呢?
在这个网站上有一个455,042,511个质数的列表,其中最高的质数是9,987,500,000(10位数字)。 已知的最大素数(截至2015年2月)是2的257,885,161 - 1次方,即17,425,170位数字。这意味着保留所有已知质数的列表是没有意义的,更不用说所有它们可能的和了。取一个数并检查它是否是质数更容易。
计算大质数本身就是一项艰巨的任务,所以密码学家和数学家都会说,反向计算两个相互相乘的质数已经足够困难了……今天。
因为每找到一个因子,分解算法的速度就会大大加快。将两个私钥设置为素数可以确保找到的第一个因子也是最后一个因子。理想情况下,两个私钥的值也几乎相等,因为只有较弱的密钥的强度才重要。