Java 实现分布式双门陷公钥密码系统(DT-PKC)

一、密钥生成

1. 方案密钥构造

DT-PKC-Keygen

2. Key Generation代码

 /**
 ** User/Requester generate (pk,sk) pair
 */
public static void KeyGen() {
    BigInteger tmp_lamda = Utils.LCM(q1.subtract(BigInteger.ONE),q2.subtract(BigInteger.ONE));
    lamda = tmp_lamda.divide(BigInteger.valueOf(2));
    ski_thetai = new BigInteger[NUM_USER+1]; //The last one stands for requester
    hi = new BigInteger[NUM_USER+1];//Index NUM_USER stands for the requester
    for(int i=0; i<NUM_USER+1; i++) {
        BigInteger tmp_ski = Utils.getRangeRandom(n.divide(BigInteger.valueOf(4))).add(BigInteger.ONE);
        ski_thetai[i] = tmp_ski;
        hi[i] = g.modPow(tmp_ski, n_squre);
    }
}

/**
 ** System initialization
 ** Generate q1, q2, n, g
 */
public static void setup() {
    q1 = Utils.getPrimeRandom(secure_k);
    q2 = Utils.getPrimeRandom(secure_k);
    n = q1.multiply(q2);
    n_squre = n.multiply(n);
    //g = n.add(BigInteger.ONE);
    //g = Utils.getRangeRandom(n_squre);
    g = Utils.getRangeRandom(n_squre).add(BigInteger.ONE).modPow(BigInteger.valueOf(2).multiply(n), n_squre).negate();
    //System.out.println("g="+g);
}

二、加密

1. 加密过程

DT-PKC-Encrypt

2. Encryption代码

 /**
 * Run encryption operation
 * @param:
 * 		message
 * 		pki
 * @return:
 * 		ci1,ci2
 */
public static Cipher encrypt(BigInteger message, BigInteger pki) {
    Cipher cipher = new Cipher();
    BigInteger tmp_ri = Utils.getRangeRandom(n.divide(BigInteger.valueOf(4))).add(BigInteger.ONE);
    BigInteger ci1_left = pki.modPow(tmp_ri, n_squre);
    BigInteger ci2_right = n.add(BigInteger.ONE).modPow(message, n_squre);
    cipher.setCi1(ci1_left.multiply(ci2_right).mod(n_squre));
    cipher.setCi2(g.modPow(tmp_ri, n_squre));
    return cipher;
}

三、弱私钥解密

1. 使用弱私钥解密过程

DT-PKC-WeakDecrypt

2. Weak Decryption 代码

 /**
  *Weak decryption
  * @param:
  * 		ski
  * 		ci1
  * 		ci2
  * @return:
  *		out_weak
  */
 public static BigInteger weak_Decrypt(BigInteger ski, BigInteger ci1, BigInteger ci2) {
     BigInteger tmpDown = ci2.modPow(ski, n_squre).modInverse(n_squre);
     BigInteger out_weak = ci1.multiply(tmpDown).mod(n_squre).subtract(BigInteger.ONE).divide(n);
     return out_weak;
 }

四、强私钥解密

1. 强私钥解密过程

DT-PKC-StrongDecrypt

2. Strong Decryption代码

omit...

五、强私钥分割

1. 强私钥分割过程

DT-PKC-StrongKeySplit

2. Strong Key Split代码

/**
 ** Generate partial private key lamda1 and lamda2
 */
public static void SkeyS() {
    BigInteger lamda_inverse = lamda.modInverse(n_squre);
    lamda1 = Utils.getRangeRandom(lamda_inverse);
    lamda2 = lamda_inverse.multiply(lamda).subtract(lamda1);
}

六、部分解密

1. 部分解密1

过程

DT-PKC-PartialDecrypt1

Partial Decryption 1代码
 /**
  * @param cipher
  * @return psd1_out
  */
 public static BigInteger PSD1(Result cipher) {
     BigInteger psd1_out = cipher.getCi1().modPow(lamda1, n_squre);
     return psd1_out;
 }

2. 部分解密2

过程

DT-PKC-ParitalDecrypt2

Partial Decryption 2代码
 /**
  *
  * @param cipher
  * @param psd1_out
  * @return psd2_out
  */
 public static BigInteger PSD2(Result cipher, BigInteger psd1_out) {

     BigInteger tmp = cipher.getCi1().modPow(lamda2, n_squre);
     BigInteger tmp_cipher = tmp.multiply(psd1_out).mod(n_squre);
     BigInteger psd2_out = tmp_cipher.subtract(BigInteger.ONE).divide(n);
     return psd2_out;
 }

七、DT-PKC的同态特性

DT-PKC-Homo

omit...

参考文献

[1] 2016-TIFS-An Efficient Privacy-Preserving Outsourced Calculation Toolkit With Multiple Keys

  • 3
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值