Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
132 changes: 132 additions & 0 deletions research/AikenVsSoroban.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
# Aiken vs Soroban

## 1. Language & Paradigm

### Aiken (Cardano)

**Functional & User-Friendly:** Aiken is a modern programming language and toolkit specifically designed for developing smart contracts on the Cardano blockchain. Drawing inspiration from languages like Gleam, Rust, and Elm, Aiken emphasizes robustness and an enhanced developer experience. Its functional programming paradigm promotes immutability and statelessness, which are beneficial for creating predictable and secure smart contracts.

#### Example of an Aiken Validator:

```rust
use aiken/hash.{Blake2b_224, Hash}
use aiken/list
use aiken/string
use aiken/transaction.{ScriptContext}
use aiken/transaction/credential.{VerificationKey}

pub type Datum {
owner: Hash<Blake2b_224, VerificationKey>,
}

pub type Redeemer {
msg: ByteArray,
}
```

In this example, Aiken's syntax showcases its functional nature, focusing on defining data types and leveraging pattern matching to handle various contract states.

### Soroban (Stellar)

**Rust-Based & WebAssembly-Powered:** Soroban is Stellar's smart contract platform that utilizes Rust for contract development, compiling down to WebAssembly (WASM). Rust is renowned for its performance and safety features, offering memory safety and concurrency without a garbage collector. WASM ensures cross-platform compatibility and efficient execution, making Soroban contracts both powerful and versatile. ​

#### Example of a Soroban Contract:

```rust
#![no_std]

use soroban_sdk::{contractimpl, Env};

pub struct HelloWorld;

#[contractimpl]
impl HelloWorld {
pub fn hello(env: Env, to: Symbol) -> Symbol {
let mut hello = String::from("Hello, ");
hello.push_str(&to.to_string());
Symbol::from_str(&env, &hello)
}
}
```

This example demonstrates a simple Soroban contract written in Rust, where the `hello` function concatenates a greeting with the provided input. The `#![no_std]` attribute indicates that the standard Rust library is not used, aligning with the constraints of WASM environments.

### Key Takeaways:
- **Aiken:** Embraces a functional programming approach tailored for Cardano's architecture, aiming to provide a seamless and secure smart contract development experience.
- **Soroban:** Leverages Rust's strengths and WASM's portability to offer a robust platform for smart contract development on Stellar, catering to developers familiar with Rust and systems programming concepts.

---

## 2. Ecosystem & Integration

### Aiken (Cardano)

#### Integration with Semaphore:
The Cardano community has been proactive in integrating Semaphore, a zero-knowledge protocol designed to enable anonymous signaling and membership proofs. A significant initiative in this direction is the "Cardano Privacy Layer: A Zero-Knowledge based anonymous membership and voting protocol" project. This endeavor aims to adapt Semaphore to the Cardano ecosystem, facilitating functionalities such as anonymous voting and membership verification.

#### Ecosystem Support:
Aiken exclusively handles the on-chain aspects of applications, ensuring that writing smart contracts is both straightforward and secure. This specialization simplifies the development process, making it more accessible for implementing complex protocols like Semaphore. ​

### Soroban (Stellar)

#### Potential for Semaphore Implementation:
While Soroban provides a robust environment for smart contract development, there is currently no documented implementation of Semaphore on the Stellar network. Implementing Semaphore would require significant development efforts to adapt the protocol to Stellar's architecture.

#### Ecosystem Support:
Soroban is a relatively new addition to the Stellar ecosystem, expanding its capabilities to support more complex smart contracts. However, the ecosystem may currently lack specific tools and libraries necessary for implementing advanced privacy protocols like Semaphore.


---

## 3. Security & Performance

### Aiken (Cardano)

#### Cryptography and Trusted Setups:
Cardano places a strong emphasis on formal verification and peer-reviewed research to ensure the security of its blockchain platform. The integration of Semaphore via Aiken benefits from Cardano's robust cryptographic foundations, ensuring secure and anonymous transactions.

#### Performance Considerations:
Aiken's functional programming paradigm, combined with Cardano's Extended UTXO (EUTXO) model, offers predictable and efficient transaction processing.

### Soroban (Stellar)

#### Cryptography and Trusted Setups:
Stellar is designed for simplicity and speed, primarily focusing on straightforward asset transfers. Implementing complex cryptographic protocols like Semaphore would necessitate additional infrastructure.

#### Performance Considerations:
While Rust and WASM provide a performant base, the addition of intricate protocols like Semaphore could impact transaction speeds and costs. Thorough optimization would be required to maintain Stellar's hallmark efficiency.

#### Security Enhancements:
The Stellar Development Foundation (SDF) has launched the Soroban Security Audit Bank, a program that distributes up to $1 million in security audit credits to high-priority projects building on Soroban.

---

## 4. Conclusion & Comparative Analysis

#### Aiken vs Soroban for Semaphore Contracts

After evaluating Aiken and Soroban based on language paradigm, ecosystem integration, and security & performance, we can draw the following conclusions:

Language Paradigm: Aiken is a functional language tailored for Cardano, emphasizing immutability and security. Soroban, on the other hand, leverages Rust and WASM, making it ideal for performance-driven contracts.

Ecosystem & Integration: Aiken has a more developed foundation for integrating Semaphore, with active community projects and cryptographic adaptations already in place. Soroban, being relatively new, lacks mature tooling and documented integrations for privacy-preserving protocols like Semaphore.

Security & Performance: Aiken benefits from Cardano’s research-driven approach to security and its EUTXO model, which ensures predictable transaction processing. Soroban, while leveraging Rust’s safety features, may face scalability and optimization challenges when implementing complex cryptographic protocols.

## Final Verdict:

For developers focused on privacy and zero-knowledge protocols: Aiken is currently the better choice due to its established ecosystem support for Semaphore and Cardano’s strong security framework.

For developers looking for performance and flexibility: Soroban offers a promising foundation with Rust and WASM but requires additional development to integrate advanced cryptographic protocols.

Both Aiken and Soroban offer distinct advantages, and the choice ultimately depends on the developer's priorities whether it be security, privacy, or performance.



## References
- [Aiken Documentation](https://aiken-lang.org/)
- [Cardano Smart Contracts with Aiken](https://developers.cardano.org/docs/smart-contracts/aiken/)
- [Soroban Smart Contracts](https://developers.stellar.org/docs/build/smart-contracts/getting-started/hello-world)
- [Semaphore Documentation](https://docs.semaphore.pse.dev/)
- [Cardano Privacy Layer](https://www.lidonation.com/fr/proposals/cardano-privacy-layer-a-zero-knowledge-based-anonymous-membership-and-voting-protocol-phase-2-f13)
- [Soroban Audit Bank](https://stellar.org/blog/developers/the-soroban-audit-bank-fostering-a-secure-smart-contract-ecosystem)