代理重加密中的密文转换

发布于 2025-01-08 01:26:44 字数 1017 浏览 0 评论 0原文

我正在尝试实施 代理重新加密 以证明具有以下参数的概念。

q = 31, g = 2, sk_a = 3, sk_b = 5,

sk_a 和 q 是互质数,因此 sk_a 的逆存在于 mod q 中。

proxy_key = sk_b/sk_a  

其中 proxy_key 是通过将 sk_b 与 sk_a 的模逆相乘来计算的,即 (sk_b.sk_a inverse) mod q

密文: y = (g^sk_a) mod q

要转换密文,我正在使用 (y^proxy) mod q.

按照算法密文变换应该是(g^sk_b) mod q,但确实如此不适合我。

我不确定其中有什么问题。我正在使用以下代码。

    BigInteger q = new BigInteger("31");

    BigInteger g = new BigInteger("2");
    BigInteger sk_a = new BigInteger("3");
    BigInteger sk_b = new BigInteger("5");

    BigInteger proxy_key = sk_b.multiply(sk_a.modInverse(q)).mod(q);

    BigInteger y = g.modPow(sk_a, q);
    System.out.println("Cipher Text: " + y);

    BigInteger transformation = y.modPow(proxy_key, q);
    System.out.println("Cipher Text Transformation: " + transformation);

I am trying to implement proxy re encryption for the proof of concept with the following parameters.

q = 31, g = 2, sk_a = 3, sk_b = 5,

sk_a and q are co-primes thus inverse of sk_a exits in mod q.

proxy_key = sk_b/sk_a  

where proxy_key is calculated by multiply sk_b with modular inverse of sk_a i.e., (sk_b.sk_a inverse) mod q

cipher text: y = (g^sk_a) mod q

To transform cipher text I am using (y^proxy) mod q.

Accoding to the algorithm cipher text transformation should turn out to be (g^sk_b) mod q, but it does not work for me.

I am not sure what's the catch in it. I am using the following code.

    BigInteger q = new BigInteger("31");

    BigInteger g = new BigInteger("2");
    BigInteger sk_a = new BigInteger("3");
    BigInteger sk_b = new BigInteger("5");

    BigInteger proxy_key = sk_b.multiply(sk_a.modInverse(q)).mod(q);

    BigInteger y = g.modPow(sk_a, q);
    System.out.println("Cipher Text: " + y);

    BigInteger transformation = y.modPow(proxy_key, q);
    System.out.println("Cipher Text Transformation: " + transformation);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

饭团 2025-01-15 01:26:44

您有两个问题:

  1. 2 不是模 31 的原根,因此您的“g”不是乘法组的生成器。您可以使用 3 代替。

  2. 看起来有人在解释 Blaze、Bleumer & 时犯了一个错误。施特劳斯。您需要计算 b/a 模 phi(q) 而不是模 q。然后您可以使用欧拉定理来证明重新加密是有效的。当 a^-1 以 q 为模计算时,(g^a)^(a^-1)=g (mod q) 是不正确的。这也意味着 sk_a 和 sk_b 应该与 phi(q) 互质。尝试使用 7 和 11 代替。

以下内容应该按您的预期工作:

BigInteger q = new BigInteger("31");
BigInteger phi = new BigInteger("30");

BigInteger g = new BigInteger("3");
BigInteger sk_a = new BigInteger("7");
BigInteger sk_b = new BigInteger("11");

BigInteger proxy_key = sk_b.multiply(sk_a.modInverse(phi)).mod(phi);

BigInteger y = g.modPow(sk_a, q);
System.out.println("Cipher Text: " + y);

BigInteger transformation = y.modPow(proxy_key, q);
System.out.println("Cipher Text Transformation: " + transformation);

You have two problems:

  1. 2 is not a primitive root modulo 31, so your "g" is not a generator for the multiplicative group. You can use 3 instead.

  2. It looks like somebody made a mistake when explaining Blaze, Bleumer & Strauss. You need to calculate b/a modulo phi(q) instead of modulo q. Then you can use Euler's theorem to show that the reencryption works. It is not true that (g^a)^(a^-1)=g (mod q) when a^-1 is calculated modulo q. This also means that sk_a and sk_b should be relatively prime to phi(q). Try using 7 and 11 instead.

The following should work as you expect:

BigInteger q = new BigInteger("31");
BigInteger phi = new BigInteger("30");

BigInteger g = new BigInteger("3");
BigInteger sk_a = new BigInteger("7");
BigInteger sk_b = new BigInteger("11");

BigInteger proxy_key = sk_b.multiply(sk_a.modInverse(phi)).mod(phi);

BigInteger y = g.modPow(sk_a, q);
System.out.println("Cipher Text: " + y);

BigInteger transformation = y.modPow(proxy_key, q);
System.out.println("Cipher Text Transformation: " + transformation);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文