> For the complete documentation index, see [llms.txt](https://debitllama.gitbook.io/debitllama/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://debitllama.gitbook.io/debitllama/payment-intents/client-side-implementation.md).

# Client Side Implementation

### Creating and account

When you create an account you need to enter a good or strong password

The password is verified using zxcvbn which provides strong protection against password crackers!

When setting up an account the user supplied password is used to encrypt your account together with a public key. Your plaintext secret is never exposed to the server and it never leaves the scope of this function:

```javascript
export async function setUpAccount(
  password: string,
  ethEncryptPublicKey: string,
) {
  const note = newAccountSecrets();
  const secrets = decodeAccountSecrets(note);
  const commitment = toNoteHex(secrets.commitment);
  //Password encrypt the note!
  const passwdEncryptedNote = await aesEncryptData(note, password);
  //Encrypt the note with a public key
  const encryptedNote = await ethEncryptData(
    ethEncryptPublicKey,
    passwdEncryptedNote,
  );

  const packed = await packEncryptedMessage(encryptedNote);

  return { encryptedNote: packed, commitment };
```

The encrypted note is saved on-chain inside the smart contract. This same encryption method is in production in Tornado cash Note Accounts and was used here also.

### Checkout page&#x20;

The checkout page is a react application that will use the password to compute a ZKP and save the ZKP on the server. The server does Passkey verification before decrypting the secret with the asymmetric key, then it will forward it to the front end where it can be further decrypted to create the zkp:

```javascript
    const [password, setPassword] = useState("");
   .....
    async function payClicked() {

        const decryptedNote = await aesDecryptData(props.symmetricEncryptedNote, password);
        .... Error handling
        const paymentIntent = await createPaymentIntent({
            paymentIntentSecret: {
                note: decryptedNote,
                payee: props.itemData.payeeAddress,
                maxDebitAmount: parseEther(props.itemData.maxPrice),
                debitTimes: props.itemData.debitTimes,
                debitInterval: props.itemData.debitInterval
            },
            snarkArtifacts: {
                wasmFilePath: "/directDebit.wasm",
                zkeyFilePath: "/directDebit_final.zkey"
            }
       ..... Error Handling
        if (paymentIntent !== null) {

            await uploadPaymentIntent({
                button_id: props.itemData.buttonId,
                proof: JSON.stringify(paymentIntent.proof),
                publicSignals: JSON.stringify(paymentIntent.publicSignals),
                maxDebitAmount: props.itemData.maxPrice,
                debitTimes: props.itemData.debitTimes,
                debitInterval: props.itemData.debitInterval,
                paymentIntent: toNoteHex(paymentIntent.publicSignals[0]),
                commitment: toNoteHex(paymentIntent.publicSignals[1])

            }).then(async (status) => {
                if (status === 200) {
                    // Success is true!
                    setSuccess(true)
                    // Log out so the back button will not reload the page
                    await logoutRequest();
                    // navigate to the redirect page
                    setTimeout(() => {
                        redirectToRedirectPage(
                            props.itemData.redirectUrl,
                            toNoteHex(paymentIntent.publicSignals[0]));
                    }, 3000)
              .... Error handling
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://debitllama.gitbook.io/debitllama/payment-intents/client-side-implementation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
