我如何计算在密码学对数?

编程入门 行业动态 更新时间:2024-10-26 10:27:46
本文介绍了我如何计算在密码学对数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想对字节进行非线性函数来实现SAFER +。该算法需要在字节计算基础-45对数,我不知道该怎么做。

I am trying to perform non-linear functions on bytes to implement SAFER+. The algorithm requires computing base-45 logarithm on bytes, and I don't understand how to do it.

登录 45 (201)= 1.39316393

log45(201) = 1.39316393

当我分配给字节,值被截断为1,且无法恢复的确切的结果。

When I assign this to a byte, the value is truncated to 1, and I can't recover the exact result.

我应该怎么来处理这个

推荐答案

加密经常使用的黄金领域,在这种情况下,GF(257)。的创建一个看起来像一个幂表这样的:

Cryptography often uses prime fields, in this case, GF(257). Create an exponentiation table that looks like this:

exp | log ----+---- 0 | 1 1 | 45 2 | 226 3 | 147 ... | ... 128 | 0 ... | ... 255 | 40 ---------

日志值45 EXP %257.你需要用 modPow 功能的高精度计算库(养数量的电力,模一定的价值)来构建这个表。你可以看到,对于值EXP128是一种特殊的情况下,由于通常的零的对数是不确定的。

The "log" values are 45exp % 257. You'll need an arbitrary precision arithmetic library with a modPow function (raise a number to a power, modulo some value) to build this table. You can see that the value for "exp" 128 is a special case, since normally the logarithm of zero is undefined.

通过找到它计算一个数的对数在日志栏目;在该行的EXP列中的值的对数。

Compute the logarithm of a number by finding the it in the "log" column; the value in the "exp" column of that row is the logarithm.

下面是初始化的草图:

BigInteger V45 = new BigInteger(45); BigInteger V257 = new BigInteger(257); byte[] exp = new byte[256]; for (int idx = 0; idx < 256; ++idx) exp[idx] = BigInteger.ModPow(V45, new BigInteger(idx), V257) % 256; byte[] log = new byte[256]; for (int idx = 0; idx < 256; ++idx) log[exp[idx]] = idx;

通过这种设置,例如,日志 45 (131)= 日志[131] = 63,和45 38 = EXP [38] = 59。

With this setup, for example, log45(131) = log[131] = 63, and 4538 = exp[38] = 59.

(我从来没有写C#;我只是从的 的BigInteger 文档;也有可能是与数据类型的错误)

(I've never written C#; I'm just guessing from the BigInteger documentation; there are likely to be errors with the data types.)

更多推荐

我如何计算在密码学对数?

本文发布于:2023-07-05 14:40:51,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1038453.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:密码学   对数

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!