概率和科学难题_油和醋使难题变得容易

概率和科学难题

Okay. This isn’t going to be an easy read, but it reveals an amazing method, and that could help fix our security in a world of quantum computers. The method involves taking a hard problem to solve, and then applying a trap door. If we know a little secret, the hard problem becomes easy.

好的。 这不是容易读懂的,但它揭示了一种惊人的方法,它可以帮助解决量子计算机世界中的安全问题。 该方法涉及解决一个棘手的问题,然后应用活板门。 如果我们知道一个小秘密,那么难题就很容易了。

Overall, quantum computers will be able to break our existing public key methods, such as discrete logs, RSA and elliptic curve. And so NIST has created a Post Quantum Cryptography competition, and one of the methods is known as Rainbow. This is known as the Oil and Vinegar method and uses multivariate cryptography with an added trapdoor. So let’s take a simple example, and work through how the trapdoor works.

总体而言,量子计算机将能够打破我们现有的公开密钥方法,例如离散日志,RSA和椭圆曲线。 因此NIST创建了一个后量子密码术竞赛,其中一种方法被称为Rainbow。 这被称为“油和醋”方法,并使用带有附加活板门的多元加密技术。 因此,让我们举一个简单的示例,并研究活板门的工作原理。

With multivariate cryptography, we have n variables within polynomial equations. For example, if we have four variables (w,x,y,z) and an order of two, we could have [here]:

使用多元密码学,我们在多项式方程中有n个变量。 例如,如果我们有四个变量( wxyz )且阶数为2,则可以有[ here ]:

w²+4wx+3x²+2wy−4wz+2wx+6xz=387

瓦特²+ 4 WX 3 X 2 + 2 WY -4 WZ 2 WX 6 XZ = 387

Generally, this is a hard problem to solve, so we want to make it easy if we know a secret. In this case, I know that the solution is w=7,x=4,y=5, and z=6. For a matrix form, we could represent this as:

通常,这是一个很难解决的问题,因此,如果我们知道一个秘密,我们希望使其变得容易。 在这种情况下,我知道解为w = 7, x = 4, y = 5和z = 6。 对于矩阵形式,我们可以表示为:

Image for post

This matrix has a trapdoor, and where we define our vinegar and oil variables. The vinegar variables are secret and which we will only know, and the oil ones will be discovered if we know the vinegar variables. The trap door is that we do not let the oil variables mix, and where they do mix in the matrix we will have zeros (the trap door):

这个矩阵有一个活板门,在这里我们定义了醋和油的变量。 醋变量是秘密的,只有我们知道,如果知道醋变量,就会发现油类。 活板门是我们不让油变量混合,在矩阵中它们混合的地方,我们将为零(活板门):

Image for post

In order to contain the values we get, we normally perform (mod p) operation and where p is a prime number. This is known as a finite field, and are numbers are always constrained between 0 and p−1. For example, if we select p=97 we have:

为了包含我们得到的值,我们通常执行(mod p )操作,其中p是质数。 这被称为有限域,并且数字始终限制在0到p -1之间。 例如,如果我们选择p = 97,则有:

w²+4wx+3x²+2wy−4wz+2wx+6xz=5 (mod 97)

瓦特²+ 4 WX 3 X 2 + 2 WY -4 WZ 2 WX 6 XZ = 5(MOD 97)

Now there are multiple solutions to this now for w,x,y,z, so we define n multivariate polynomials. For example:

现在对于wxyz有多种解决方案,因此我们定义了n个多元多项式。 例如:

w²+4wx+3x²+2wy−4xz+2wx+6xy=96 (mod 97)

瓦特²+ 4 WX 3 X 2 + 2 WY -4 XZ 2 WX 6的xy = 96(MOD 97)

5w²+3wx+3x²+4wyxz+8wx+4xy=36 (mod 97)

5w²3 WX 3 X 2 + 4 WY - XZ 8 WX 4的xy = 36(MOD 97)

4w²+5wx+3+2wy−5xz+3wx+6xy=95 (mod 97)

4w² + 5 wx + 3x² +2 wy −5 xz +3 wx +6 xy = 95(mod 97)

6w²+7wx+4x²+2wy−8xz+2wx+9xy=17 (mod 97)

6瓦特²+ 7 WX 4 X 2 + 2 WY -8 XZ 2 WX 9的xy = 17(MOD 97)

With large values of the variables, this is a known hard problem to solve. So now we define our vinegar variables of w and x and oil variables of y and z. If we know w and x it will now become easy to determine oil variables. For example, if w=7 and x=4, we get:

对于较大的变量值,这是一个众所周知的难题。 因此,现在我们定义wx的醋变量以及yz的油变量。 如果我们知道wx ,现在将很容易确定机油变量。 例如,如果w = 7且x = 4,我们得到:

49+112+48+14y−16z+14z+24y=96 (mod 97)

49 + 112 + 48 + 14 y −16 z +14 z +24 y = 96(mod 97)

245+84+48+28y−4z+56z+16y=36 (mod 97)

245 + 84 + 48 + 28 y −4 z +56 z +16 y = 36(mod 97)

and gives:

并给出:

209+38y−2z=96 (mod 97)

209 + 38 y -2 z = 96(mod 97)

377+44y+52z=36 (mod 97)

377 + 44 y +52 z = 36(mod 97)

and gives:

并给出:

38y+95z=−113 (mod 97)

38 y +95 z = −113(mod 97)

44y+52z=−341 (mod 97)

44 y +52 z = −341(mod 97)

and gives:

并给出:

38y+95z=81 (mod 97)

38 y +95 z = 81(mod 97)

