# Integrating Aligned into your Application

Aligned can be integrated into your applications in a few simple steps to provide a way to verify ZK proofs generated inside your system.

You can find an example of the full flow of using Aligned in your app in the ZKQuiz example.

This example shows a sample app that generates an SP1 proof that a user knows the answers to a quiz and then submits the proof to Aligned for verification. Finally, it includes a smart contract that verifies that a proof was verified in Aligned and mints an NFT.

## 1. Generate your ZK Proof

To submit proofs to Aligned and get them verified, first you need to generate those proofs. Every proving system has its own way of generating proofs.

You can find examples on how to generate proofs in the generating proofs guide.

Also, you can find an example of the ZKQuiz proof program as well as the script that generates it in the ZKQuiz example directory.

## 2. Write your smart contract

To check if a proof was verified in Aligned, you need to make a call to the `AlignedServiceManager`

contract inside your smart contract.

Also, you will need a way to check that the proven program is the correct one.

The Aligned CLI provides a way for you to get the verification key commitment without actually generating and submitting a proof.

You can do this by running the following command:

The following is an example of how to call the `verifyBatchInclusionMethod`

from the `AlignedServiceManager`

contract in your smart contract.

You can find an example of the smart contract that checks if the proof was verified in Aligned in the Quiz Verifier Contract.

Note that the contract checks if the verification key commitment is the same as the program ELF commitment.

This contract also includes a static call to the `AlignedServiceManager`

contract to check if the proof was verified in Aligned.

## 3. Submit and verify the proof to Aligned

The proof submission and verification can be done either with the SDK or by using the Aligned CLI.

#### Using the SDK

To submit a proof using the SDK, you can use the `submit_and_wait_verification`

function. This function submits the proof to aligned and waits for it to be verified in Aligned. Alternatively you can call `submit`

if you dont want to wait for proof verification. The following code is an example of how to submit a proof using the SDK:

You can find an example of the proof submission and verification in the ZKQuiz Program.

This example generates a proof, instantiates a wallet to submit the proof, and then submits the proof to Aligned for verification. It then waits for the proof to be verified in Aligned.

#### Using the CLI

You can find examples of how to submit a proof using the CLI in the submitting proofs guide.

Last updated