Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix JS publishing #142

Merged
merged 1 commit into from
Dec 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 33 additions & 15 deletions private_set_intersection/javascript/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@

# PSI - JavaScript

Private Set Intersection protocol based on ECDH, Bloom Filters, and Golomb Compressed Sets. The goal of this library is to allow a server to compute and return the intersection or intersection size (cardinality) from a set on the server and a set from a client without the server learning anything about the client's set.
Private Set Intersection protocol based on ECDH, Bloom Filters, and Golomb
Compressed Sets. The goal of this library is to allow a server to compute and
return the intersection or intersection size (cardinality) from a set on the
server and a set from a client without the server learning anything about the
client's set.

- 💾 Low memory footprint
- 🚀 Fastest implementation using WebAssembly
- 🔥 Works in any client / server configuration, even [React Native](https://reactnative.dev/)!
- 🔥 Works in any client / server configuration, even [React
Native](https://reactnative.dev/)!
- 😎 Privacy preserving

## Installation
Expand All @@ -33,10 +38,11 @@ import PSI from '@openmined/psi.js'
const PSI = require('@openmined/psi.js')
```

By **default**, the package will use the `psi` build with the `wasm` targeting the `node` environment.
By **default**, the package will use the `psi` build with the `wasm` targeting
the `node` environment.

The deep import structure is as follows:
`<package name> / <psi>_<wasm>_<node|web|worker>`
The deep import structure is as follows: `<package name> /
<psi>_<wasm>_<node|web|worker>`

Example:

Expand All @@ -48,7 +54,13 @@ import PSI from '@openmined/psi.js/psi_wasm_worker.js'

## React-Native

The bundle needs a bit of extra work. Specifically, it expects the browser `crypto.getRandomValues` which it will not find by default as react-native doesn't support the crypto builtin. It can be fixed by `npm install react-native-get-random-values` which provides access to this global while supporting a CSPRNG. The library also needs to have the browser `document` which is an artifact from the build system. Simply provide `global.document = {}`. Finally, it requires the following deep import structure:
The bundle needs a bit of extra work. Specifically, it expects the browser
`crypto.getRandomValues` which it will not find by default as react-native
doesn't support the crypto builtin. It can be fixed by `npm install
react-native-get-random-values` which provides access to this global while
supporting a CSPRNG. The library also needs to have the browser `document` which
is an artifact from the build system. Simply provide `global.document = {}`.
Finally, it requires the following deep import structure:

```javascript
// Provide a CSPRNG mapping to crypto.getRandomValues()
Expand All @@ -72,7 +84,8 @@ We show an example following the steps:

1. Initialize the server and create the `server setup` to be sent later
2. Initialize the client and create a client `request` to be sent to the server
3. Process the `request` and send both the `server setup` and `response` to the client
3. Process the `request` and send both the `server setup` and `response` to the
client
4. Client receives the `setup` and `response` and computes the intersection

```javascript
Expand Down Expand Up @@ -211,11 +224,13 @@ const PSI = require('@openmined/psi.js')

## Contributors

See [CONTRIBUTORS.md](https://github.com/OpenMined/PSI/blob/master/CONTRIBUTORS.md).
See
[CONTRIBUTORS.md](https://github.com/OpenMined/PSI/blob/master/CONTRIBUTORS.md).

## Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Pull requests are welcome. For major changes, please open an issue first to
discuss what you would like to change.

Please make sure to update tests as appropriate.

Expand All @@ -232,7 +247,8 @@ Now, install the rest of the dev dependencies
npm install
```

To compile the client, server, or psi (both client and server) for WebAssembly and pure JS
To compile the client, server, or psi (both client and server) for WebAssembly
and pure JS

```
npm run build
Expand All @@ -250,7 +266,8 @@ Compile TypeScript to JS (sanity checking)
npm run compile
```

Run the tests or generate coverage reports. **Note** tests are run using the WASM variant.
Run the tests or generate coverage reports. **Note** tests are run using the
WASM variant.

```
npm run test
Expand Down Expand Up @@ -313,10 +330,11 @@ Finally, publish the bundle

`npm run publish`

**Note**: The default `npm publish` has been disabled to prevent publishing of the entire project files.
Instead, we have a custom override which will publish the npm package from a specific directory.
This allows us to publish a single package with shortened deep import links that specify the
different targets listed above.
**Note**: The default `npm publish` has been disabled to prevent publishing of
the entire project files. Instead, we have a custom override which will publish
the npm package from a specific directory. This allows us to publish a single
package with shortened deep import links that specify the different targets
listed above.

## Changes

Expand Down
2 changes: 1 addition & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { terser } from 'rollup-plugin-terser'
import terser from '@rollup/plugin-terser'
import alias from '@rollup/plugin-alias'
import commonjs from '@rollup/plugin-commonjs'
import resolve from '@rollup/plugin-node-resolve'
Expand Down