pub_key_gen.m
来自「elgamal elgrithm by matlab」· M 代码 · 共 37 行
M
37 行
%% The public key generator for the receiver%% Here the receiver chooses p, Alpha, and is assigned the% secret key (the secret key is already set in this algorithm.% The public key Betaa is computed.% Allow these variables to be global throughout the sessionglobal y1 y2 num_plaintext % Load numtheory for Maple which has useful funcionsmaple('with(numtheory)');disp('Warning: it may take a few minutes to generate Alpha in some cases.')% **********Set the secret key for the user*********** %% This is where you need to change the code to change the secret keymaple('a:=', 245674);disp(' ')disp('Publishing p, Alpha and Betaa:')% Generate a random prime p (p is between 0 and 2^128)maple('p:=','nextprime(rand(0..2^128)())')p = maple('p');% Compute the primitive root Alphamaple('Alpha:=','primroot(p)')Alpha = maple('Alpha');% Compute the public key Betamaple('Betaa:=','(Alpha^a) mod p')Betaa = maple('Betaa');
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?