44y+52z=47 (mod 97)

44 y +52 z = 47(mod 97)

This is now a simple linear equation (in a modulo form), and which can be easily solved. In a matrix form this becomes:

现在,这是一个简单的线性方程(以模形式),并且可以轻松求解。 以矩阵形式,它变为:

Image for post

and we can solve for y and z with:

我们可以用以下公式求解yz

Image for post

We can now easily solve this with y=5 and z=6. Here is the code [here]:

现在,我们可以轻松地通过y = 5和z = 6来解决这个问题。 这里是代码[ here ]:

import numpy as np
from inv import modMatInv
import sys

p=97

w=7
x=4


if (len(sys.argv)>1):
w=int(sys.argv[1])
if (len(sys.argv)>2):
x=int(sys.argv[2])

if (len(sys.argv)>3):
p=int(sys.argv[3])

def printM(M):
rtn = ""+str(M[0][0])+"w^2 + "+str(M[0][1]+M[1][0])+"wx + "+str(M[1][1])+"x^2 + "+str(M[0][2]+M[2][0])+"wy + "+str(M[1][3]+M[3][1])+"xz + " +str(M[0][3]+M[3][0])+"wz + "+str(M[1][2]+M[2][1])+"xy"
return rtn

def revealM(M,w,x):
rtn = ""+str(M[0][0]*w*w) +" + "+str((M[0][1]+M[1][0])*w*x)+" + "+str(M[1][1]*x*x)+" + "+str((M[0][2]+M[2][0])*w)+"y + "+str((M[1][3]+M[3][1])*x)+"z + " +str((M[0][3]+M[3][0])*w)+"z + "+str((M[1][2]+M[2][1])*x)+"y"
return rtn


M0=[[1,2,1,1],[2,3,3,-2],[1,3,0,0],[1,-2,0,0]]
M1=[[5,2,1,2],[1,3,2,2],[3,2,0,0],[6,-3,0,0]]
M2=[[4,2,2,1],[3,3,3,-2],[0,3,0,0],[2,-3,0,0]]
M3=[[6,2,1,1],[5,4,3,-3],[1,6,0,0],[1,-5,0,0]]

print ("p=",p)

print ("\nM0:",M0)
print ("M1:",M1)
print ("M2:",M2)
print ("M3:",M3)

# res = m . M0 . m^{-1}
res0=96
res1=36
res2=95
res3=17

a=(res0-(M0[0][0]*(w*w)+(M0[0][1]+M0[1][0])*w*x + (M0[1][1])*x*x ) ) %p
b=(res1-(M1[0][0]*(w*w)+(M1[0][1]+M1[1][0])*w*x + (M1[1][1])*x*x ) ) %p

factor1=( ((M0[0][2]+M0[2][0])*w) + ((M0[1][2]+M0[2][1]) *x) ) %p
factor2=( ((M0[0][3]+M0[3][0])*w) + ((M0[1][3]+M0[3][1]) *x) ) %p
factor3=( (M1[0][2]+M1[2][0])*w) + ((M1[1][2]+M1[2][1]) *x) %p
factor4=( ((M1[0][3]+M1[3][0])*w) + ((M1[1][3]+M1[3][1])*x)) %p

print ("w=",w)
print ("x=",x)
print (printM(M0))
print (printM(M1))
print ()
print (revealM(M0,w,x))
print (revealM(M1,w,x))
print ()
print (str(factor1)+"y+"+str(factor2)+"z="+str(a))
print (str(factor3)+"y+"+str(factor4)+"z="+str(b))
print ()


A = np.array([[factor1,factor2], [factor3,factor4]])
B = np.array([a,b])

invA = modMatInv(A,p)

print (invA)

res = np.dot(invA,B) % p


print ("y=",res[0])
print ("z=",res[1])

And a sample run [here]:

并运行一个示例[这里]:

p= 97

M0: [[1, 2, 1, 1], [2, 3, 3, -2], [1, 3, 0, 0], [1, -2, 0, 0]]
M1: [[5, 2, 1, 2], [1, 3, 2, 2], [3, 2, 0, 0], [6, -3, 0, 0]]
M2: [[4, 2, 2, 1], [3, 3, 3, -2], [0, 3, 0, 0], [2, -3, 0, 0]]
M3: [[6, 2, 1, 1], [5, 4, 3, -3], [1, 6, 0, 0], [1, -5, 0, 0]]
w= 7
x= 4
1w^2 + 4wx + 3x^2 + 2wy + -4xz + 2wz + 6xy
5w^2 + 3wx + 3x^2 + 4wy + -1xz + 8wz + 4xy

49 + 112 + 48 + 14y + -16z + 14z + 24y
245 + 84 + 48 + 28y + -4z + 56z + 16y

38y+95z=81
44y+52z=47

Inverse matrix:
[[63. 36.]
[81. 5.]]
y= 5.0
z= 6.0

Here is the full code:

这是完整的代码:

And so with a little bit of secret information (from the vinegar variables) we can take a hard problem, and make it easy, and then discover the oil variables. Fingers-crossed that a rainbow and a bit of oil and vinegar might solve our post-quantum cryptography problem, and secure the Internet.

因此,利用一些秘密信息(来自醋变量),我们可以解决一个棘手的问题,使其变得简单,然后发现机油变量。 手指交叉,彩虹和一点点油和醋可能会解决我们的后量子密码学问题,并保护互联网。

Paper: [here]

论文:[这里]

翻译自: https://medium.com/asecuritysite-when-bob-met-alice/oil-and-vinegar-makes-a-hard-problem-easy-205269c7c5

概率和科学难题

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值