fhenix-trivial-encryption

Convert plaintext to encrypted types on-chain with FHE.asEuintXX/asEbool/asEaddress (+ optional securityZone), and understand the critical caveat — trivially-encrypted values are NOT confidential. Covers the full cross-cast matrix and the wrap*/asE* renaming.

nickthelegend/fhenix-skills1 installsMITSynced Aug 22

Works with

Claude CodeCursorCodex CLIGitHub CopilotGemini CLI
---
name: fhenix-trivial-encryption
description: Convert plaintext to encrypted types on-chain with FHE.asEuintXX/asEbool/asEaddress (+ optional securityZone), and understand the critical caveat — trivially-encrypted values are NOT confidential. Covers the full cross-cast matrix and the wrap*/asE* renaming.
license: MIT
---

# Fhenix Trivial Encryption

## Overview
**Trivial encryption** converts a plaintext Solidity value into an encrypted type so it can interact with real ciphertexts, using the `FHE.asE…` family:
```solidity
uint16 number = 2;
euint16 enc = FHE.asEuint16(number);
ebool   flag = FHE.asEbool(true);
eaddress a   = FHE.asEaddress(0x1234...7890);
euint32  z   = FHE.asEuint32(50000, 1);   // optional securityZone
```

## ⚠️ Trivially-encrypted values are NOT confidential
The plaintext was public, so the result stays public — anyone watching the chain knows the value (it just has an encrypted *type*). Combining two trivially-encrypted values yields another non-confidential value (the observer can replay the math). **Confidentiality only comes from `InEuintXX` inputs encrypted client-side.** Treat any `FHE.asE…(literal)` result as public.

```solidity
function calc(InEuint16 calldata input) public {
    euint16 number5  = FHE.add(FHE.asEuint16(2), FHE.asEuint16(3)); // public (=5)
    euint16 encInput = FHE.asEuint16(input);                        // confidential
    euint16 encMul   = FHE.mul(encInput, number5);                 // confidential
    // observer knows the structure, not the secret value
}
```

## Two meanings of `FHE.asEuintXX(...)`
- **From plaintext** (trivial encryption) — `FHE.asEuint32(50000)`.
- **From an `InE*` input struct** — `FHE.asEuint32(inEuint32)` (this *is* confidential; see `fhenix-encrypted-inputs`).

## Cross-casting between encrypted types
The full matrix is supported, e.g. `FHE.asEbool(euintN)`, `FHE.asEuint8(euint128)`, `FHE.asEaddress(euint128)`, etc. Narrowing/widening casts each emit an FHE op.

## Handle-wrapping rename (cofhe-contracts ≥ 0.1.3)
Wrapping a raw `bytes32` handle into a typed value moved from `FHE.asE*(bytes32)` to dedicated `FHE.wrap*` functions (`wrapEbool`, `wrapEuint8…128`, `wrapEaddress`) to remove an overload ambiguity with `asEuint*(0)`. `FHE.unwrap(x)` extracts the `bytes32` handle. If upgrading from ≤0.1.2, rewrite `FHE.asE*(<bytes32>)` call sites as `FHE.wrap*`.

## Source docs
- [`fhe-library/core-concepts/trivial-encryption.mdx`](../fhenix-docs/fhe-library/core-concepts/trivial-encryption.mdx)
- [`fhe-library/reference/fhe-sol/type-conversion.mdx`](../fhenix-docs/fhe-library/reference/fhe-sol/type-conversion.mdx) · [`utility.mdx`](../fhenix-docs/fhe-library/reference/fhe-sol/utility.mdx)

## AI Agent Prompt
> "Explain why a trivially-encrypted constant (e.g. a counter delta of 1) is safe to make public but a user balance must come from an `InEuintXX`. Then show a function mixing a public `FHE.asEuint32(1)` delta with a confidential input."

More Security skills

azure-cost

microsoft/azure-skills

Azure cost management: query costs, forecast spending, optimize to reduce waste. WHEN: \"Azure costs\", \"Azure bill\", \"cost breakdown\", \"how much am I spending\", \"forecast spending\", \"optimize costs\", \"reduce spending\", \"orphaned resources\", \"rightsize VMs\", \"cost spike\", \"reduce storage costs\", \"AKS cost\". DO NOT USE FOR: deploying resources, provisioning, diagnostics, or security audits.

355.6k

entra-app-registration

microsoft/azure-skills

Guides Microsoft Entra ID app registration, OAuth 2.0 authentication, and MSAL integration. USE FOR: create app registration, register Azure AD app, configure OAuth, set up authentication, add API permissions, generate service principal, MSAL example, console app auth, Entra ID setup, Azure AD authentication. DO NOT USE FOR: Key Vault secrets (use azure-keyvault-expiration-audit), general Azure resource security guidance.

318.9k

azure-messaging

microsoft/azure-skills

Troubleshoot and resolve issues with Azure Messaging SDKs for Event Hubs and Service Bus. Covers connection failures, authentication errors, message processing issues, and SDK configuration problems. WHEN: event hub SDK error, service bus SDK issue, messaging connection failure, AMQP error, event processor host issue, message lock lost, message lock expired, lock renewal, lock renewal batch, send timeout, receiver disconnected, SDK troubleshooting, azure messaging SDK, event hub consumer, service bus queue issue, topic subscription error, enable logging event hub, service bus logging, eventhub python, servicebus java, eventhub javascript, servicebus dotnet, event hub checkpoint, event hub not receiving messages, service bus dead letter, batch processing lock, session lock expired, idle timeout, connection inactive, link detach, slow reconnect, session error, duplicate events, offset reset, receive batch.

310.3k

← All Security skills

Check your AI visibility

One URL in, a 0–100 score and the exact fixes out.

RUN THE CHECK

Browse all the tools

15 tools across six categories
13 of them never send your data anywhere

Free · No signup · No trial clock

SEE THE DIRECTORY