# Homomorphic Encryption
[![Build Gradle project](https://github.com/AndrewQuijano/Homomorphic_Encryption/actions/workflows/build-gradle-project.yml/badge.svg)](https://github.com/AndrewQuijano/Homomorphic_Encryption/actions/workflows/build-gradle-project.yml)
[![codecov](https://codecov.io/gh/AndrewQuijano/Homomorphic_Encryption/branch/master/graph/badge.svg?token=OIFWDVX2SA)](https://codecov.io/gh/AndrewQuijano/Homomorphic_Encryption)
Homomorphic Encryption is a Java library that implements the following partially homomorphic encryption systems:
* Paillier
* El-Gamal (Additive or multiplicative)
* Goldwasser-Micali
* DGK
As the partially homomorphic encryption systems only support addition with two ciphertexts, other protocols been appended to extend its functionality, in particular:
* Secure Multiplication
* Secure Division
* Secure Comparison
## Installation
Please retrieve the JAR file from [here](https://github.com/AndrewQuijano/Homomorphic_Encryption/tags)
As this library uses Java 8, the JAR file can be imported into an Android project.
If you want to review/edit the library, import the JAVA_PHE directory into a Eclipse project and edit as necessary. The Main.java folder only exists for testing and provide examples of how to use the library.
## Usage
Import the packages as necessary. For basic usage please check Server.java in the test package for basic usage of these cryptography libraries.
Please view Client.java and Server.java for an example how to compare encrypted numbers, secure multiplication, secure division, etc.
# security.socialistmillionaire.alice
**Initialize**
```java
alice Niu = new alice(new Socket("192.168.1.208", 9254));
// These Public Keys are made by Bob and automatically sent to Alice.
PaillierPublicKey pk = Niu.getPaillierPublicKey();
DGKPublicKey pubKey = Niu.getDGKPublicKey();
ElGamalPublicKey e_pk = Niu.getElGamalPublicKey();
```
**Protocol1(x)**
See Protocol 1 in "Improving the DGK comparison protocol" in Alice section.
Compare with plaintext value y Bob has.
* Parameters
* plaintext (**BigInteger**)
* Returns
* value (**boolean**) - x <= y
* Raises (**HomomorphicException**)
* If the plaintext has more bits than what the DGK public key supports.
**Protocol2(x, y)**
See Protocol 2 in "Improving the DGK comparison protocol" in Alice section.
* Parameters
* x (**BigInteger**) - a Paillier/DGK encrypted value
* y (**BigInteger**) - a Paillier/DGK encrypted value
* Returns
* value (**boolean**) - x >= y
* Raises (**HomomorphicException**)
* N/A
**Protocol3(x)**
See Protocol 3 in "Improving the DGK comparison protocol" in Alice section. Compare with plaintext value y held by bob
* Parameters
* x (**BigInteger**) - plaintext
* Returns
* value (**boolean**) - x <= y
* Raises (**HomomorphicException**)
* If the plaintext has more bits than what the DGK public key supports
**Modified_Protocol3(x)**
See Protocol 3 in "Correction to 'Improving the DGK comparison protocol'" in Alice section. View the sub-protocol.
* Parameters
* x (**BigInteger**) - plaintext
* Returns
* value (**boolean**) - x <= y
* Raises (**HomomorphicException**)
* N/A
**Protocol4(x, y)**
See Protocol 3 in "Correct to 'Improving the DGK comparison protocol'" in Alice section.
* Parameters
* x (**BigInteger**) - Paillier or DGK encrypted value
* y (**BigInteger**) - Paillier or DGK encrypted value
* Returns
* value (**boolean**) - x >= y
* Raises (**HomomorphicException**)
*
```java
BigInteger x = new BigInteger("50");
BigInteger y = new BigInteger("51");
// Note: Assume bob is sharing y = new BigIntger("55");
Niu.Protocol1(x); // TRUE, X <= Y
Niu.Protocol3(x);// TRUE X <= Y
Niu.Modified_Protocol3(x); // TRUE X <= Y
// Note: Protocol 2 only works with Paillier encrypted values!
// Note: Protocol 2/4 works with Paillier/DGK encrypted values!
x = PaillierCipher.encrypt(x, pk);
y = PaillierCipher.encrypt(y, pk);
Niu.Protocol2(x, y); // FALSE, b.c X >= Y is FALSE
Niu.Protocol4(x, y); // FALSE: b.c X >= Y is FALSE
```
**division(x, y)**
Please review Protocol 2 in the "Encrypted Integer Division" paper by Thjis Veugen
* Parameters
* x (**BigInteger**) - Paillier or DGK encrypted value
* d (**BigInteger**) - plaintext value
* Returns
* ciphertext (**BigInteger**) - x/d
* Raises (**HomomorphicException**)
* Constraints: 0 <= x <= N * 2^{-sigma} and 0 <= d < N
**multiplication(x, y)**
* Parameters
* x (**BigInteger**) - Paillier or DGK encrypted value
* y (**BigInteger**) - Paillier or DGK encrypted value
* Returns
* ciphertext (**BigInteger**) - x * y
* Raises (**HomomorphicException**)
* Constraints: 0 <= x <= N * 2^{-sigma} and 0 <= d < N
**bubbleSort(arr)**
* Parameters
* arr (**BigInteger**) - List of Paillier or DGK encrypted value
* Returns
* N/A - arr is list of sorted encrypted values from low to high
* Raises (**HomomorphicException**)
* N/A
**getKMax(arr, k)**
* Parameters
* arr (**List<BigInteger>**) - List of Paillier or DGK encrypted value
* k - get number of k largest encrypted numbers
* Returns
* a (**List<BigInteger>**) - new array of size k sorted from low to high
* Raises (**HomomorphicException**)
* N/A
**getKMin(arr, k)**
* Parameters
* arr (**List<BigInteger>**) - List of Paillier or DGK encrypted value
* k - get number of k smallest encrypted numbers
* Returns
* a (**List<BigInteger>**) - new array of size k sorted from low to high
* Raises (**HomomorphicException**)
* N/A
# security.socialistmillionaire.bob
**Initialize**
```java
ServerSocket bob_socket = null;
Socket bob_client = null;
int KEY_SIZE = 1024;
bob andrew = null;
// Build all Key Pairs
PaillierKeyPairGenerator p = new PaillierKeyPairGenerator();
p.initialize(KEY_SIZE, null);
KeyPair pe = p.generateKeyPair();
DGKKeyPairGenerator d = new DGKKeyPairGenerator();
d.initialize(KEY_SIZE, null);
KeyPair DGK = d.generateKeyPair();
ElGamalKeyPairGenerator pg = new ElGamalKeyPairGenerator();
pg.initialize(KEY_SIZE, new SecureRandom());
KeyPair el_gamal = pg.generateKeyPair();
bob_socket = new ServerSocket(9254);
bob_client = bob_socket.accept();
// Note: Alice automatically gets the public keys!
andrew = new bob(bob_client, pe, DGK, el_gamal);
```
**Protocol1(y)**
See Protocol 1 in "Improving the DGK comparison protocol" in Bob section.
Compare with plaintext value y Bob has.
* Parameters
* plaintext (**BigInteger**)
* Returns
* value (**boolean**) - x <= y
* Raises (**HomomorphicException**)
* If the plaintext has more bits than what the DGK public key supports.
**Protocol2()**
See Protocol 2 in "Improving the DGK comparison protocol" in Bob section.
* Parameters
* N/A
* Returns
* value (**boolean**) - x >= y
* Raises (**HomomorphicException**)
* N/A
**Protocol3(y)**
See Protocol 3 in "Improving the DGK comparison protocol" in Bob section. Compare with plaintext value y held by bob
* Parameters
* y (**BigInteger**) - plaintext
* Returns
* value (**boolean**) - x <= y
* Raises (**HomomorphicException**)
* If the plaintext has more bits than what the DGK public key supports
**Modified_Protocol3(y)**
See Protocol 3 in "Correction to 'Improving the DGK comparison protocol'" in Bob section. View the sub-protocol.
* Parameters
* y (**BigInteger**) - plaintext
* Returns
* value (**boolean**) - x <= y
* Raises (**HomomorphicException**)
* N/A
**Protocol4()**
See Protocol 3 in "Correct to 'Improving the DGK comparison protocol'" in Bob section.
* Parameters
* N/A
* Returns
* value (**boolean**) - x >= y
* Raises (**HomomorphicException**)
*
```java
```
**division(x, y)**
Please review Protocol 2 in the "Encrypted Integer Division" paper by Thjis Veugen
* Parameters
* d (**BigInteger**) - plaintext value
* Returns
* N/A
* Raises (**HomomorphicException**)
* Constraints: 0 <= x <= N * 2^{-sigma
没有合适的资源?快使用搜索试试~ 我知道了~
包含ElGamal、Paillier、Goldweiser-Micali和DGK同态加密系统.zip
共58个文件
java:34个
pdf:9个
gitignore:2个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
5星 · 超过95%的资源 1 下载量 11 浏览量
2023-03-23
21:11:14
上传
评论
收藏 5.92MB ZIP 举报
温馨提示
包含ElGamal、Paillier、Goldweiser-Micali和DGK同态加密系统的软件包。还实现安全的乘法、除法和比较。
资源推荐
资源详情
资源评论
收起资源包目录
包含ElGamal、Paillier、Goldweiser-Micali和DGK同态加密系统的软件包。还实现安全的乘法、除法和比较。.zip (58个子文件)
Homomorphic_Encryption-master
Homomorphic_Encryption_Library_Performance.pdf 123KB
.github
workflows
build-gradle-project.yml 372B
LICENSE 1KB
Java_PHE
gradle
wrapper
gradle-wrapper.jar 54KB
gradle-wrapper.properties 200B
.classpath 805B
.settings
org.eclipse.buildship.core.prefs 317B
org.eclipse.jdt.core.prefs 357B
src
test
java
test
StressTest.java 20KB
Bob.java 5KB
LibraryTesting.java 9KB
Alice.java 11KB
main
java
security
misc
HomomorphicException.java 266B
CipherConstants.java 1KB
NTL.java 5KB
gm
GMKey.java 107B
GMPrivateKey.java 687B
GMKeyPairGenerator.java 1013B
GMCipher.java 15KB
GMPublicKey.java 621B
paillier
PaillierKey.java 152B
PaillierPublicKey.java 2KB
PaillierPrivateKey.java 4KB
PaillierKeyPairGenerator.java 3KB
PaillierSignature.java 6KB
PaillierCipher.java 24KB
elgamal
ElGamalCipher.java 18KB
ElGamalPublicKey.java 1KB
ElGamalKeyPairGenerator.java 3KB
ElGamal_Ciphertext.java 541B
ElGamalSignature.java 6KB
ElGamalPrivateKey.java 3KB
ElGamal_Key.java 118B
socialistmillionaire
socialist_millionaires.java 3KB
alice.java 51KB
bob.java 26KB
DGK
DGKKeyPairGenerator.java 8KB
DGKPrivateKey.java 3KB
DGKSignature.java 4KB
DGKPublicKey.java 3KB
DGK_Key.java 157B
DGKOperations.java 23KB
gradlew.bat 3KB
build.gradle 909B
settings.gradle 369B
gradlew 6KB
.project 629B
.gitignore 110B
.gitignore 326B
Papers
Division.pdf 167KB
2007-Efficient and Secure Comparison for On-Line Auctions.pdf 349KB
Correction_to_Improving_DGK_Comparison.pdf 247KB
2009-A correction to efficient and secure comparison for on-line auctions.pdf 751KB
Paillier1999_Chapter_Public-KeyCryptosystemsBasedOn.pdf 291KB
Comparison_Protocols.pdf 1.35MB
ElGamal.pdf 261KB
Mau_Correction_to_DGK_Comparison_Protocols.pdf 2.55MB
README.md 32KB
共 58 条
- 1
资源评论
- m0_462365222023-10-25资源不错,对我启发很大,获得了新的灵感,受益匪浅。
快撑死的鱼
- 粉丝: 1w+
- 资源: 9154
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- html动态爱心代码一(附源码)
- c40539bc-071a-486c-9d52-9d0c18d62dac 4.html
- 基于物理的非视域成像(NLOS)算法,利用了nerf+python源码+文档说明
- yuluer知更鸟.7z(1).001
- 基于Qt实现医院信息管理系统c++源码+文档说明+数据库(期末大作业)
- 基于python实现的医院信息管理系统完整源码+sql数据库+详细注释(高分课程设计)
- 基于python的眼底图像视杯视盘分割项目源码+文档说明+截图演示+详细注释(高分课程设计)
- ImageBasedModellingEdu-贰壹贰叁零
- DFFmeasurement-数据预处理
- ImageBasedModellingEdu-回文素数c语言
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功