-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Layr-Labs/update-readme-and-update-license
Update readme and add license
- Loading branch information
Showing
2 changed files
with
38 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Copyright 2024 Layr Labs, Inc. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,52 @@ | ||
# rust-kzg-bn254 | ||
|
||
## Description | ||
This library is primarly designed to integrate with Eigen DA from the context of 4844 and Fraud Proofs. | ||
|
||
This library offers a set of functions for generating and interacting with bn254 KZG commitments and proofs in rust, with the motivation of supporting fraud and validity proof logic in EigenDA rollup integrations. | ||
|
||
## Warning & Disclaimer | ||
|
||
This code is unaudited and under construction. This is experimental software and is provided on an "as is" and "as available" basis and may not work at all. It should not be used in production. | ||
|
||
## Setup for testing | ||
|
||
1. To test, please download the provided G1 and G2 points from [DA Resources](https://github.com/Layr-Labs/eigenda/tree/master/inabox/resources/kzg), | ||
2. Specify these files in the `kzg.setup()` function, leave the `g2_power_of2_path` empty, and specify `srs_order` to be 3000. | ||
|
||
## Setup to replicate Eigen DA Mainnet | ||
## Configuring with the EigenDA KZG trusted setup | ||
|
||
1. Follow the setup instructions to download the G1 and G2 powers of 2 points from the [Operator Setup Guide](https://github.com/Layr-Labs/eigenda-operator-setup) | ||
2. Specify the files in `kzg.setup()` function, leave the `g2_points` empty, and specify the `srs_order` per the guide. | ||
3. Note that this is process will take a few minutes to load since it is a bit intensive. | ||
|
||
## Quick Start | ||
|
||
1. Check the test in `test_compute_kzg_proof` function to see the end to end usage of the library for quick start. | ||
|
||
## Requirements | ||
1. SRS points required are in the same format as provided by the Eigen DA. | ||
2. Commiting is performed in lagrange format. The required IFFT is done within the function and is not required to be performed separately. | ||
|
||
1. SRS points required are in the same format as provided by the EigenDA. | ||
2. Commiting is performed in lagrange format. The required IFFT is done within the function and is not required to be performed separately. | ||
3. For proof generation, the data is treated as evaluation of polynomial. The required (i)FFT is performed by the compute function and is not required to be performed separately. | ||
|
||
## Details of functions | ||
1. The `Blob` is loaded with `from_bytes_and_pad` which accepts bytes and "pads" it so that the data fits within the requirements of Eigen DA functioning. It also keeps track of the blob length after padding. | ||
2. From the `Blob`, a polynomial can be obtained via calling the `to_polynomial()` function. This converts the Blob to Field elements, then calculates the next power of 2 from this length of field elements and appends `zero` value elements for the remaining length. | ||
3. The `data_setup_custom` (for testing) or `data_setup_mins` should be used to specify the number of chunks and chunk length. These parameters are used to calculate the FFT params required for FFT operations. | ||
4. The `commit` function takes in a `polynomial`. It is computed over `lagrange` basis by performing the (i)FFT. | ||
5. The `compute_kzg_proof_with_roots_of_unity` takes in a `Polynomial` and an `index` at which it needs to be computed. | ||
## Function Reference | ||
|
||
### `from_bytes_and_pad()` | ||
|
||
The `Blob` is loaded with `from_bytes_and_pad` which accepts bytes and "pads" it so that the data fits within the requirements of Eigen DA functioning. It also keeps track of the blob length after padding. | ||
|
||
### `to_polynomial()` | ||
|
||
From the `Blob`, a polynomial can be obtained via calling the `to_polynomial()` function. This converts the Blob to Field elements, then calculates the next power of 2 from this length of field elements and appends `zero` value elements for the remaining length. | ||
|
||
### `data_setup_custom` and `data_setup_mins` parameters | ||
|
||
The `data_setup_custom` (for testing) or `data_setup_mins` should be used to specify the number of chunks and chunk length. These parameters are used to calculate the FFT params required for FFT operations. | ||
|
||
### `commit()` | ||
|
||
The `commit` function takes in a `polynomial`. It is computed over `lagrange` basis by performing the (i)FFT. | ||
|
||
### `compute_kzg_proof_with_roots_of_unity()` | ||
|
||
The `compute_kzg_proof_with_roots_of_unity` takes in a `Polynomial` and an `index` at which it needs to be computed. |