-
Notifications
You must be signed in to change notification settings - Fork 23
/
README.md
104 lines (67 loc) · 2.12 KB
/
README.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# nucypher-ts
Communicate with NuCypher network from browser.
## Disclaimer
**This is a work in progress**
- SDK does not support policy revocation.
- We expect breaking changes.
## Supported networks
`nucypher-ts` is available on the following networks:
- Polygon
- Mumbai (Polygon testnet)
## Usage
Run with:
```bash
yarn install
yarn test
yarn build
```
## Development
Install git hooks
```bash
npx husky install
```
Generate contract typings
```bash
yarn typechain
```
Prepare a new release
```bash
yarn run prepare-release
```
## Publishing
Publish a new release on NPM.
Pay attention to output of these commands and fix your release if needed.
To build and publish a release, run
```bash
yarn prepare-release
# Or, to publish an alpha release
yarn prepare-release:alpha
```
Follow instructions from the command output to finalize the process.
## Examples
See `./test` directory for usage examples.
See `./examples` directory for examples of browser integration.
See `./examples/api-example.ts` for an abridged API example.
See [`nucypher-ts-demo`](https://github.com/nucypher/nucypher-ts-demo) for usage example with React app.
### Using Threshold Decryption
There are several schemes available for the user.
They follow a naming convention of `<NETWORK>-<M>-of-<N>`, where `M` is the threshold required, and `N` is the total size of the cohort.
`NETWORK` is either `mainnet` or `ibex`.
An encrypter can be created by:
```js
import { makeTDecEncrypter } from '@nucypher/nucypher-ts'
const encrypter = await makeTDecEncrypter("ibex-2-of-3");
```
The equivalent decrypter can be created by:
```js
import { makeTDecDecrypter } from '@nucypher/nucypher-ts'
// you can specify your own porter url here
const decrypter = await makeTDecDecrypter("ibex-2-of-3", "https://porter-ibex.nucypher.community")
```
Please note, the schemes for the encrypter and decrypter **must** match.
Encryption and decryption is then as simple as:
```js
const plaintext = toBytes('plaintext-message');
const encryptedMessageKit = encrypter.encryptMessage(plaintext);
const decryptedPlaintext = await decrypter.retrieveAndDecrypt([encryptedMessageKit]);
```