Skip to content

Commit

Permalink
Constants for success
Browse files Browse the repository at this point in the history
  • Loading branch information
aumetra committed May 7, 2024
1 parent 043beb1 commit ee64b92
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions packages/vm/src/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,12 @@ const BLS12_381_VALID_PAIRING: u32 = 0;
/// Return code (error code) for an invalid pairing
const BLS12_381_INVALID_PAIRING: u32 = 1;

/// Return code (error code) if the aggregating the points on curve was successful
const BLS12_381_AGGREGATE_SUCCESS: u32 = 0;

/// Return code (error code) for success when hashing to the curve
const BLS12_381_HASH_TO_CURVE_SUCCESS: u32 = 0;

/// Maximum size of continous points passed to aggregate functions
const BLS12_381_MAX_AGGREGATE_SIZE: usize = 2 * MI;

Expand Down Expand Up @@ -280,7 +286,7 @@ pub fn do_bls12_381_aggregate_g1<
Ok(point) => {
let memory = data.memory(&store);
write_region(&memory, out_ptr, &point)?;
0
BLS12_381_AGGREGATE_SUCCESS
}
Err(err) => match err {
CryptoError::InvalidPoint { .. } | CryptoError::Aggregation { .. } => err.code(),
Expand Down Expand Up @@ -324,7 +330,7 @@ pub fn do_bls12_381_aggregate_g2<
Ok(point) => {
let memory = data.memory(&store);
write_region(&memory, out_ptr, &point)?;
0
BLS12_381_AGGREGATE_SUCCESS
}
Err(err) => match err {
CryptoError::InvalidPoint { .. } | CryptoError::Aggregation { .. } => err.code(),
Expand Down Expand Up @@ -423,7 +429,7 @@ pub fn do_bls12_381_hash_to_g1<
let memory = data.memory(&store);
write_region(&memory, out_ptr, &point)?;

Ok(0)
Ok(BLS12_381_HASH_TO_CURVE_SUCCESS)
}

pub fn do_bls12_381_hash_to_g2<
Expand Down Expand Up @@ -455,7 +461,7 @@ pub fn do_bls12_381_hash_to_g2<
let memory = data.memory(&store);
write_region(&memory, out_ptr, &point)?;

Ok(0)
Ok(BLS12_381_HASH_TO_CURVE_SUCCESS)
}

pub fn do_secp256k1_verify<A: BackendApi + 'static, S: Storage + 'static, Q: Querier + 'static>(
Expand Down

0 comments on commit ee64b92

Please sign in to comment.