This repository is maintained by Witness Chain . The project implements an RSA accumulator along with various functionalities for data extraction, benchmarking, and on-chain verification. The code is designed to be efficient, with support for multi-core processing and batching.
The RSA accumulator is a powerful cryptographic tool that allows for the succinct proof of membership or non-membership within a set of elements. This repository provides a robust implementation of the RSA accumulator, including additional scripts for data extraction, benchmarking, and integration with smart contracts for on-chain verification.
-
allFunctions.py
- Contains the basic boilerplate of all functions used in the RSA accumulator.
- This file includes utility functions that are essential for the operation of the accumulator and are reused across multiple scripts.
-
data.py
- Extracts transaction data from a range of blockchain nodes using the Infura API.
- This script serves as the data retrieval backbone, ensuring that transaction data is readily available for the RSA processes.
-
benchmark.py
- Generates 100,000 random hashes to benchmark various aspects of the RSA accumulator.
- The benchmarking focuses on measuring accumulation time, witness generation time, and verification time to evaluate performance.
-
rsa.py
- The core script for performing RSA accumulator operations on the transaction data retrieved by
data.py
. - Handles the core RSA computations necessary for accumulating elements and generating proofs.
- The core script for performing RSA accumulator operations on the transaction data retrieved by
-
rsa_with_delete.py
- Extends the functionality of
rsa.py
by adding the ability to delete elements from the RSA accumulator. - Useful for scenarios where elements need to be dynamically managed within the accumulator.
- Extends the functionality of
-
verify.sol
- A Solidity contract designed for on-chain verification of RSA accumulator proofs.
- Enables integration of RSA accumulator functionalities within blockchain environments, providing a means for decentralized verification.
-
checkpoint.py
- Code to generate and store checkpoints of the accumulator's state.
- Note: This script is still under development and has not yet been fully tested.
-
multi.py and multi1.py
- Implement RSA accumulator operations utilizing multiple processing cores for improved performance.
- These scripts parallelize the RSA computations, making the system more efficient on multi-core processors.
-
witness.json
- Stores all witnesses generated by the
rsa.py
script. - Witnesses are used to prove the membership or non-membership of elements within the accumulator.
- Stores all witnesses generated by the
-
transactions.json
- A storage file for all retrieved transactions and their corresponding hashes.
- Acts as the local database for transaction data that is processed by the RSA accumulator.
-
batchRsa.py
- Implements batching functionality to accumulate multiple elements in a single operation.
- Note: This script is experimental and has not been fully tested yet.
Running RSA Operations:
To perform RSA operations on transaction data, use the rsa.py
script:
python rsa.py
Benchmarking:
To run benchmarks on hash generation, accumulation, and verification times, use the benchmark.py
script:
python benchmark.py
Multi-Core Processing (Experimental):
Utilize multiple processing cores for RSA computations with:
python multi.py
On-Chain Verification:
-
Compile the
verify.sol
contract:You may need to compile the
verify.sol
contract using a Solidity compiler before deploying it on-chain. Here are two options:-
Solidity Compiler (solc):
- Install the Solidity compiler for your environment.
- Use the
solc
command to compile the contract:
solc --bin --abi verify.sol
This will generate two files:
verify.sol.bin
andverify.sol.abi
. You'll need these for deployment. -
Remix IDE:
- Open Remix IDE (https://remix.ethereum.org) and create a new project.
- Paste the contents of
verify.sol
into the editor. - Select the compiler version and environment (e.g., Injected Web3).
- Click the "Compile" button.
- You can then access the compiled bytecode and ABI from the "Compile" tab.
-
-
Deploy the Contract:
Deploy the compiled contract (bytecode) to your preferred blockchain using its deployment tools. The specific steps will vary depending on the blockchain you choose.
-
Interact with the Contract:
Once deployed, interact with the contract's functions (using its ABI) to perform on-chain verification of RSA accumulator proofs. Refer to the blockchain's documentation and smart contract interaction tools for details.
Contributing
Contributions are welcome! Please fork the repository and submit a pull request with your improvements. Ensure that your code adheres to the repository's style guidelines.