Skip to content

Commit 72dc0e6

Browse files
committed
Barely anything
1 parent 09081f4 commit 72dc0e6

1 file changed

Lines changed: 59 additions & 1 deletion

File tree

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,61 @@
11
# Migrating from `cofhejs`
22

3-
Install cofhesdk instead :D
3+
`cofhesdk` is an improved replacement for `cofhejs`. Improvements are focused around:
4+
- explicit api
5+
- developer experience
6+
- flexibility
7+
8+
### Key Changes:
9+
10+
- Functions are encapsulated in a new `client` class.
11+
- No longer need to wait for initialization (keys fetched during encrypt)
12+
- Permits must be explicitly generated, preventing unknown signature requests in users' wallets.
13+
- Top level configuration of cofhesdk behavior.
14+
- Explicit overrides and settings in `encryptInputs` and `decryptHandle` functions.
15+
- Better feedback and error handling in functions.
16+
- Better multichain usage
17+
18+
### Requirements:
19+
20+
- Node.js: 18+
21+
- React: 18+
22+
- TypeScript: 5+
23+
- Wagmi: 2+
24+
- Viem: 2+
25+
26+
### Installation:
27+
28+
```bash
29+
npm install @cofhe/sdk
30+
```
31+
32+
### Migration
33+
34+
#### Initializing the library
35+
36+
`cofhejs` is initialized with `cofhejs.initializeWithViem(...)`. Initialization involves fetching FHE keys, connecting to the supplied provider and signer, and
37+
`cofhesdk` encapsulates all functions in a new `client`, which is created with a `config` param
38+
39+
- link to config api for full breakdown of options
40+
41+
#### Encrypting inputs
42+
43+
- Why - more explicit, more customizable, loads keys during encrypt
44+
- Old - example (encrypt)
45+
- New - example (encryptInputs)
46+
- Customizable - setAccount, setChainId, setSecurityZone, setStepCallback
47+
48+
#### Decrypting handles
49+
50+
- Why - more explicit, more customizable
51+
- Old - example (unseal)
52+
- New - example (decryptHandle)
53+
- Customizable - setAccount, setChainId, setPermitHash, setPermit
54+
55+
#### Permits
56+
57+
- Why - Permits require a user signature (must be transparent and understandable), permits are complex with overlapping use cases, so a more explicit api was needed
58+
- Why - Better type safety
59+
- Old - example of auto-generation, example of usage in unseal
60+
- New - example of manual generation, example of usage in decryptHandle
61+
-

0 commit comments

Comments
 (0)