Integrating Aligned into your Application
1. Generate your ZK Proof
2. Write your smart contract
aligned get-commitment --input <path_to_input_file>contract YourContract {
// Your contract variables ...
address public alignedServiceManager;
bytes32 public elfCommitment = <elf_commitment>;
constructor(address _alignedServiceManager) {
//... Your contract constructor ...
alignedServiceManager = _alignedServiceManager;
}
// Your contract code ...
function yourContractMethod(
//... Your function variables, ...
bytes32 proofCommitment,
bytes32 pubInputCommitment,
bytes32 provingSystemAuxDataCommitment,
bytes20 proofGeneratorAddr,
bytes32 batchMerkleRoot,
bytes memory merkleProof,
uint256 verificationDataBatchIndex
) {
// ... Your function code
require(elfCommitment == provingSystemAuxDataCommitment, "ELF does not match");
(bool callWasSuccessful, bytes memory proofIsIncluded) = alignedServiceManager.staticcall(
abi.encodeWithSignature(
"verifyBatchInclusion(bytes32,bytes32,bytes32,bytes20,bytes32,bytes,uint256)",
proofCommitment,
pubInputCommitment,
provingSystemAuxDataCommitment,
proofGeneratorAddr,
batchMerkleRoot,
merkleProof,
verificationDataBatchIndex
)
);
require(callWasSuccessful, "static_call failed");
bool proofIsIncludedBool = abi.decode(proofIsIncluded, (bool));
require(proofIsIncludedBool, "proof not included in batch");
// Your function code ...
}
}3. Submit and verify the proof to Aligned
Using the SDK
Using the CLI
Last updated