Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/abdelstark/starkstr
Nostr x STARKs exploration project.
https://github.com/abdelstark/starkstr
cairo cairo-lang nostr starks zero-knowledge-proofs
Last synced: about 17 hours ago
JSON representation
Nostr x STARKs exploration project.
- Host: GitHub
- URL: https://github.com/abdelstark/starkstr
- Owner: AbdelStark
- License: mit
- Created: 2025-01-16T16:28:32.000Z (11 days ago)
- Default Branch: main
- Last Pushed: 2025-01-24T20:36:32.000Z (3 days ago)
- Last Synced: 2025-01-24T21:25:30.918Z (3 days ago)
- Topics: cairo, cairo-lang, nostr, starks, zero-knowledge-proofs
- Language: Shell
- Homepage:
- Size: 383 KB
- Stars: 6
- Watchers: 1
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# STARKstr ๐
> Exploring STARK proofs for enhancing Nostr's privacy, scalability, and functionality.
STARKstr is a research project exploring the potential benefits of STARK proofs for the Nostr ecosystem. It serves as a collection of proof of concepts and explorations in this direction.
## ๐ฏ Current Focus: Delegated Aggregate Signature Verification
Our first exploration focuses on enabling relays to strip signatures from events and provide STARK proofs that those signatures were valid. This approach offers several benefits:
- **Enhanced Privacy**: Signatures are not revealed, providing deniability
- **Reduced Bandwidth**: Events can be transmitted without signatures
- **Batch Verification**: Multiple signatures can be verified in a single proof
- **Trust Minimization**: Clients can verify the proof instead of trusting the relayThis work is related to [NIP PR #1682](https://github.com/nostr-protocol/nips/pull/1682), which proposes a standard for delegated signature verification.
## ๐ Architecture & Proving Pipeline
STARKstr implements a complete proving pipeline for Nostr event signature verification. The system is designed to be modular and extensible, leveraging the power of STARKs to provide cryptographic guarantees.
### System Architecture
```mermaid
graph TB
subgraph "Event Generation"
A[Nostr NDK] --> B[Event Signer]
B --> C[JSON Output]
endsubgraph "Cairo VM execution"
C --> D[CLI Parser]
D --> E[Cairo Program]
E --> F[Execution Trace]
endsubgraph "STARK Proof Generation"
F --> G[STWO Prover]
G --> H[STARK Proof]
endsubgraph "Proof Verification"
H --> I[STWO Verifier]
I --> J[Verification Result]
endstyle A fill:#f9f,stroke:#333,stroke-width:2px
style E fill:#bbf,stroke:#333,stroke-width:2px
style G fill:#bfb,stroke:#333,stroke-width:2px
style I fill:#fbb,stroke:#333,stroke-width:2px
```### Proving Pipeline Flow
```mermaid
sequenceDiagram
participant Client
participant NDK as Nostr NDK
participant Cairo as Cairo Program
participant STWO as STWO Prover
participant Verifier as STWO VerifierClient->>NDK: Generate Events
NDK->>NDK: Sign Events
NDK->>Cairo: Batch Events
Cairo->>Cairo: Verify Signatures
Cairo->>STWO: Execution Trace
STWO->>STWO: Generate Proof
STWO->>Verifier: STARK Proof
Verifier->>Client: Verification Result
```### Components
1. **Event Generation** (`aggsig_checker_cli`)
- Uses [Nostr NDK](https://github.com/nostr-dev-kit/ndk) for event creation
- Generates and signs events with Schnorr signatures
- Outputs events in JSON format with Cairo-compatible parameters2. **Cairo Verification** (`aggsig_checker`)
- Implements batch signature verification in Cairo
- Uses [Cairo VM](https://github.com/lambdaclass/cairo-vm) for execution
- Generates execution trace for proving3. **STARK Proof Generation**
- Uses [STWO Prover](https://github.com/starkware-libs/stwo) for proof generation
- Leverages [STWO Cairo AIR](https://github.com/starkware-libs/stwo-cairo/) for Cairo program proving
- Produces a STARK proof of the integrity of the computation (in this case, the verification of the signatures)4. **Proof Verification**
- STWO verifier for proof validation
- Can be run in browsers, Nostr clients, or any environment
- Provides cryptographic guarantees of signature validity of a batch of Nostr events### End-to-End Flow
1. **Event Generation**:
```bash
cd apps/aggsig_checker_cli
npm start
```Generates a batch of signed Nostr events with Cairo-compatible parameters.
2. **Signature Verification**:
```bash
cd packages/aggsig_checker
scarb cairo-run
```Verifies all signatures and generates execution trace.
3. **Proof Generation**:
```bash
# Coming soon: STWO integration
```Generates STARK proof from execution trace.
4. **Proof Verification**:
```bash
# Coming soon: STWO verifier integration
```
Verifies the STARK proof.## ๐๏ธ Architecture
The project is structured into several components:
```
starkstr/
โโโ packages/ # Core packages
โ โโโ aggsig_checker/ # Cairo package for signature verification
โ โโโ src/ # Cairo source code
โ โโโ Scarb.toml # Package manifest
โโโ apps/ # Applications
โ โโโ aggsig_checker_cli/ # CLI tool for signature verification
โ โโโ src/ # TypeScript source code
โ โโโ package.json # Package manifest
โโโ scripts/ # Helper scripts
โ โโโ verify_nostr_event_batch_signatures.sh # Batch verification script
โโโ tests/ # Test suite
```### Components
1. **aggsig_checker** (Cairo Package)
- Core signature verification logic
- Schnorr signature verification using BIP340
- Batch verification support
- STARK proof generation (coming soon)2. **aggsig_checker_cli** (TypeScript)
- Command-line interface for signature verification
- Generates sample Nostr events
- Signs events using Schnorr signatures
- Outputs events in JSON format
- Converts hex values to Cairo-compatible format## ๐ Getting Started
### Prerequisites
- [Scarb](https://docs.swmansion.com/scarb/download.html) - Cairo package manager
- [Node.js](https://nodejs.org/) (v16 or later)### Installation
1. Clone the repository:
```bash
git clone https://github.com/AbdelStark/starkstr.git
cd starkstr
```2. Install CLI dependencies:
```bash
cd apps/aggsig_checker_cli
npm install
cd ../..
```3. Build the Cairo package:
```bash
cd packages/aggsig_checker
scarb build
cd ../..
```### Usage
1. Generate and verify a batch of Nostr events:
```bash
./scripts/verify_nostr_event_batch_signatures.sh
```2. Run the CLI tool directly:
```bash
cd apps/aggsig_checker_cli
npm start
```## ๐งช Testing
Run the test suite:
```bash
cd packages/aggsig_checker
scarb test
```## ๐ Benchmarks
> Coming soon: We will be adding comprehensive benchmarks to evaluate:
>
> - Proof generation time
> - Verification time
> - Cloud costs
> - Memory usage
> - Network overhead## ๐ฃ๏ธ Roadmap
1. **Phase 1: Proof of Concept** (Current)
- โ Basic Schnorr signature verification in Cairo
- โ Test data generation
- โ Batch verification
- ๐ STARK proof generation2. **Phase 2: Benchmarking**
- Cloud cost analysis
- Latency measurements
- Scalability testing3. **Phase 3: Integration**
- Relay implementation
- Client libraries
- Documentation## ๐ค Contributing
We welcome contributions! Please check our [Contributing Guidelines](CONTRIBUTING.md) for details on how to submit pull requests, report issues, and contribute to the project.
## ๐ License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## ๐ Acknowledgments
- [Nostr Protocol](https://github.com/nostr-protocol/nostr)
- [StarkWare](https://starkware.co/) for Cairo and STARK technology
- [Alexandria](https://github.com/keep-starknet-strange/alexandria) for Cairo utilities---
Made with โค๏ธ by the Nostr community