-
Notifications
You must be signed in to change notification settings - Fork 27
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
[WIP] LitEncryption Module #130
base: feat/ssx-modules
Are you sure you want to change the base?
[WIP] LitEncryption Module #130
Conversation
* ssx design pattern * updated tests * added sdk test command * migrate SSX functions to UserAuthroization resource * updated UserAuthorization logic + tests * update tests * renamed resources to modules * setup SSX to import modules * include modules in ssx * correct typescript errors * add module dependencies to tests * cleanup * fix provider reference * remove ssx init + connected
* add signature encryption module * update tests * text box for ciphertext * made changes to extension to fix tests --------- Co-authored-by: franklovefrank <[email protected]>
* Signature Encryption Module (spruceid#113) * add signature encryption module * update tests * text box for ciphertext * made changes to extension to fix tests --------- Co-authored-by: franklovefrank <[email protected]> * added storage + datavault module * added datavault * added ssx-notepad-datavault * move from blob to json * encryption debugging changes * fix build error * updated example to use only datavault instead of server * updated storage module to use indexedDB instead of localstorage * prevent occasional install bug * update indexeddb usage * updated notepad example * remove examples from workspace due to installation issues * added helmet back for walleconnect * added mock indexeddb * cleanup * add missing dependencies for test * updated docstrings * Add examples to monorepo and fix notepad example build * Fix getSigner on tests * configurable store name * fixed tests --------- Co-authored-by: franklovefrank <[email protected]> Co-authored-by: Juliano <[email protected]>
test('Should be able to encrypt and decrypt a message', async () => { | ||
const message = 'Hello World'; | ||
const encryptedMessage = await encryption.encrypt(message); | ||
const decryptedMessage = await encryption.decrypt(encryptedMessage); | ||
expect(decryptedMessage).toEqual(message); | ||
const encryptedData = await encryption.encrypt({ | ||
content: message, | ||
accessControlConditions: LIT_ENCRYPTION_ACCESS_CONTROL_CONDITIONS | ||
}); | ||
const decryptedData = await encryption.decrypt({ | ||
...encryptedData, | ||
accessControlConditions: LIT_ENCRYPTION_ACCESS_CONTROL_CONDITIONS | ||
}); | ||
expect(decryptedData.decryptedString).toEqual(message); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the tests here, but I still have trouble with the crypto library. Left them disabled.
packages/ssx-sdk/src/ssx.ts
Outdated
if ( | ||
this.config?.modules?.encryption === true || | ||
(this.config?.modules?.encryption as SSXEncryptionModuleConfig)?.module === 'SignatureEncryption' | ||
) { | ||
this.encryption = new SignatureEncryption({}, this.userAuthorization); | ||
} else if ((this.config?.modules?.encryption as SSXEncryptionModuleConfig)?.module === 'LitEncryption') { | ||
this.encryption = new LitEncryption({}, this.userAuthorization); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a temporary approach until we define the way we configure the modules. I'm assuming SignatureEncryption as default
* @param chainId - Unique chain id. | ||
* @returns - The chain name follwing the Lit Protocol docs. | ||
*/ | ||
private getChainName = (chainId: number) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had to create this to translate chainId -> chain string followingLit supported chains.
// case ?: | ||
// return "cosmos"; | ||
// case ?: | ||
// return "kyve"; | ||
// case ?: | ||
// return "evmosCosmos"; | ||
// case ?: | ||
// return "evmosCosmosTestnet"; | ||
// case ?: | ||
// return "cheqd"; | ||
// case ?: | ||
// return "juno"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't find these chainIds
@@ -1,5 +1,6 @@ | |||
import * as jose from 'jose'; | |||
import { IUserAuthorization } from './UserAuthorization'; | |||
import { IUserAuthorization, UserAuthorization } from './UserAuthorization'; | |||
import * as LitJsSdk from '@lit-protocol/lit-node-client'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm receiving this warning after the compilation:
WARNING in ../../node_modules/@lit-protocol/ecdsa-sdk/src/lib/ecdsa-sdk.js 428:22-61
Critical dependency: the request of a dependency is an expression
@ ../../node_modules/@lit-protocol/ecdsa-sdk/src/index.js 4:21-47
@ ../../node_modules/@lit-protocol/crypto/src/lib/crypto.js 7:18-52
@ ../../node_modules/@lit-protocol/crypto/src/index.js 4:21-44
@ ../../node_modules/@lit-protocol/lit-node-client-nodejs/src/lib/lit-node-client-nodejs.js 9:17-48
@ ../../node_modules/@lit-protocol/lit-node-client-nodejs/src/index.js 6:29-68 18:21-60
@ ../../node_modules/@lit-protocol/lit-node-client/src/index.js 25:21-68
@ ./src/modules/Encryption.ts 37:30-70
@ ./src/modules/index.ts 20:13-36
@ ./src/index.ts 19:13-33
And this is generating a warning on ssx-test-dapp:
Compiled with warnings.
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
Search for the keywords to learn more about each warning.
To ignore, add // eslint-disable-next-line to the line before.
WARNING in ../../packages/ssx-sdk/dist/index.js 59504:80-87
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
webpack compiled with 1 warning
signedMessage: session.siwe, | ||
}; | ||
|
||
const { encryptedString, symmetricKey } = await LitJsSdk.encryptString(data.content) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm only encrypting strings here, but they have other methods to encrypt. We can add/change this call
Description
This adds support for the LitEncryption module.
Type
Diligence Checklist