Skip to content

Commit 246ce02

Browse files
committed
Constants for success
1 parent 871c63f commit 246ce02

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

packages/vm/src/imports.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,12 @@ const BLS12_381_VALID_PAIRING: u32 = 0;
247247
/// Return code (error code) for an invalid pairing
248248
const BLS12_381_INVALID_PAIRING: u32 = 1;
249249

250+
/// Return code (error code) if the aggregating the points on curve was successful
251+
const BLS12_381_AGGREGATE_SUCCESS: u32 = 0;
252+
253+
/// Return code (error code) for success when hashing to the curve
254+
const BLS12_381_HASH_TO_CURVE_SUCCESS: u32 = 0;
255+
250256
/// Maximum size of continous points passed to aggregate functions
251257
const BLS12_381_MAX_AGGREGATE_SIZE: usize = 2 * MI;
252258

@@ -280,7 +286,7 @@ pub fn do_bls12_381_aggregate_g1<
280286
Ok(point) => {
281287
let memory = data.memory(&store);
282288
write_region(&memory, out_ptr, &point)?;
283-
0
289+
BLS12_381_AGGREGATE_SUCCESS
284290
}
285291
Err(err) => match err {
286292
CryptoError::InvalidPoint { .. } | CryptoError::Aggregation { .. } => err.code(),
@@ -324,7 +330,7 @@ pub fn do_bls12_381_aggregate_g2<
324330
Ok(point) => {
325331
let memory = data.memory(&store);
326332
write_region(&memory, out_ptr, &point)?;
327-
0
333+
BLS12_381_AGGREGATE_SUCCESS
328334
}
329335
Err(err) => match err {
330336
CryptoError::InvalidPoint { .. } | CryptoError::Aggregation { .. } => err.code(),
@@ -423,7 +429,7 @@ pub fn do_bls12_381_hash_to_g1<
423429
let memory = data.memory(&store);
424430
write_region(&memory, out_ptr, &point)?;
425431

426-
Ok(0)
432+
Ok(BLS12_381_HASH_TO_CURVE_SUCCESS)
427433
}
428434

429435
pub fn do_bls12_381_hash_to_g2<
@@ -455,7 +461,7 @@ pub fn do_bls12_381_hash_to_g2<
455461
let memory = data.memory(&store);
456462
write_region(&memory, out_ptr, &point)?;
457463

458-
Ok(0)
464+
Ok(BLS12_381_HASH_TO_CURVE_SUCCESS)
459465
}
460466

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

0 commit comments

Comments
 (0)