> For the complete documentation index, see [llms.txt](https://docs.iadvize.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.iadvize.dev/use-cases/visitor-experience/authenticated-messaging/web-backend-implementation/signature-and-encryption-detailed-process.md).

# Signature and Encryption Detailed Process

## Key pair generation and sharing

<figure><img src="/files/vTSAVR0vOfy6g37sKVlM" alt=""><figcaption></figcaption></figure>

You will need to generate a key pair: a public key/private key. You will have to share your public key with iAdvize.\
iAdvize provides you with its public key.

One way to generate your keys (you can adjust the number of bits):

```
openssl genpkey -out rsaPrivateKey.pem -algorithm RSA -pkeyopt rsa_keygen_bits:2048
openssl rsa -in rsaPrivateKey.pem -pubout -out rsaPublicKey.pem
```

## Sign and encrypt

<figure><img src="/files/mi5U3cpdJcRYJN5Rahqf" alt=""><figcaption></figcaption></figure>

iAdvize will make the process the other way around which consist of decrypting the JWE (using iAdvize Private key) and verify the token signature (using Customer Public key) in order to finally extract the User ID and create a Visitor Authenticated Session (a new JWS generated by iAdvize internally):

<figure><img src="/files/4CDi70et1sCry0fSZzSl" alt=""><figcaption></figcaption></figure>

## iAdvize Public Key (use for production)

```
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA1KdAzuUa5rOXgLHavoDRYoNXzwWz/pFhgGypYFbvV8DNjB93XK2AzKTwW+vxT7RYl4f+sKLdEi3dJYgPt2hquhTNmFxAzRvTuolUOKr1XNx7QbDj+7cfLVDYjmds/ydNtyHi8TUHSvfzs8SGXO5E5H13llmayPEslHKShG0cLIDcLNr6hJcfv9fvOZqQlLQ4Bx7to/66IHke9zY+1oidrUdFGzxXG+RGK81mIMuXj6N2EGJ7YYcQqXJfBJnWFlSGCQNttw5Rfj00eZbkMRO3XohhNqGIiBG2tejSjfB53UpiHdbzni+tyB72R5aaq4d+gkkgaOVYn/Or2fArOH2FUQIDAQAB
```
