Skip to content
New issue

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

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

Already on GitHub? # to your account

Update bundle 06 #153

Merged
merged 9 commits into from
Dec 16, 2024
Merged

Update bundle 06 #153

merged 9 commits into from
Dec 16, 2024

Conversation

immortal-tofu
Copy link
Collaborator

@immortal-tofu immortal-tofu commented Dec 16, 2024

Allow usage of bundle directly through a CDN to simplify a lot usage with Next or any framework

For example like this:

<html>
  <head>
    <title>Demo</title>
    <script src="https://cdn.zama.ai/fhevmjs/0.6.2/fhevmjs.umd.cjs"></script>
    <script>
      window.fhevmjs.initFhevm();
      const i = await window.fhevmjs.createInstance({
        network: window.ethereum,
        kmsContractAddress: '0x904Af2B61068f686838bD6257E385C2cE7a09195',
        aclContractAddress: '0x9479B455904dCccCf8Bc4f7dF8e9A1105cBa2A8e',
        gatewayUrl: 'https://gateway.sepolia.zama.ai',
      });
      const input = i.createEncryptedInput(
        '0x9479B455904dCccCf8Bc4f7dF8e9A1105cBa2A8e',
        '0x9479B455904dCccCf8Bc4f7dF8e9A1105cBa2A8e'
      );
    </script>
  </head>
  <body>
    Hello
  </body>
</html>

Include also a bundle export to use the package like this:

import { initFhevm, createInstance, FhevmInstance } from 'fhevmjs/bundle';

Under the hood, it will get functions from window object.

Rework also the bundle: wasm is now separate from JS which reduce a lot filesizes.

It will be used for React template and Vue template since it's more optimized than trying to fit the 2 wasm and webworkers in the build.

@immortal-tofu immortal-tofu merged commit b7a5104 into main Dec 16, 2024
4 checks passed
@jatZama
Copy link
Member

jatZama commented Dec 19, 2024

I just noticed in your message you use same address for both user and contract addresses in:

const input = i.createEncryptedInput(
        '0x9479B455904dCccCf8Bc4f7dF8e9A1105cBa2A8e',
        '0x9479B455904dCccCf8Bc4f7dF8e9A1105cBa2A8e'
      );

And also this address is equal to the acl address, please this should be avoided for readability . I also stumbled on similar issue when i developped the react template with mocked mode, you used almost same address twice for reencrypt there. This makes it hard to read. Use clear different addresses.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants