Documentation Index Fetch the complete documentation index at: https://docs.privora.xyz/llms.txt
Use this file to discover all available pages before exploring further.
Privora provides client SDKs for Rust, TypeScript, and React, enabling you to build applications that interact with FHE-enabled Solana programs.
SDK Comparison
Feature Rust SDK TypeScript SDK React SDK Package privora-sdk-client@privora/sdk@privora/reactEnvironment Native, CLI, Backend Browser, Node.js React Apps Async Tokio async/await Promise-based React Hooks State Management Manual Manual Built-in (Context) User Recovery UI Manual Manual useDecryptReveal hook
Quick Start
npm install @privora/react @privora/sdk
import { PrivoraProvider , usePrivoraContext , useEncrypt } from '@privora/react' ;
function App () {
const { signMessage } = useWallet ();
return (
< PrivoraProvider
rpcUrl = "http://localhost:8899"
autoInitialize
signMessage = { signMessage }
>
< MyComponent />
</ PrivoraProvider >
);
}
function MyComponent () {
const { privora , userCrypto , isInitialized } = usePrivoraContext ();
const { encryptAndSubmit } = useEncrypt ( privora , userCrypto );
const handleSubmit = async () => {
const result = await encryptAndSubmit ( 100 , 'u8' );
console . log ( 'Hash:' , result ?. hash );
};
if ( ! isInitialized ) return < div > Loading... </ div > ;
return < button onClick = { handleSubmit } > Submit </ button > ;
}
import { Privora } from '@privora/sdk' ;
const privora = await Privora . connect ( 'http://localhost:8899' );
const encrypted = privora . encrypt ( 100 , 'u8' );
const hash = await privora . submit ( encrypted );
console . log ( 'Submitted:' , hash );
[ dependencies ]
privora-sdk-client = { git = "https://github.com/privora-xyz/privora" }
tokio = { version = "1" , features = [ "full" ] }
use privora_sdk_client :: prelude ::* ;
#[tokio :: main]
async fn main () -> Result <()> {
let privora = PrivoraClient :: new ( "http://localhost:8899" ) . await ? ;
let encrypted = privora . encryptor () . encrypt ( 100 u8 ) ? ;
let hash = privora . submit ( & encrypted ) . await ? ;
println! ( "Submitted: {:?}" , hash );
Ok (())
}
Core Functionality
1. FHE Encryption
Encrypt values with the network’s FHE public key:
const { encrypt , encryptAndSubmit } = useEncrypt ( privora , userCrypto );
// With user recovery (recommended)
const result = await encryptAndSubmit ( 100 , 'u8' );
const encrypted = privora . encrypt ( 100 , 'u8' );
let price : ClientEncrypted < u8 > = encryptor . encrypt ( 100 u8 ) ? ;
2. Data Submission
Submit encrypted data to the sequencer:
const hash = await privora . submit ( encrypted );
3. User Recovery
Add user-recoverable encryption:
// encryptAndSubmit automatically includes user recovery
const result = await encryptAndSubmit ( 100 , 'u8' );
// result.userCiphertext and result.userNonce contain recovery data
const userCrypto = privora . userCrypto ( keypair );
const encrypted = privora . encrypt ( 100 , 'u8' ). withUserRecovery ( userCrypto );
let with_recovery = user_crypto . add_recovery ( encrypted , & plaintext_bytes ) ? ;
4. Transaction Building
Build and send transactions with FHE data:
const signature = await privora
. transaction ()
. add ( instruction )
. withFheData ([ hash ])
. sign ( keypair )
. send ();
Next Steps
React Integration React hooks and components
TypeScript Client Core TypeScript SDK
Rust Client Native Rust SDK