javallier-master
所属分类:加密解密
开发工具:Java
文件大小:109KB
下载次数:10
上传日期:2017-08-06 18:56:57
上 传 者:
啊哈啦里
说明: paillier 加密系统,实现同态加密解密
(paillier encryptedPaillier encryption system, the realization of homomorphic encryption)
文件列表:
.travis.yml (1127, 2017-02-16)
CHANGELOG (1166, 2017-02-16)
LICENSE.txt (10428, 2017-02-16)
benchmark (0, 2017-02-16)
benchmark\src (0, 2017-02-16)
benchmark\src\main (0, 2017-02-16)
benchmark\src\main\java (0, 2017-02-16)
benchmark\src\main\java\com (0, 2017-02-16)
benchmark\src\main\java\com\n1analytics (0, 2017-02-16)
benchmark\src\main\java\com\n1analytics\paillier (0, 2017-02-16)
benchmark\src\main\java\com\n1analytics\paillier\JavallierBenchmark.java (4147, 2017-02-16)
build.sbt (2787, 2017-02-16)
examples (0, 2017-02-16)
examples\fixedpointdecoding (0, 2017-02-16)
examples\fixedpointdecoding\src (0, 2017-02-16)
examples\fixedpointdecoding\src\main (0, 2017-02-16)
examples\fixedpointdecoding\src\main\java (0, 2017-02-16)
examples\fixedpointdecoding\src\main\java\examples (0, 2017-02-16)
examples\fixedpointdecoding\src\main\java\examples\fixedpointdecoding (0, 2017-02-16)
examples\fixedpointdecoding\src\main\java\examples\fixedpointdecoding\FixedPoint.java (4962, 2017-02-16)
examples\fixedpointdecoding\src\main\java\examples\fixedpointdecoding\Main.java (6336, 2017-02-16)
examples\privateSum (0, 2017-02-16)
examples\privateSum\build.sbt (163, 2017-02-16)
examples\privateSum\src (0, 2017-02-16)
examples\privateSum\src\main (0, 2017-02-16)
examples\privateSum\src\main\scala (0, 2017-02-16)
examples\privateSum\src\main\scala\PrivateSum.scala (1290, 2017-02-16)
project (0, 2017-02-16)
project\assembly.sbt (56, 2017-02-16)
project\plugins.sbt (249, 2017-02-16)
src (0, 2017-02-16)
src\main (0, 2017-02-16)
src\main\java (0, 2017-02-16)
src\main\java\com (0, 2017-02-16)
src\main\java\com\n1analytics (0, 2017-02-16)
src\main\java\com\n1analytics\paillier (0, 2017-02-16)
... ...
[![Build Status](https://travis-ci.org/n1analytics/javallier.svg?branch=master)](https://travis-ci.org/n1analytics/javallier) [![Javadocs](https://www.javadoc.io/badge/com.n1analytics/javallier_2.10.svg)](https://www.javadoc.io/doc/com.n1analytics/javallier_2.10)
# javallier
A Java library for [Paillier partially homomorphic encryption](https://en.wikipedia.org/wiki/Paillier_cryptosystem)
based on [python-paillier](https://github.com/NICTA/python-paillier).
The homomorphic properties of the paillier cryptosystem are:
- Encrypted numbers can be multiplied by a non encrypted scalar.
- Encrypted numbers can be added together.
- Encrypted numbers can be added to non encrypted scalars.
To use the library add the following dependency to your SBT configuration:
libraryDependencies += "com.n1analytics" % "javallier_2.10" % "0.6.0"
Example usages are provided in the `/examples` source directory. A
benchmarking script can be found in `/benchmark`.
## Build
Compile the library:
$ sbt compile
Create a jar file:
$ sbt package
Run all tests with `sbt`:
$ sbt test
Or run just fast tests:
$ ./test-fast.sh
## Command Line Tool
A small command line tool has been created to wrap the `javallier` library.
Use the `javallier` cli tool to:
- generate and serialize key pairs (of different key sizes)
- encrypt and serialize signed floating point numbers given a public key
- add two encrypted numbers together
- add an encrypted number to a plaintext number
- multiply an encrypted number by a plaintext number
- decrypt an encrypted number given the private key
Build the `javallier` CLI tool:
sbt assembly
This creates a `javallier.jar` jar file in:
./target/scala-2.10
To run it:
java -jar javallier.jar
Alternatively you can run directly with sbt:
sbt "runMain com.n1analytics.paillier.cli.Main"
### Example CLI session
$ java -jar javallier.jar genpkey --keysize 256 -m "Example keypair" examplekey.priv
$ cat examplekey.priv | python -m json.tool
{
"kty": "DAJ",
"key_ops": [
"decrypt"
],
"pub": {
"alg": "PAI-GN1",
"kty": "DAJ",
"kid": "Example keypair",
"n": "AI9TjNmoL7p3j_D-RNK5AJQC1uDMtVvdy0MNi6ctj6Xn",
"key_ops": [
"encrypt"
]
},
"kid": "Example keypair",
"lambda": "AI9TjNmoL7p3j_D-RNK5AJJ3odV_yUj39nLtFBMcrsoQ",
"mu": "MDo136LqeN-R5W4kT2azGc6Y-cD77f6r_B6zncj48Eo"
}
$ java -jar javallier.jar extract examplekey.priv examplekey.pub
$ java -jar javallier.jar encrypt examplekey.pub "12" -o encA.json
$ java -jar javallier.jar encrypt examplekey.pub "8" -o encB.json
$ java -jar javallier.jar addenc examplekey.pub encA.json encB.json -o encC.json
$ java -jar javallier.jar decrypt examplekey.priv encC.json
20.0
$ java -jar javallier.jar add -o encD.json examplekey.pub encA.json 12
$ java -jar javallier.jar decrypt examplekey.priv encD.json
24.0
## Releases
Releases will be signed by [Brian Thorne](https://keybase.io/hardbyte) with the PGP key
[22AD F3BF C183 47DE](https://pgp.mit.edu/pks/lookup?op=vindex&search=0x22ADF3BFC18347DE)
### Creating a release
Update the version in `build.sbt` using [semantic versioning](http://semver.org/).
Update the [CHANGELOG](./CHANGELOG), git tag the new release.
Ensure you have sonatype credentials in `~/.sbt/0.13/sonatype.sbt`, and
[install the pgp plugin](http://www.scala-sbt.org/sbt-pgp/)
(`~/.sbt/0.13/plugins/pgp.sbt`). Run `sbt publishSigned`, then visit the
[staging repositories](https://oss.sonatype.org/#stagingRepositories) of
sonatype. **Close** the staging repository which will allow you to move
to the release channel. Once you have successfully closed the staging
repository, you can **release** it.
For more information:
* http://www.scala-sbt.org/release/docs/Using-Sonatype.html
* http://central.sonatype.org/pages/releasing-the-deployment.html
## Limitation
Adding two encrypted numbers where the exponents differs wildly may result in overflow
in the `EncryptedNumber` domain. The addition result can be successfully decrypted and
decoded but the computation result is incorrect. Current implementation does not detect
such overflow.
近期下载者:
相关文件:
收藏者: