> For the complete documentation index, see [llms.txt](https://docs.envector.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.envector.io/1.4.x/sdk-user-guide/search/decrypting-scores.md).

# Decrypting Scores

In a **full search pipeline** (Scoring → Decryption → Metadata retrieval), this is the **second step**.

When you use the scoring API, the similarity scores are returned in encrypted form for security.\
To access the actual values, you must call `decrypt_score` on the client side.\
Decryption always happens locally, so there is no risk of exposing data to the server.

If you initialized your client with `pyenvector.init` using `key_path` and `key_id`, and set `auto_key_setup=True`, the secret key is already loaded into memory. In this case, you can directly call `decrypt_score` without specifying the key path again.

However, if you prefer not to load the secret key automatically and set `auto_key_setup=False`, you must explicitly provide the `sec_key_path` parameter when calling `decrypt_score`.

#### Example 1: With `auto_key_setup=True`

```python
import pyenvector as ev

# Initialize with automatic key setup
ev.init(
    address="localhost:50050",
    key_path="keys/example",
    key_id="example",
    auto_key_setup=True
)

index = ev.Index("example_index")

# Perform scoring
encrypted_scores = index.scoring(query)

# Decrypt directly, no need to provide sec_key_path
plaintext_scores = index.decrypt_score(encrypted_scores)

print(plaintext_scores[:5])

```

#### Example 2: With `auto_key_setup=False`

```python
import pyenvector as ev
from pyenvector import Cipher

# Initialize without loading keys automatically
ev.init(
    address="localhost:50050",
    key_path="keys/example",
    auto_key_setup=False
)

index = ev.Index("example_index")

# Perform scoring
encrypted_scores = index.scoring(query)

# Must explicitly provide the secret key path
plaintext_scores = ev.decrypt_score(
    encrypted_scores,
    sec_key_path="keys/example/SecKey.json"
)

print(plaintext_scores[:5])

```


---

# 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://docs.envector.io/1.4.x/sdk-user-guide/search/decrypting-scores.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.
