Random Number Generation
TheArcisRNG struct provides access to randomness within MPC circuits. All random values are generated within the MPC context.
Basic Usage
The
width parameter in gen_integer_from_width must be known at compile time.Public vs Secret Random Integers
gen_public_integer_from_width when you need randomness that does not need to stay secret within the MPC computation—for example, nonce generation. The value is visible to ARX nodes during execution but is not automatically included in the circuit output; you still control what gets returned.
Range-Based Generation
To generate integers within a specific range, usegen_integer_in_range:
n_attempts=24 gives a failure probability below 2^-24.
The
n_attempts parameter must be known at compile time.Shuffling
Shuffle arrays in-place with cryptographic uniformity:What Works and What Doesn’t
Cryptographic Operations
SHA3 Hashing
Arcis provides SHA3-256 and SHA3-512 hash functions:Arcis uses SHA3 (Keccak) rather than SHA-2/SHA-512 because SHA3 has a more efficient circuit structure for MPC evaluation.
Ed25519 Signatures
Arcis provides Ed25519 signature operations using SHA3-512 internally (ArcisEd25519).Signature Verification
Key Generation
Only the public verifying key is revealed. The secret key is never revealed in plaintext; it exists only as secret shares distributed across ARX nodes. Arcium uses full-threshold security—all ARX nodes in the cluster would need to collude to reconstruct the secret. As long as even one node remains honest, the secret stays protected.
MXE Cluster Signing
Sign messages using the MXE cluster’s collective key:Public Key Operations
Work with X25519 public keys:Advanced: Coordinate Extraction
Advanced: Coordinate Extraction
For advanced use, work with the Montgomery X coordinate directly:Coordinate extraction is for advanced cryptographic operations such as:
- Custom ECDH key exchange implementations
- Key derivation from shared secrets
- Interoperability with external systems that work with raw Curve25519 coordinates
- Zero-knowledge proof inputs that require field elements
from_base58() or from_uint8() for standard public key handling.Reveal Constraints
Learn where
.reveal() and .from_arcis() can be called.Data Packing
ThePack<T> type provides bit-level compression for onchain storage efficiency.
Why Packing Matters
In Arcis, all values are stored as field elements (~255 bits / 32 bytes each). Without packing:- A single
u8(8 bits) uses one full field element [u8; 256]uses 256 field elements
[u8; 256]= 256 bytes total- Each field element packs ~26 bytes (208 usable bits)
- Packed: ⌈256 / 26⌉ = 10 field elements
- Compression: 256 → 10 = ~26x fewer field elements
u8 would use a full field element (256 elements total). This significantly reduces onchain storage costs and transaction sizes.
When to Use Pack
- Large arrays of small integers (
[u8; N],[u16; N]) - Data that needs to be stored onchain
- Input/output parameters approaching transaction size limits
Basic Usage
Simple Example
Pack<T> use cases. The “Practical Example” below shows advanced usage with encrypted types.
Practical Example
Pack with Crypto Types
Cryptographic types likeVerifyingKey are often passed as Pack<VerifyingKey>:
Machine Learning
Arcis includes basic ML primitives for privacy-preserving inference.Logistic Regression
Linear Regression
Available ML Functions
| Function | Description |
|---|---|
LogisticRegression::new(coef, intercept) | Create logistic regression model |
LogisticRegression::predict(x, threshold) | Binary classification |
LogisticRegression::predict_proba(x) | Probability output |
LinearRegression::new(coef, intercept) | Create linear regression model |
LinearRegression::predict(x) | Continuous prediction |
ArcisMath::sigmoid(x) | Sigmoid activation function |
logit(p) | Inverse of sigmoid |
expit(x) | Alias for sigmoid |
ML models support up to 100 features (
MAX_FEATURES = 100). For larger models, consider feature selection or dimensionality reduction.Summary
| Primitive | Use Case | Key Methods |
|---|---|---|
ArcisRNG | Random values | bool(), gen_integer_from_width(), gen_public_integer_from_width(), gen_integer_in_range(), gen_uniform(), shuffle() |
SHA3_256/512 | Hashing | new(), digest() |
SecretKey | Ed25519 keys | new_rand(), from_bytes() |
VerifyingKey | Signature verification | from_secret_key(), verify() |
MXESigningKey | Cluster signing | sign() |
ArcisX25519Pubkey | Public keys | from_base58(), from_uint8(), to_x(), new_from_x() |
Pack<T> | Efficient storage | new(), unpack() |
LogisticRegression | Binary classification | new(), predict(), predict_proba() |
LinearRegression | Regression | new(), predict() |
ArcisMath | Math functions | sigmoid() |
What’s Next?
Best Practices
Performance optimization, debugging, and testing strategies.
Quick Reference
Concise syntax lookup for all Arcis patterns.
Operations
Full function and method reference.