{"id":29193188,"url":"https://github.com/ironcorelabs/recrypt-node-binding","last_synced_at":"2025-07-02T02:08:32.007Z","repository":{"id":33185757,"uuid":"150637551","full_name":"IronCoreLabs/recrypt-node-binding","owner":"IronCoreLabs","description":"Bindings from recrypt-rs to work with NodeJS","archived":false,"fork":false,"pushed_at":"2025-06-11T20:28:53.000Z","size":697,"stargazers_count":25,"open_issues_count":4,"forks_count":6,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-07-02T02:08:30.585Z","etag":null,"topics":["cryptography","nodejs","proxy-re-encryption","transform-encryption"],"latest_commit_sha":null,"homepage":"https://docs.ironcorelabs.com","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/IronCoreLabs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-09-27T19:27:20.000Z","updated_at":"2025-06-11T20:28:56.000Z","dependencies_parsed_at":"2023-01-14T23:49:47.534Z","dependency_job_id":"64ce819e-2643-4bfb-a542-b60862c2a811","html_url":"https://github.com/IronCoreLabs/recrypt-node-binding","commit_stats":{"total_commits":243,"total_committers":11,"mean_commits":22.09090909090909,"dds":0.3744855967078189,"last_synced_commit":"07f5075945193e2a59ba724d1fdd20ac1690bb53"},"previous_names":[],"tags_count":115,"template":false,"template_full_name":null,"purl":"pkg:github/IronCoreLabs/recrypt-node-binding","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IronCoreLabs%2Frecrypt-node-binding","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IronCoreLabs%2Frecrypt-node-binding/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IronCoreLabs%2Frecrypt-node-binding/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IronCoreLabs%2Frecrypt-node-binding/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/IronCoreLabs","download_url":"https://codeload.github.com/IronCoreLabs/recrypt-node-binding/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IronCoreLabs%2Frecrypt-node-binding/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263061405,"owners_count":23407606,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cryptography","nodejs","proxy-re-encryption","transform-encryption"],"created_at":"2025-07-02T02:08:30.277Z","updated_at":"2025-07-02T02:08:31.993Z","avatar_url":"https://github.com/IronCoreLabs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Recrypt Node Binding\n\n![Build Status](https://github.com/IronCoreLabs/recrypt-node-binding/actions/workflows/typescript-ci.yaml/badge.svg)\n[![NPM Version](https://badge.fury.io/js/%40ironcorelabs%2Frecrypt-node-binding.svg)](https://www.npmjs.com/package/@ironcorelabs/recrypt-node-binding)\n\nBindings to be able to use [Recrypt Rust](https://github.com/IronCoreLabs/recrypt-rs) from NodeJS code. Improves the performance of Recrypt operations by using native code.\n\nThis library uses the [Neon Bindings](https://www.neon-bindings.com) toolchain to compile the [Recrypt Rust](https://github.com/IronCoreLabs/recrypt-rs) library into a binary NodeJS file that can be used from Node applications. The Neon Bindings provide a way to write a shim which converts data in/out of the [Recrypt Rust](https://github.com/IronCoreLabs/recrypt-rs) code. The resulting binary Node file can then be included into a NodeJS module just like any other NPM dependency.\n\n## Supported Platforms\n\n|                         | Node 18 | Node 20 | Node 22 |\n| ----------------------- | ------- | ------- | ------- |\n| Linux x64 - glibc       | ✓       | ✓       | ✓       |\n| Linux x64 - musl-libc   | ✓       | ✓       | ✓       |\n| Linux arm64 - glibc     | ✓       | ✓       | ✓       |\n| Linux arm64 - musl-libc | ✓       | ✓       | ✓       |\n| OSX x64                 | ✓       | ✓       | ✓       |\n| OSX arm64               | ✓       | ✓       | ✓       |\n| Windows x64             | ✓       | ✓       | ✓       |\n\n## Install\n\n```\nnpm install @ironcorelabs/recrypt-node-binding\n```\n\nThe binary that is generated via the Neon Bindings toolchain is platform specific. We use the [`node-pre-gyp`](https://github.com/mapbox/node-pre-gyp) tool to pre-compile binaries for the most [popular platforms](https://github.com/IronCoreLabs/recrypt-node-binding#supported-platforms). When you `npm install` this library it will automatically pull down the proper binary for your platform from the binaries uploaded to the [releases page](https://github.com/IronCoreLabs/recrypt-node-binding/releases).\n\nThis means that you'll need to make sure that the machine that runs `npm install` is the machine where the code will run. This library will not work if you run `npm install` on an OSX machine and move the `node_modules` directory over to a Linux machine, for example.\n\nIf the machine you run `npm install` on is not one of the supported architectures you will get an install failure. If there's an architecture that you'd like supported that isn't yet available, [open a new issue](https://github.com/IronCoreLabs/recrypt-node-binding/issues/new) and we'll look into adding support for it. You can also build the bindings yourself to generate a binary file for whichever architecture you need. Refer to the [local development section](https://github.com/IronCoreLabs/recrypt-node-binding#local-development) for details.\n\n## Types\n\nThis library contains a [TypeScript definitions](index.d.ts) file which shows the available classes and methods.\n\n## Examples\n\nThe following examples show how to use this library from a NodeJS application\n\n#### Basic Encrypt/Decrypt Example\n\n```js\nconst assert = require(\"assert\");\nconst Recrypt = require(\"@ironcorelabs/recrypt-node-binding\");\n\n//Create a new Recrypt API instance\nconst Api256 = new Recrypt.Api256();\n\n//Generate both a user key pair and a signing key pair\nconst keys = Api256.generateKeyPair();\nconst signingKeys = Api256.generateEd25519KeyPair();\n\n//Generate a plaintext to encrypt\nconst plaintext = Api256.generatePlaintext();\n\n//Encrypt the data to the public key and then attempt to decrypt with the private key\nconst encryptedValue = Api256.encrypt(plaintext, keys.publicKey, signingKeys.privateKey);\nconst decryptedValue = Api256.decrypt(encryptedValue, keys.privateKey);\n\nassert.equal(decryptedValue, plaintext);\n```\n\n#### Single-hop Transform Encryption Example\n\n```js\nconst assert = require(\"assert\");\nconst Recrypt = require(\"@ironcorelabs/recrypt-node-binding\");\n\n//Create a new Recrypt API instance\nconst Api256 = new Recrypt.Api256();\n\n//Generate both a user key pair and a signing key pair\nconst userKeys = Api256.generateKeyPair();\nconst signingKeys = Api256.generateEd25519KeyPair();\n\n//Generate a plaintext to encrypt\nconst plaintext = Api256.generatePlaintext();\n\n//Encrypt the data to the user public key\nconst encryptedValue = Api256.encrypt(plaintext, userKeys.publicKey, signingKeys.privateKey);\n\n//Generate a second public/private key pair as the target of the transform. This will allow the encrypted data to be\n//transformed to this second key pair and allow it to be decrypted.\nconst deviceKeys = Api256.generateKeyPair();\n\n//Generate a transform key from the user private key to the device public key\nconst userToDeviceTransformKey = Api256.generateTransformKey(userKeys.privateKey, deviceKeys.publicKey, signingKeys.privateKey);\n\n//Transform the encrypted data (without decrypting it!) so that it can be decrypted with the second key pair\nconst transformedEncryptedValue = Api256.transform(encryptedValue, userToDeviceTransformKey, signingKeys.privateKey);\n\n//Decrypt the data using the second private key\nconst decryptedValue = Api256.decrypt(transformedEncryptedValue, deviceKeys.privateKey);\n\nassert.equal(decryptedValue, plaintext);\n```\n\n## Local Development\n\nIn order to build the binary Node file for Recrypt, you'll need the dependencies specified on the [Neon Bindings site](https://neon-bindings.com/docs/quick-start/). Follow their getting started directions and install Rust and the Node Build Tools. The Neon CLI is already installed as a dependency of this project so you don't have to install that as a global dependency.\n\nOnce all of those dependencies are installed, the following can be run.\n\n```\nnpm run compile\n```\n\nor\n\n```\nyarn compile\n```\n\nThis will produce an `index.node` file within the `bin-package` directory. This file can be used directly, or via index.js:\n\n```\nconst recrypt = require('index.js');\n```\n\n### Benchmarks\n\n-   From this repos root, run `npm i` or `yarn`.\n-   Run `npm/yarn run compile` to compile the Rust source into a `bin-package/index.node` module.\n-   Run `npm/yarn run benchmark`.\n\n### Unit Tests\n\n-   From this repos root, run `npm i` or `yarn`.\n-   Run `npm/yarn run compile` to compile the Rust source into a `bin-package/index.node` module.\n-   Run `npm/yarn run test`.\n\nCopyright (c) 2021 IronCore Labs, Inc.\nAll rights reserved.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fironcorelabs%2Frecrypt-node-binding","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fironcorelabs%2Frecrypt-node-binding","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fironcorelabs%2Frecrypt-node-binding/lists"}