> For the complete documentation index, see [llms.txt](https://docs.snarkify.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.snarkify.io/sirius-folding/sirius-folding-apis/ivc-struct.md).

# \`IVC\` struct

Check [Terminologies](/sirius-folding/terminologies.md#ivc) first

### Example

```rust
// Create IVC
// The zero step will be executed internally
let mut ivc = IVC::new(
    &public_params,
    &primary,
    primary_initial_z_in,
    &secondary,
    secondary_initial_z_in,
    false,
)
.expect("Error while create IVC");
                                                                                               
// Performs the folding steps
//
// Inside the synthesis circuit will be called multiple times and therefore the state will
// change outside `fold_step`
//
// Also there must be a continuity of steps within the step-circuit, it must take into account
// that the next step `z_in` will be `z_out` from the previous step
for _ in 1..5 {
    primary.update(input);
    secondary.update(input);
                                                                                               
    ivc.fold_step(&public_params, &primary, &secondary)
        .expect("Error while fold step");
}

// Verify that the folding was successful.                                                                                           
ivc.verify(&public_params).expect("Error while verify");
```

### Create IVC

#### Public Params&#x20;

Please check [\`PublicParams\` Struct](/sirius-folding/sirius-folding-apis/publicparams-struct.md)&#x20;

#### Primary & Secondary Circuit

IVC uses two step-circuits. Each of them is wrapped inside into a regular \`StepFoldingCircuit' and in addition to the step-circuit synthesis logic, the folding of the paired circuit is verified (secondary verifies the folding of primary and vice versa).

Therefore, the second circuit can always be a `sirius::step_circuit::trivial::Circuit` and have no payload whatsoever.

#### \`z\_in\` & \`z\_out\`

Each step-circuit has an input and an output at each step. Only the first input is specified in `IVC::new`, the others are chained `z_out` of step `n` is transmitted as `z_in` on step `n+1`

#### Debug Mode

In order to get a detailed error, you can enable `debug_mode`, then at each `fold_step` the `MockProver` from the halo2 library will be enabled and check your circuit. Otherwise, any error will only occur at the `verify` step.

### Fold Step IVC

Each folding step synthesizes primary & secondary circuits and performs off-circuit calculations to fold the plonk structure & witness. The developer's task here, between steps, is to modify the circuits (over which he retains ownership), also keeping in mind the `z_in` & `z_out` continuity.

### Verify

This step verifies that the constraint system is correct. If you started IVC not in `debug_mode` mode, in this case, only at the moment of `verify` call it is possible to detect violations of the constraint system at any of the steps.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.snarkify.io/sirius-folding/sirius-folding-apis/ivc-struct.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
