📄 pub_key_gen.m
字号:
%% 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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -