1.0.0 • Published 2 years ago

@safeheron/crypto-paillier v1.0.0

Weekly downloads
-
License
-
Repository
github
Last release
2 years ago

crypto-paillier-js

Installation

npm install @safeheron/crypto-paillier

Import the library in code:

import * as assert from "assert"
import * as BN from "bn.js"
import {Rand} from '@safeheron/crypto-rand'
import {PailPrivKey, PailPubKey, createPailKeyPair} from "@safeheron/crypto-paillier"

Examples

Encrypt and Decrypt

let m = await Rand.randomBNLt(pub.n)
let r = await Rand.randomBNLtGCD(pub.n)
let c = await pub.encryptWithR(m, r)
let expected = await priv.decrypt(c)
assert(m.eq(expected), "should equal")