SDK
The Aligned SDK aims to help developers interact with Aligned in a simple way. Some of its functionalities include submitting and verifying proofs through the Aligned Batcher, as well as checking the inclusion of the verified proofs on-chain. This guide provides an overview of the SDK, its installation, usage, and API details.
You can check the list of supported verifiers here.
Installation
To use this SDK in your Rust project, add the following to your Cargo.toml:
[dependencies]
aligned-sdk = { git = "https://github.com/yetanotherco/aligned_layer", tag="v0.3.0" }To find the latest release tag go to releases and copy the version of the release that has the latest badge.
API Reference
submit
Submits a proof to the batcher to be verified and returns an aligned verification data struct.
pub async fn submit(
batcher_addr: &str,
verification_data: &VerificationData,
wallet: Wallet<SigningKey>,
) -> Result<Option<AlignedVerificationData>, errors::SubmitError>Arguments
batcher_addr- The address of the batcher to which the proof will be submitted.verification_data- The verification data for the proof.wallet- The wallet used to sign the proof.
Returns
Result<Option<AlignedVerificationData>>, SubmitError>- An aligned verification data or an error.
Errors
MissingRequiredParameterif the verification data vector is empty.ProtocolVersionMismatchif the version of the SDK is lower than the expected one.UnexpectedBatcherResponseif the batcher doesn't respond with the expected message.SerializationErrorif there is an error deserializing the message sent from the batcher.WebSocketConnectionErrorif there is an error connecting to the batcher.WebSocketClosedUnexpectedlyErrorif the connection with the batcher is closed unexpectedly.GenericErrorif the error doesn't match any of the previous ones.
submit_multiple
Submits multiple proofs to the batcher to be verified and returns an aligned verification data array.
Arguments
batcher_addr- The address of the batcher to which the proof will be submitted.verification_data- A verification data array.wallet- The wallet used to sign the proof.
Returns
Result<Option<Vec<AlignedVerificationData>>>, SubmitError>- An aligned verification data array or an error.
Errors
MissingRequiredParameterif the verification data vector is empty.ProtocolVersionMismatchif the version of the SDK is lower than the expected one.UnexpectedBatcherResponseif the batcher doesn't respond with the expected message.SerializationErrorif there is an error deserializing the message sent from the batcher.WebSocketConnectionErrorif there is an error connecting to the batcher.WebSocketClosedUnexpectedlyErrorif the connection with the batcher is closed unexpectedly.GenericErrorif the error doesn't match any of the previous ones.
submit_and_wait
Submits a proof to the batcher to be verified, waits for the verification on ethereum and returns an aligned verification data struct.
Arguments
batcher_addr- The address of the batcher to which the proof will be submitted.eth_rpc_url- The URL of the Ethereum RPC node.chain- The chain on which the verification will be done.verification_data- The verification data for the proof.wallet- The wallet used to sign the proof.
Returns
Result<Option<AlignedVerificationData>>, SubmitError>- An aligned verification data or an error.
Errors
MissingRequiredParameterif the verification data vector is empty.ProtocolVersionMismatchif the version of the SDK is lower than the expected one.UnexpectedBatcherResponseif the batcher doesn't respond with the expected message.SerializationErrorif there is an error deserializing the message sent from the batcher.WebSocketConnectionErrorif there is an error connecting to the batcher.WebSocketClosedUnexpectedlyErrorif the connection with the batcher is closed unexpectedly.EthereumProviderErrorif there is an error in the connection with the RPC provider.HexDecodingErrorif there is an error decoding the Aligned service manager contract address.BatchVerificationTimeoutif there is a timeout waiting for the batch verification.GenericErrorif the error doesn't match any of the previous ones.
submit_multiple_and_wait
Submits multiple proofs to the batcher to be verified, waits for the verification on Ethereum and returns an aligned verification data array.
Arguments
batcher_addr- The address of the batcher to which the proof will be submitted.eth_rpc_url- The URL of the Ethereum RPC node.chain- The chain on which the verification will be done.verification_data- A verification data array.wallet- The wallet used to sign the proof.
Returns
Result<Option<Vec<AlignedVerificationData>>>, SubmitError>- An aligned verification data array or an error.
Errors
MissingRequiredParameterif the verification data vector is empty.ProtocolVersionMismatchif the version of the SDK is lower than the expected one.UnexpectedBatcherResponseif the batcher doesn't respond with the expected message.SerializationErrorif there is an error deserializing the message sent from the batcher.WebSocketConnectionErrorif there is an error connecting to the batcher.WebSocketClosedUnexpectedlyErrorif the connection with the batcher is closed unexpectedly.EthereumProviderErrorif there is an error in the connection with the RPC provider.HexDecodingErrorif there is an error decoding the Aligned service manager contract address.BatchVerificationTimeoutif there is a timeout waiting for the batch verification.GenericErrorif the error doesn't match any of the previous ones.
verify_proof_onchain
Checks if the proof has been verified with Aligned and is included in the batch on-chain.
Arguments
aligned_verification_data- The aligned verification data obtained when submitting the proofs.chain- The chain on which the verification will be done.eth_rpc_url- The URL of the Ethereum RPC node.
Returns
Result<bool, VerificationError>- A boolean indicating whether the proof was verified on-chain and is included in the batch or an error.
Errors
EthereumProviderErrorif there is an error in the connection with the RPC provider.EthereumCallErrorif there is an error in the Ethereum call.HexDecodingErrorif there is an error decoding the Aligned service manager contract address.
get_commitment
Generates a keccak256 hash commitment of the verification key.
Arguments
content- A byte slice of the verification key.
Returns
[u8; 32]- A 32-byte array representing the keccak256 hash of the verification key.
Last updated