s0l0ist/node-seal
关于
Homomorphic Encryption for TypeScript or JavaScript - Microsoft SEAL
安全与隐私实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- 0
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文node-seal
Homomorphic encryption for TypeScript and JavaScript, powered by Microsoft SEAL 4.7.2 and WebAssembly. Compute on encrypted data, then decrypt the result with the secret key.
Install
npm install node-seal
Quick start
This doubles three encrypted integers using BFV:
import SEAL from 'node-seal'
const seal = await SEAL()
const degree = 4096
const security = seal.SecLevelType.tc128
using parameters = new seal.EncryptionParameters(seal.SchemeType.bfv)
using coeffModulus = seal.CoeffModulus.BFVDefault(degree, security)
using plainModulus = seal.PlainModulus.Batching(degree, 20)
parameters.setPolyModulusDegree(degree)
parameters.setCoeffModulus(coeffModulus)
parameters.setPlainModulus(plainModulus)
using context = new seal.SEALContext(parameters, true, security)
if (!context.parametersSet()) {
throw new Error(context.parameterErrorMessage())
}
using keygen = new seal.KeyGenerator(context)
using publicKey = keygen.createPublicKey()
using secretKey = keygen.secretKey()
using encoder = new seal.BatchEncoder(context)
using encryptor = new seal.Encryptor(context, publicKey)
using evaluator = new seal.Evaluator(context)
using decryptor = new seal.Decryptor(context, secretKey)
using plain = new seal.Plaintext()
using cipher = new seal.Ciphertext()
encoder.encode(BigInt64Array.from([1n, 2n, 3n]), plain)
encryptor.encrypt(plain, cipher)
evaluator.addInplace(cipher, cipher)
decryptor.decrypt(cipher, plain)
console.log(Array.from(encoder.decodeBigInt64(plain).slice(0, 3)))
// [2n, 4n, 6n]
The examples use using to release native objects at scope exit. See
object lifetime for cleanup details.
Initialize once and reuse the SEAL instance.
Guides
- Getting started: encrypt, serialize, compute, and decrypt a result.
- Advanced usage: schemes, parameters, key generation, compact serialization, and performance choices.
Runtime
The package includes ES modules, Wasm binaries, and TypeScript declarations. The runtime needs WebAssembly exception handling and BigInt typed arrays. For bundlers that relocate the Wasm file, see Wasm deployment.
node-seal and node-seal/throws reject transparent ciphertext results.
Use node-seal/allows when your calculation needs those results, such as
subtracting a ciphertext from itself. Both variants expose the same API.
Reference
- Bindings and tests cover the available API.
- Microsoft SEAL examples explain the underlying library. Some C++ overloads are not available here.
- Contributing and release notes.
License
MIT.
探索相关项目
加载中…