Input & Encryption
To create an encrypted value, usenew_euint128 or new_ebool with client-encrypted ciphertext.
Creating Encrypted Values (Program Side)
Input Functions
| Function | Description | Signature |
|---|---|---|
new_euint128 | Create encrypted u128 from client-encrypted ciphertext | (CpiContext, Vec<u8>, u8) -> Result<Euint128> |
new_ebool | Create encrypted bool from client-encrypted ciphertext | (CpiContext, Vec<u8>, u8) -> Result<Ebool> |
as_euint128 | Convert plaintext u128 to encrypted handle (trivial encrypt) | (CpiContext, u128) -> Result<Euint128> |
as_ebool | Convert plaintext bool to encrypted handle (trivial encrypt) | (CpiContext, bool) -> Result<Ebool> |
The last parameter in
new_euint128/new_ebool identifies whether the input is ciphertext (0) or plaintext (1). Always pass 0 when working with client-encrypted data.Trivial Encryption
Useas_euint128 and as_ebool to convert plaintext values to encrypted handles directly in your program. This is useful for constants or program-generated values.
Client-Side Encryption
Values must be encrypted client-side before sending to your program. Use the JavaScript SDK to encrypt values:See the JavaScript SDK Encryption documentation for supported types and error handling.