|
1 | | -# Aligned SDK |
| 1 | +# Aggregation Mode SDK |
2 | 2 |
|
3 | | -## API Reference for aggregation mode |
| 3 | +## API Reference |
4 | 4 |
|
5 | | -### `is_proof_verified_in_aggregation_mode` |
| 5 | +### `AggregationModeGatewayProvider` |
6 | 6 |
|
7 | | -Checks if the proof has been verified with Aligned Aggregation Mode. |
| 7 | +The gateway provider handles communication with the Aggregation Mode Gateway for submitting proofs and querying proof status. |
| 8 | + |
| 9 | +--- |
| 10 | + |
| 11 | +### `AggregationModeGatewayProvider::new` |
| 12 | + |
| 13 | +Creates a new gateway provider without a signer. Useful for read-only operations like checking nonces or receipts. |
| 14 | + |
| 15 | +```rust |
| 16 | +pub fn new(network: Network) -> Result<Self, GatewayError> |
| 17 | +``` |
| 18 | + |
| 19 | +#### Arguments |
| 20 | + |
| 21 | +- `network` - The network to connect to (`Devnet | Hoodi | Mainnet`) |
| 22 | + |
| 23 | +#### Returns |
| 24 | + |
| 25 | +- `Result<AggregationModeGatewayProvider, GatewayError>` - A gateway provider instance or an error. |
| 26 | + |
| 27 | +--- |
| 28 | + |
| 29 | +### `AggregationModeGatewayProvider::new_with_signer` |
| 30 | + |
| 31 | +Creates a new gateway provider with a signer. Required for submitting proofs. |
| 32 | + |
| 33 | +```rust |
| 34 | +pub fn new_with_signer(network: Network, signer: S) -> Result<Self, GatewayError> |
| 35 | +``` |
| 36 | + |
| 37 | +#### Arguments |
| 38 | + |
| 39 | +- `network` - The network to connect to (`Devnet | Hoodi | Mainnet`) |
| 40 | +- `signer` - A signer implementing the `Signer` trait (e.g., `PrivateKeySigner`) |
| 41 | + |
| 42 | +#### Returns |
| 43 | + |
| 44 | +- `Result<AggregationModeGatewayProvider, GatewayError>` - A gateway provider instance or an error. |
| 45 | + |
| 46 | +--- |
| 47 | + |
| 48 | +### `get_nonce_for` |
| 49 | + |
| 50 | +Retrieves the current nonce for a given address. |
| 51 | + |
| 52 | +```rust |
| 53 | +pub async fn get_nonce_for( |
| 54 | + &self, |
| 55 | + address: String, |
| 56 | +) -> Result<GatewayResponse<NonceResponse>, GatewayError> |
| 57 | +``` |
| 58 | + |
| 59 | +#### Arguments |
| 60 | + |
| 61 | +- `address` - The Ethereum address to query the nonce for. |
| 62 | + |
| 63 | +#### Returns |
| 64 | + |
| 65 | +- `Result<GatewayResponse<NonceResponse>, GatewayError>` - The nonce response or an error. |
| 66 | + |
| 67 | +--- |
| 68 | + |
| 69 | +### `get_receipts_for` |
| 70 | + |
| 71 | +Retrieves proof submission receipts for a given address. |
| 72 | + |
| 73 | +```rust |
| 74 | +pub async fn get_receipts_for( |
| 75 | + &self, |
| 76 | + address: String, |
| 77 | + nonce: Option<u64>, |
| 78 | +) -> Result<GatewayResponse<ReceiptsResponse>, GatewayError> |
| 79 | +``` |
| 80 | + |
| 81 | +#### Arguments |
| 82 | + |
| 83 | +- `address` - The Ethereum address to query receipts for. |
| 84 | +- `nonce` - Optional nonce to filter receipts by a specific submission. |
| 85 | + |
| 86 | +#### Returns |
| 87 | + |
| 88 | +- `Result<GatewayResponse<ReceiptsResponse>, GatewayError>` - The receipts response or an error. |
| 89 | + |
| 90 | +--- |
| 91 | + |
| 92 | +### `submit_sp1_proof` |
| 93 | + |
| 94 | +Submits an SP1 proof to the Aggregation Mode Gateway. |
8 | 95 |
|
9 | 96 | ```rust |
10 | | -pub async fn is_proof_verified_in_aggregation_mode( |
| 97 | +pub async fn submit_sp1_proof( |
| 98 | + &self, |
| 99 | + proof: &SP1ProofWithPublicValues, |
| 100 | + vk: &SP1VerifyingKey, |
| 101 | +) -> Result<GatewayResponse<SubmitProofResponse>, GatewayError> |
| 102 | +``` |
| 103 | + |
| 104 | +#### Arguments |
| 105 | + |
| 106 | +- `proof` - The SP1 proof with public values. |
| 107 | +- `vk` - The SP1 verifying key. |
| 108 | + |
| 109 | +#### Returns |
| 110 | + |
| 111 | +- `Result<GatewayResponse<SubmitProofResponse>, GatewayError>` - The submission response containing a task ID, or an error. |
| 112 | + |
| 113 | +#### Errors |
| 114 | + |
| 115 | +- `SignerNotConfigured` - If the provider was created without a signer. |
| 116 | +- `ProofSerialization` - If there is an error serializing the proof or verifying key. |
| 117 | +- `MessageSignature` - If there is an error signing the submission message. |
| 118 | +- `Request` - If there is a network error communicating with the gateway. |
| 119 | +- `Api` - If the gateway returns an error response. |
| 120 | + |
| 121 | +--- |
| 122 | + |
| 123 | +### `ProofAggregationServiceProvider` |
| 124 | + |
| 125 | +The blockchain provider handles verification of proofs on-chain by querying the AlignedProofAggregationService contract. |
| 126 | + |
| 127 | +--- |
| 128 | + |
| 129 | +### `ProofAggregationServiceProvider::new` |
| 130 | + |
| 131 | +Creates a new blockchain provider for verifying proofs on-chain. |
| 132 | + |
| 133 | +```rust |
| 134 | +pub fn new(network: Network, rpc_url: String, beacon_client_url: String) -> Self |
| 135 | +``` |
| 136 | + |
| 137 | +#### Arguments |
| 138 | + |
| 139 | +- `network` - The network to connect to (`Devnet | Hoodi | Mainnet`) |
| 140 | +- `rpc_url` - The Ethereum RPC provider URL. |
| 141 | +- `beacon_client_url` - The Beacon chain client URL. |
| 142 | + |
| 143 | +#### Returns |
| 144 | + |
| 145 | +- `ProofAggregationServiceProvider` - A blockchain provider instance. |
| 146 | + |
| 147 | +--- |
| 148 | + |
| 149 | +### `check_proof_verification` |
| 150 | + |
| 151 | +Checks if a proof has been verified on-chain. |
| 152 | + |
| 153 | +```rust |
| 154 | +pub async fn check_proof_verification( |
| 155 | + &self, |
| 156 | + from_block: Option<u64>, |
11 | 157 | verification_data: AggregationModeVerificationData, |
12 | | - network: Network, |
13 | | - eth_rpc_url: &str, |
14 | | - beacon_client_url: &str, |
15 | | - from_block: Option<u64> |
16 | | -) -> Result<[u8; 32], ProofVerificationAggModeError> |
| 158 | +) -> Result<ProofStatus, ProofVerificationAggModeError> |
17 | 159 | ``` |
18 | 160 |
|
19 | 161 | #### Arguments |
20 | 162 |
|
21 | | -- `verification_data` - The verification data needed based on the provided proving system. |
22 | | -- `network` - The network on which the verification will be done (`devnet | holesky | mainnet | hoodi`) |
23 | | -- `eth_rpc_url` - The URL of the Ethereum RPC node. |
| 163 | +- `from_block` - Optional block number to start searching from. Defaults to current block minus 7500 blocks (~25 hours). |
| 164 | +- `verification_data` - The verification data containing the proving system type, verifying key hash, and public inputs. |
24 | 165 |
|
25 | 166 | #### Returns |
26 | 167 |
|
27 | | -- `Result<[u8; 32], ProofVerificationAggModeError>` - The merkle root of the aggregated proof. |
| 168 | +- `Result<ProofStatus, ProofVerificationAggModeError>` - The proof status or an error. |
| 169 | + |
| 170 | +#### Proof Status |
| 171 | + |
| 172 | +- `Verified { merkle_path, merkle_root }` - The proof was found and verified in an aggregated batch. |
| 173 | +- `Invalid` - The proof was found but Merkle root verification failed. |
| 174 | +- `NotFound` - The proof was not found in any aggregated batch. |
28 | 175 |
|
29 | 176 | #### Errors |
30 | 177 |
|
31 | | -- `ProvingSystemNotSupportedInAggMode` if the proving system is not supported (Currently, only SP1 compressed proofs are supported). |
32 | | -- `EthereumProviderError` if there is an error in the Ethereum call. |
33 | | -- `BeaconClient` if there is an error in the Beacon client call. |
34 | | -- `UnmatchedBlobAndEventMerkleRoot` if the proof was in included in the blob but the merkle root did not match with the one in the contract |
35 | | -- `ProofNotFoundInLogs` if the proof was not found in any of the aggregated proofs from the specified block_number |
36 | | -- `EventDecoding`: if it failed to decode an event from the ProofAggregationService |
| 178 | +- `EthereumProviderError` - If there is an error communicating with the Ethereum RPC. |
| 179 | +- `BeaconClient` - If there is an error communicating with the Beacon chain. |
| 180 | +- `EventDecoding` - If there is an error decoding the on-chain event data. |
| 181 | + |
| 182 | +--- |
| 183 | + |
| 184 | +## Types |
| 185 | + |
| 186 | +### `Network` |
| 187 | + |
| 188 | +```rust |
| 189 | +pub enum Network { |
| 190 | + Devnet, // Chain ID: 31337 |
| 191 | + Hoodi, // Chain ID: 560048 |
| 192 | + Mainnet, // Chain ID: 1 |
| 193 | +} |
| 194 | +``` |
| 195 | + |
| 196 | +### `AggregationModeVerificationData` |
| 197 | + |
| 198 | +```rust |
| 199 | +pub enum AggregationModeVerificationData { |
| 200 | + SP1 { |
| 201 | + vk: [u8; 32], |
| 202 | + public_inputs: Vec<u8>, |
| 203 | + }, |
| 204 | +} |
| 205 | +``` |
| 206 | + |
| 207 | +### `GatewayError` |
| 208 | + |
| 209 | +```rust |
| 210 | +pub enum GatewayError { |
| 211 | + Request(String), |
| 212 | + Api { status: u16, message: String }, |
| 213 | + SignerNotConfigured, |
| 214 | + ProofSerialization(String), |
| 215 | + MessageSignature(String), |
| 216 | +} |
| 217 | +``` |
| 218 | + |
| 219 | +### `ProofStatus` |
| 220 | + |
| 221 | +```rust |
| 222 | +pub enum ProofStatus { |
| 223 | + Verified { |
| 224 | + merkle_path: Vec<[u8; 32]>, |
| 225 | + merkle_root: [u8; 32], |
| 226 | + }, |
| 227 | + Invalid, |
| 228 | + NotFound, |
| 229 | +} |
| 230 | +``` |
0 commit comments