s0l0ist/node-seal
À propos
Homomorphic Encryption for TypeScript or JavaScript - Microsoft SEAL
Sécurité et confidentialitéProgression mesurée des étoiles
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- 0
- in 1 month
- Historique en cours
Variations nettes sur des périodes qui se chevauchent, pas des totaux quotidiens. Les mesures absentes restent vides. Les étoiles indiquent l’intérêt, pas la qualité.
README.md
Originalnode-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.
Explorer des projets similaires
Chargement…