> For the complete documentation index, see [llms.txt](https://support.backpack.exchange/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://support.backpack.exchange/support-docs/vn/vi-wallet/tai-lieu-ky-thuat/deeplinks/ma-hoa.md).

# Mã Hóa

Deeplinks được mã hóa bằng mã hóa đối xứng được tạo từ trao đổi khóa [Diffie-Hellman key exchange](https://en.wikipedia.org/wiki/Diffie%E2%80%93Hellman_key_exchange). Trong khi các phiên deeplink sẽ được tạo ở dạng plaintext, một kênh mã hóa sẽ được tạo để ngăn chặn token phiên bị đánh cắp.

### Mã Hóa & Giải Mã Quy Trình Làm Việc <a href="#encryption-and-decryption-workflow" id="encryption-and-decryption-workflow"></a>

Backpack deeplinks được mã hóa theo quy trình sau:

#### Connect <a href="#connect" id="connect"></a>

1. \[dapp]: Trong deeplink `connect` ban đầu, ứng dụng nên bao gồm tham số truy vấn `dapp_encryption_public_key` . Khuyến nghị tạo một cặp khóa x25519 mới cho mỗi phiên được khởi tạo với `connect`. Trong tất cả các phương thức, khóa công khai của cặp khóa này được gọi là `dapp_encryption_public_key`.
2. \[backpack]: Khi xử lý deeplink `connect` , Backpack cũng sẽ tạo một cặp khóa x25519 mới.
   * Backpack sẽ trả về khóa công khai này dưới dạng `wallet_encryption_public_key` trong phản hồi `connect` .
   * Backpack sẽ tạo một khóa bí mật bằng Diffie-Hellman với `dapp_encryption_public_key` và ***khóa riêng*** liên kết với `wallet_encryption_public_key`.
   * Backpack sẽ lưu trữ cục bộ một ánh xạ từ `dapp_encryption_public_key` đến các shared secrets để sử dụng cho việc giải mã trong các deeplink tiếp theo.
3. \[dapp]: Khi nhận được phản hồi `connect` , dapp nên tạo một shared secret bằng cách sử dụng Diffie-Hellman với  `wallet_encryption_public_key` và ***khóa riêng*** liên kết với `dapp_encryption_public_key`. Shared secret này sau đó sẽ được sử dụng để giải mã trường `data` trong phản hồi. Nếu thực hiện đúng, khóa công khai của người dùng sẽ có sẵn để chia sẻ với dapp bên trong đối tượng `data` JSON.

#### Deeplink Tiếp Theo <a href="#subsequent-deeplinks" id="subsequent-deeplinks"></a>

1. \[dapp]: Đối với bất kỳ phương thức tiếp theo nào (như [SignAndSendTransaction](broken://pages/vEasqQZZKPhNBYZJLl5f) và [SignMessage](broken://pages/JIjSgVVeiqjAyGnfWVEs)), ứng dụng nên gửi một `dapp_encryption_public_key` ((khóa công khai phía ứng dụng trong shared secret) được sử dụng với Backpack cùng với một đối tượng `payload` đã được mã hóa.
2. \[backpack]: Khi được phê duyệt, Backpack sẽ mã hóa phản hồi đã ký dưới dạng đối tượng JSON với phần mã hóa được gửi dưới dạng tham số truy vấn `data=` .
3. \[dapp]: Khi nhận được phản hồi deeplink, ứng dụng nên giải mã đối tượng trong tham số truy vấn `data=` để xem chữ ký.

### &#x20;Tài Nguyên Mã Hóa <a href="#encryption-resources" id="encryption-resources"></a>

Để tìm hiểu thêm về mã hóa và giải mã, vui lòng tham khảo các thư viện sau:

**JavaScript**

* [TweetNaCl.js](https://github.com/dchest/tweetnacl-js)

**iOS**

* [TweetNaCl SwiftWrap](https://github.com/bitmark-inc/tweetnacl-swiftwrap)

**Android**

* [Tink](https://github.com/google/tink)
* [TweetNaCl Java](https://github.com/InstantWebP2P/tweetnacl-java)


---

# 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, and the optional `goal` query parameter:

```
GET https://support.backpack.exchange/support-docs/vn/vi-wallet/tai-lieu-ky-thuat/deeplinks/ma-hoa.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
