The Thesis
Compact is not a general-purpose programming language. It is a domain-specific language designed to express zero-knowledge circuits that execute on Midnight Network. Its core value lies in enforcing privacy by default, where all data is treated as confidential unless explicitly disclosed, enabling developers to build applications that balance verifiability with data protection.
The Constraint That Shapes Everything
If you've written JavaScript or TypeScript, Compact feels familiar at first. The syntax looks recognizable, but the execution model is completely different.
Compact doesn’t run like traditional smart contract languages such as Solidity. It compiles into circuits that generate proofs using Zero-Knowledge Proof systems.
That single constraint changes everything.
You’re not writing instructions for a virtual machine. You’re defining what must be proven.
The Anatomy of a Compact Program
Every Compact contract follows a predictable structure. Let’s start with the minimal example:
pragma language_version >= 0.16 && <= 0.18;
import CompactStandardLibrary;
export ledger message: Opaque<"string">;
export circuit storeMessage(customMessage: Opaque<"string">): [] {
message = disclose(customMessage);
}Six lines. Fully deployable.
Let’s break it down.
Pragma: Version Control for Determinism
pragma language_version >= 0.16 && <= 0.18;This ensures your contract compiles against a known version of the language.
Why it matters:
Compact evolves quickly
Minor updates can introduce breaking changes
Deterministic compilation is critical for reproducible proofs
Imports: Accessing the Standard Library
import CompactStandardLibrary;This gives you access to:
Data structures (
Map,Set,Counter)Cryptographic helpers
Utility circuits
Unlike traditional languages, libraries are minimal and tightly scoped to what can be efficiently proven.
Ledger: Where Public State Lives
Compact does not use a contract body like Solidity. Instead, state is declared at the top level.
export ledger message: Opaque<"string">;This defines:
A persistent, on-chain variable
Stored on Midnight’s public ledger
Key properties:
export→ readable by external applicationssealed→ immutable after deployment
Example:
export sealed ledger owner: Bytes<32>;This is set once and never changed.
Circuits: Functions That Become Proofs
In Compact, functions are called circuits:
export circuit storeMessage(customMessage: Opaque<"string">): [] {
message = disclose(customMessage);
}What actually happens:
The user executes this locally
A proof is generated
The network verifies the proof
The state updates if valid
No raw computation is re-executed on-chain.
This is the difference between:
Execution-based systems (Ethereum)
Proof-based systems (Midnight)
Data Types: Designed for Proof Efficiency
Compact’s type system is intentionally restrictive.
Primitive Types
Field→ base unit for computationUint<N>→ bounded integersBoolean→ true/falseBytes<N>→ fixed-length data
Opaque Types
Opaque<"string">These are critical:
Data is not readable inside circuits
Treated as hashed values
Preserves privacy while enabling verification
Witnesses: Private Data Without Exposure
This is where things diverge sharply from traditional models.
witness get_user_input(): Field;A witness:
Exists off-chain
Runs locally on the user’s machine
Supplies private inputs to the circuit
The network never sees the actual value.
It only verifies that:
“A valid value exists and was used correctly.”
The disclose Mechanism: Explicit Transparency
Compact enforces a strict rule:
Everything is private unless explicitly made public.
message = disclose(customMessage);Without disclose, the compiler rejects the code.
Why this matters:
Prevents accidental data leaks
Forces intentional design decisions
Aligns with Midnight’s selective disclosure model
Control Flow and Privacy Constraints
Even logic must respect privacy boundaries.
if (disclose(caller == owner)) {
// allowed
}Without disclose, this fails.
Because:
Control flow can leak information
The compiler enforces safe disclosure
Assertions: Enforcing Validity
assert(amount > 0, "Amount must be positive");If the condition fails:
The proof is invalid
The transaction is rejected
This guarantees correctness without exposing internal values.
The Execution Model: Proof, Not Execution
Traditional blockchains:
Execute every transaction
Replicate computation across nodes
Midnight:
One party computes
Generates a proof
Network verifies
This improves:
Efficiency (less computation per node)
Throughput (parallelizable validation)
Privacy (no raw data exposure)
The "Why": What Problem Compact Solves
Most smart contract platforms force a tradeoff:
Transparency → no privacy
Privacy → no verifiability
Compact removes that constraint.
It enables:
Private financial logic
Confidential business processes
Verifiable off-chain computation
Without exposing:
Inputs
Intermediate state
Sensitive relationships
Contextual Analysis: Where Compact Fits
Compact is not competing with Solidity or Rust directly.
It operates in a different category:
ZK-native smart contract languages
Compared to alternatives:
Solidity → execution-based
Cairo (Starknet) → circuit-focused but lower-level
Compact → higher-level abstraction with privacy enforcement
Its advantage:
Developers don’t need deep cryptography knowledge
Privacy is built into the language itself
Roadmap & Hurdles
Compact is still evolving alongside Midnight Network, and adoption depends on a few key factors:
Challenges
Proof generation latency (especially on consumer devices)
Developer onboarding (new mental model)
Tooling maturity
Opportunities
Growing demand for privacy-preserving applications
Integration with regulated environments
Expansion of ZK infrastructure
Conclusion
Compact represents a shift in how developers think about smart contracts.
You’re no longer writing code to be executed publicly.
You’re defining logic that can be proven without being revealed.
That shift matters.
Because the future of blockchain isn’t just about transparency.
It’s about selective disclosure, where privacy and verification coexist.
Compact is the language that makes that possible.

Discussion
Join the conversation
Connect your wallet to share your thoughts and engage with the community
No comments yet
Connect your wallet to be the first to comment!