数字签名mulino功能

时间:2015-06-16 11:38:59

标签: matlab

您好我正在尝试运行数字signture,我收到一个错误: "未定义的功能' mulinv'输入参数类型为' double'。" 我将数字9和23插入为常量,因为错误与变量类型有关。

我的代码是:

addpath('C:\MATLAB\R2015a\VariablePrecisionIntegers');
disp('Implementation of ELGAMAL Digital Signature');
addpath('search-ms:query=mulinv\mulinv');
addpath('');
clear all; 
close all;

%%Hardcoded values (vpi stands for VariablePrecisionIntegers, and are used to store large values)
g = vpi(5)  %alpha in example
k = vpi(9)  %Random number 1<k<p-1 and gcd(k, p ? 1) = 1.
p = vpi(23) %Prime Number
x = vpi(3)  %Secret Key 1 < x < p ? 1
m = vpi(7)  %Message

y = vpi(2)
r = vpi(2)
s = vpi(2)

%%Key Generation
y = powermod(g,x,p)     %y = g^x mod p  

%%Signature Generation
r = powermod(g,k,p)     %r = g^k mod p

multinver = mulinv(9,23)    %Generates multiplicative inverse k^-1 mod p

s = mod(((multinver)*(m-x*r)),p-1)      %s = (k^-1)*(m-x*r) mod p-1


%%Verification
zvg = vpi(2);
zvg = powermod (g,m,p)      %zvg = g^m mod p

zvyr = vpi(2);
zvyr = mod(((y^r)*(r^s)),p) %zvyr = y^r * r^s mod p

1 个答案:

答案 0 :(得分:1)

不要clear all,而只是clear

如果您clear all还清除了所有添加的路径,那么让Matlab忘记addpath('search-ms:query=mulinv\mulinv');

阅读详情:http://uk.mathworks.com/help/matlab/ref/clear.html