-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* adding bare changes for batch verification * adding some comments * adding more comments * moving back to sha2 * removing a test which is no longer needed. Removing methods no longer needed * updates to method visibility, updating tests * fmt fixes * clean up * cleanup, optimization, inline docs * removing unwanted const * more docs and cleanup * formatting * removing unwanted comments * cargo fmt and clippy * adding test for point at infinity * cleaner errors, cleanup * adding another test case * removing unwanted errors * adding fixes per comments * adding 4844 spec references * comment fixes * formatting, adding index out of bound check, removing print statement * removing unwanted test, adding test for evaluate_polynomial_in_evaluation_form * moving test to bottom section * Update src/polynomial.rs Co-authored-by: Samuel Laferriere * Update src/kzg.rs Co-authored-by: Samuel Laferriere * Update src/kzg.rs Co-authored-by: Samuel Laferriere * Update src/kzg.rs Co-authored-by: Samuel Laferriere * Update src/helpers.rs Co-authored-by: Samuel Laferriere * updating deps, and toolchain to 1.84 * removing errors test, no longer useful * adding to_byte_array arg explanation * fmt fixes * fmt and clippy fixes * fixing function names and fmt * clippy fixes * Update src/helpers.rs Co-authored-by: Samuel Laferriere * changes based on comments and discussion --------- Co-authored-by: anupsv <[email protected]> Co-authored-by: Samuel Laferriere Co-authored-by: Bowen Xue <[email protected]>
- Loading branch information
1 parent
946a634
commit 4ad14ea
Showing
12 changed files
with
1,328 additions
and
647 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
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
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
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,5 +1,5 @@ | ||
[toolchain] | ||
channel = '1.75' | ||
channel = '1.81' | ||
profile = 'minimal' | ||
components = ['clippy', 'rustfmt'] | ||
targets = ["x86_64-unknown-linux-gnu", "x86_64-pc-windows-gnu", "wasm32-unknown-unknown", "aarch64-apple-darwin"] |
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
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,3 +1,17 @@ | ||
pub const BYTES_PER_FIELD_ELEMENT: usize = 32; | ||
pub const SIZE_OF_G1_AFFINE_COMPRESSED: usize = 32; // in bytes | ||
pub const SIZE_OF_G2_AFFINE_COMPRESSED: usize = 64; // in bytes | ||
|
||
/// Ref: https://github.com/ethereum/consensus-specs/blob/master/specs/deneb/polynomial-commitments.md#blob | ||
pub const FIAT_SHAMIR_PROTOCOL_DOMAIN: &[u8] = b"EIGENDA_FSBLOBVERIFY_V1_"; // Adapted from 4844 | ||
|
||
/// Ref: https://github.com/ethereum/consensus-specs/blob/master/specs/deneb/polynomial-commitments.md#blob | ||
pub const RANDOM_CHALLENGE_KZG_BATCH_DOMAIN: &[u8] = b"EIGENDA_RCKZGBATCH___V1_"; // Adapted from 4844 | ||
|
||
pub const KZG_ENDIANNESS: Endianness = Endianness::Big; // Choose between Big or Little. | ||
|
||
#[derive(Debug, Clone, Copy)] | ||
pub enum Endianness { | ||
Big, | ||
Little, | ||
} |
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,64 +1,64 @@ | ||
use std::{error::Error, fmt}; | ||
use thiserror::Error; | ||
|
||
#[derive(Clone, Debug, PartialEq)] | ||
pub enum BlobError { | ||
GenericError(String), | ||
} | ||
|
||
impl fmt::Display for BlobError { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
match *self { | ||
BlobError::GenericError(ref msg) => write!(f, "generic error: {}", msg), | ||
} | ||
} | ||
} | ||
|
||
impl Error for BlobError {} | ||
|
||
#[derive(Clone, Debug, PartialEq)] | ||
/// Errors related to Polynomial operations. | ||
/// | ||
/// The `PolynomialError` enum encapsulates all possible errors that can occur | ||
/// during operations on the `Polynomial` struct, such as FFT transformations | ||
/// and serialization errors. | ||
#[derive(Clone, Debug, PartialEq, Error)] | ||
pub enum PolynomialError { | ||
SerializationFromStringError, | ||
/// Error related to commitment operations with a descriptive message. | ||
#[error("commitment error: {0}")] | ||
CommitError(String), | ||
GenericError(String), | ||
|
||
/// Error related to Fast Fourier Transform (FFT) operations with a descriptive message. | ||
#[error("FFT error: {0}")] | ||
FFTError(String), | ||
IncorrectFormError(String), | ||
} | ||
|
||
impl fmt::Display for PolynomialError { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
match *self { | ||
PolynomialError::SerializationFromStringError => { | ||
write!(f, "couldn't load string to fr vector") | ||
}, | ||
PolynomialError::CommitError(ref msg) => write!(f, "Commitment error: {}", msg), | ||
PolynomialError::FFTError(ref msg) => write!(f, "FFT error: {}", msg), | ||
PolynomialError::GenericError(ref msg) => write!(f, "generic error: {}", msg), | ||
PolynomialError::IncorrectFormError(ref msg) => { | ||
write!(f, "Incorrect form error: {}", msg) | ||
}, | ||
} | ||
} | ||
/// A generic error with a descriptive message. | ||
#[error("generic error: {0}")] | ||
GenericError(String), | ||
} | ||
|
||
impl Error for PolynomialError {} | ||
|
||
#[derive(Clone, Debug, PartialEq)] | ||
/// Errors related to KZG operations. | ||
/// | ||
/// The `KzgError` enum encapsulates all possible errors that can occur during | ||
/// KZG-related operations, including those from `PolynomialError` and `BlobError`. | ||
/// It also includes additional errors specific to KZG operations. | ||
#[derive(Clone, Debug, PartialEq, Error)] | ||
pub enum KzgError { | ||
CommitError(String), | ||
/// Wraps errors originating from Polynomial operations. | ||
#[error("polynomial error: {0}")] | ||
PolynomialError(#[from] PolynomialError), | ||
|
||
#[error("MSM error: {0}")] | ||
MsmError(String), | ||
|
||
/// Error related to serialization with a descriptive message. | ||
#[error("serialization error: {0}")] | ||
SerializationError(String), | ||
FftError(String), | ||
|
||
/// Error related to commitment processes with a descriptive message. | ||
#[error("not on curve error: {0}")] | ||
NotOnCurveError(String), | ||
|
||
/// Error indicating an invalid commit operation with a descriptive message. | ||
#[error("commit error: {0}")] | ||
CommitError(String), | ||
|
||
/// Error related to Fast Fourier Transform (FFT) operations with a descriptive message. | ||
#[error("FFT error: {0}")] | ||
FFTError(String), | ||
|
||
/// A generic error with a descriptive message. | ||
#[error("generic error: {0}")] | ||
GenericError(String), | ||
} | ||
|
||
impl fmt::Display for KzgError { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
match *self { | ||
KzgError::CommitError(ref msg) => write!(f, "Commitment error: {}", msg), | ||
KzgError::SerializationError(ref msg) => write!(f, "Serialization error: {}", msg), | ||
KzgError::FftError(ref msg) => write!(f, "FFT error: {}", msg), | ||
KzgError::GenericError(ref msg) => write!(f, "Generic error: {}", msg), | ||
} | ||
} | ||
} | ||
/// Error indicating an invalid denominator scenario, typically in mathematical operations. | ||
#[error("invalid denominator")] | ||
InvalidDenominator, | ||
|
||
impl Error for KzgError {} | ||
/// Error indicating an invalid input length scenario, typically in data processing. | ||
#[error("invalid input length")] | ||
InvalidInputLength, | ||
} |
Oops, something went wrong.