s0l0ist/node-seal
소개
Homomorphic Encryption for TypeScript or JavaScript - Microsoft SEAL
보안 및 개인정보 보호측정된 스타 증가
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- 0
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
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.
관련 프로젝트 살펴보기
불러오는 중…