前言
我们现有的公钥方法面临被量子计算机破解的巨大危险。被提议作为量子计算机的一个难题的方法之一是错误学习问题(LWE)。
LWE是量子鲁棒性密码学方法。
我们创建一个密钥值 (s) 和另一个值 (e)。接下来我们选择A[]并计算
B[] = A[] *s + e
A[] 和 B[] 的值成为我们的公钥。如果 s 是单个值,则 A 和 B 是一维矩阵。如果我们选择 s 为一维矩阵,则 A 为二维矩阵,B 为一维矩阵。
错误学习是 Oded Regev 在 2005 年 [ 论文] 定义的一种方法。它涉及找到解决以下问题的值的难度:
B = A × s + e
公钥:A和B
密钥:s
相关解释ppt
一、LWE and Ring LWE
1.概念介绍
一个基本的LWE:
import numpy as np
import sys
q=13 //mod q
A=np.array([
[4 ,1, 11, 10],
[5, 5 ,9 ,5],
[3, 9 ,0 ,10],
[1, 3 ,3 ,2],
[12, 7 ,3 ,4],
[6, 5 ,11 ,4],
[3, 3, 5, 0]])
sA = np.array([[6],[9],[11],[11]])
eA = np.array([[0],[-1],[1],[1],[1],[0],[-1]])
bA = np.matmul(A,sA)%q
print(bA)
bA = np.add(bA,eA)%q
print("Print output\n",bA)
Public Key Encryption with Learning With Errors (LWE):
import sys
import numpy as np
import random
import math
nvals=20
B=[]
e=[]
s = 20
message = 1
q=97
A = random.sample(range(q), nvals)
for x in range(0,len(A)):
e.append(random.randint(1,4))
B.append((A[x]*s+e[x])%q)
print("\n------Parameters and keys-------")
print("Message to send:\t",message)
print("Public Key (A):\t",A)
print("Public Key (B):\t",B)
print("Errors (e):\t\t",e)
print("Secret key:\t\t",s)
print("Prime number:\t\t",q)
print("\n------Sampling Process from public key-------")
sample= random.sample(range(nvals-1), nvals//4)
print("Sampling",sample)
u=0
v=0
for x in range(0,len(sample)):
print("[",A[sample[x]],B[sample[x]],"]", end=' ')
u=u+(A[sample[x]])
v= v+B[sample[x]]
v=v+math.floor(q//2)*message
v = v%q
u = u%q
print()
print("\n------Calculation of u and v -----------------")
print("u:\t\t",u)
print("v:\t\t",v)
res=(v-s*u) % q
print("Result is\t",res)
if (res>q/2):
print("Message is a 1")
else:
print("Message is a 0")
2.读入数据
总结
提示:这里对文章进行总结:
例如:以上就是今天要讲的内容,本文仅仅简单介绍了pandas的使用,而pandas提供了大量能使我们快速便捷地处理数据的函数和方法。