Skip to content

Commit 2e2cd7f

Browse files
committed
chore: move serialization errors into error module
1 parent 6cd60e2 commit 2e2cd7f

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

eip7594/src/errors.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::{serialization::SerializationError, CellID};
1+
use crate::CellID;
22

33
/// Errors that can occur while calling a method in the Prover API
44
#[derive(Debug)]
@@ -45,3 +45,13 @@ pub enum VerifierError {
4545
proofs_len: usize,
4646
},
4747
}
48+
49+
/// Errors that can occur during deserialization of untrusted input from the public API
50+
#[derive(Debug)]
51+
pub enum SerializationError {
52+
CouldNotDeserializeScalar { bytes: Vec<u8> },
53+
CouldNotDeserializeG1Point { bytes: Vec<u8> },
54+
ScalarHasInvalidLength { bytes: Vec<u8>, length: usize },
55+
BlobHasInvalidLength { bytes: Vec<u8>, length: usize },
56+
G1PointHasInvalidLength { bytes: Vec<u8>, length: usize },
57+
}

eip7594/src/serialization.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,7 @@ use crate::constants::{
33
};
44
use bls12_381::{G1Point, Scalar};
55

6-
#[derive(Debug)]
7-
pub enum SerializationError {
8-
CouldNotDeserializeScalar { bytes: Vec<u8> },
9-
CouldNotDeserializeG1Point { bytes: Vec<u8> },
10-
ScalarHasInvalidLength { bytes: Vec<u8>, length: usize },
11-
BlobHasInvalidLength { bytes: Vec<u8>, length: usize },
12-
G1PointHasInvalidLength { bytes: Vec<u8>, length: usize },
13-
}
6+
pub use crate::errors::SerializationError;
147

158
fn deserialize_bytes_to_scalars(bytes: &[u8]) -> Result<Vec<Scalar>, SerializationError> {
169
// Check that the bytes are a multiple of the scalar size

0 commit comments

Comments
 (0)