# microsoft/nova architecture

> Architecture diagram of the GitHub repository microsoft/nova, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/microsoft/nova
- Repository: https://github.com/microsoft/nova

## Overview

##### Project Type and Purpose
- This is a Rust-based cryptographic library that implements Nova—a high-speed recursive SNARK proof system. Its primary role is to allow the creation of incrementally verifiable proofs (IVC) via recursive proofs and circuit folding.
- The project supports several curve cycles with various cryptographic schemes (e.g., HyperKZG, Pedersen commitments, Spartan SNARK for compression). It also supports multiple “front-ends” for creating circuits (e.g., bellman-style circuits and integrations with DSLs like Circom).

##### Analyzing the File Structure
- Top-Level Files: Files such as Cargo.toml, LICENSE, and README indicate that this is an open-source Rust library.
- Several directories (e.g., benches, examples) help users test and understand its functionalities.
- The src/ directory is where most of the implementation resides. Note the logical separation into submodules:
– src/frontend: Implements the constraint system and various cryptographic “gadgets” (e.g., for SHA256, Poseidon) that build circuits.
– src/gadgets: Contains lower-level implementations of cryptographic primitives and utility code.
– src/neutron: Contains components specifically for “neutron,” which is one of the core abstractions for representing or processing circuits (its “circuit” subdirectory, nifs.rs, relations, and univariate modules suggest that it may transform or serve as an intermediate representation for circuits).
– src/nova: Encapsulates the core logic for the Nova proof system, particularly the recursive SNARK aspects (e.g., its circuit submodules and nifs.rs).
– src/provider: Implements the underlying cryptographic providers and commitment schemes (e.g., for hyperkzg, pedersen, etc.) that support both the Nova and Neutron modules.
– Other modules (r1cs, spartan, traits): They support constraint system representations, snark compression (the Spartan SNARK), and shared abstractions.

##### Focusing on Neutron and Nova
- Neutron Component:
- Found under src/neutron, this module appears to handle circuit definitions and associated computations. Its contained files (e.g., circuit/mod.rs, circuit/nifs.rs, relation.rs) suggest that it is responsible for converting high-level circuit representations into formats amenable for proof composition.
- It likely interfaces with both the frontend (providing the circuit constraints and gadget integration) and the Nova module (for eventual recursive proof formation).
- Nova Component:
- Located in src/nova, Nova is at the heart of the recursive SNARK construction. It implements the recursive proof system and, through folding schemes and integration with Spartan SNARK components, compresses and verifies proofs.
- It depends on the cryptographic routines provided by the provider module and the circuit details supplied by Neutron (and perhaps, indirectly, the frontend and gadgets).

## Diagram (Mermaid)

```mermaid
flowchart TD

  %% Frontend & Gadgets Subgraph (Blue)
  subgraph "Frontend & Gadgets"
    FE["Frontend - Circuit API (bellman)"]:::frontend
    GA["Gadgets - Cryptographic circuits"]:::frontend
  end

  %% Neutron Module Subgraph (Green)
  subgraph "Neutron Module (Circuit Transformation & Representation)"
    NC1["Circuit Processing"]:::neutron
    NC2["NIFS Transformation"]:::neutron
    NC3["Relation Handling"]:::neutron
    NC4["Univariate Computation"]:::neutron
  end

  %% Nova Module Subgraph (Red)
  subgraph "Nova Module (Recursive SNARK Core & Proof Compression)"
    NCore["Nova Core - Recursive Proof Generation"]:::nova
    NV1["Circuit Handling"]:::nova
    NV2["NIFS Processing"]:::nova
    SSN["Spartan SNARK Integration"]:::spartan
  end

  %% Provider Component (Purple)
  P["Provider - Cryptographic Primitives"]:::provider

  %% Connections
  FE -->|"defines"| NC1
  GA -->|"supplies gadgets"| NC1

  NC1 -->|"flows to"| NC2
  NC2 -->|"refines"| NC3
  NC3 -->|"culminates in"| NC4

  NC4 -->|"feeds into"| NCore
  
  NCore -->|"handles circuit folding"| NV1
  NCore -->|"integrates proofs"| NV2
  NCore -->|"compresses via"| SSN

  P ---|"provides primitives to"| NC1
  P ---|"supports cryptography for"| NCore

  %% Styles
  classDef frontend fill:#add8e6,stroke:#000,stroke-width:1px;
  classDef neutron fill:#90ee90,stroke:#000,stroke-width:1px;
  classDef nova fill:#f08080,stroke:#000,stroke-width:1px;
  classDef provider fill:#dda0dd,stroke:#000,stroke-width:1px;
  classDef spartan fill:#ffdead,stroke:#000,stroke-width:1px;

  %% Click Events for Frontend & Gadgets
  click FE "https://github.com/microsoft/nova/tree/main/src/frontend"
  click GA "https://github.com/microsoft/nova/tree/main/src/gadgets"
  
  %% Click Events for Neutron Module Subcomponents
  click NC1 "https://github.com/microsoft/nova/blob/main/src/neutron/circuit/mod.rs"
  click NC2 "https://github.com/microsoft/nova/blob/main/src/neutron/nifs.rs"
  click NC3 "https://github.com/microsoft/nova/blob/main/src/neutron/relation.rs"
  click NC4 "https://github.com/microsoft/nova/blob/main/src/neutron/univariate.rs"
  
  %% Click Events for Nova Module Subcomponents
  click NCore "https://github.com/microsoft/nova/tree/main/src/nova"
  click NV1 "https://github.com/microsoft/nova/tree/main/src/nova/circuit"
  click NV2 "https://github.com/microsoft/nova/blob/main/src/nova/nifs.rs"
  
  %% Click Event for Spartan SNARK Module
  click SSN "https://github.com/microsoft/nova/tree/main/src/spartan"
  
  %% Click Event for Provider Component
  click P "https://github.com/microsoft/nova/tree/main/src/provider"
```
