Repository: aptos-labs/aptos-core
File: aptos-move/framework/src/natives/cryptography/bulletproofs.rs (Rust)

Code before:
    let v_blindings = pop_scalars_from_bytes(&mut args)?;
    let vs = pop_scalars_from_bytes(&mut args)?;

    if !is_supported_number_of_bits(num_bits) {
        return Err(SafeNativeError::abort_with_message(
            abort_codes::NFE_RANGE_NOT_SUPPORTED,
            format!(
                "Range of {} bits is not supported (must be 8, 16, 32, or 64)",
                num_bits
            ),
        ));
    }
    if !is_supported_batch_size(vs.len()) {
        return Err(SafeNativeError::abort_with_message(
            abort_codes::NFE_BATCH_SIZE_NOT_SUPPORTED,
            format!(
                "Batch size {} is not supported (must be 1, 2, 4, 8, or 16)",
                vs.len()
            ),
        ));
    }
    if vs.len() != v_blindings.len() {
        return Err(SafeNativeError::abort_with_message(
            abort_codes::NFE_VECTOR_LENGTHS_MISMATCH,
            format!(
                "Values length {} does not match blinding factors length {}",
                vs.len(),
                v_blindings.len()
            ),
        ));
    }

    // Make sure only the first 64 bits are set for each Scalar.
    if !vs
        .iter()
        .all(|v| v.as_bytes()[8..].iter().all(|&byte| byte == 0u8))
    {
        return Err(SafeNativeError::abort(abort_codes::NFE_VALUE_OUTSIDE_RANGE));
    }

    // Convert each Scalar to u64.
    let vs = vs
        .iter()
        .map(|v| LittleEndian::read_u64(v.as_bytes()))
        .collect::<Vec<_>>();

    let mut t = Transcript::new(dst.as_slice());

    let pg = {
        let point_context = context.extensions().get::<NativeRistrettoPointContext>();
        let point_data = point_context.point_data.borrow_mut();

Review comment (suggestion):
```
"Number of committed values ({}) must equal number of blinding factors ({})"
```

Code after:
    let v_blindings = pop_scalars_from_bytes(&mut args)?;
    let vs = pop_scalars_from_bytes(&mut args)?;

    if !is_supported_number_of_bits(num_bits) {
        return Err(SafeNativeError::abort_with_message(
            abort_codes::NFE_RANGE_NOT_SUPPORTED,
            format!(
                "Range of {} bits is not supported (must be 8, 16, 32, or 64)",
                num_bits
            ),
        ));
    }
    if !is_supported_batch_size(vs.len()) {
        return Err(SafeNativeError::abort_with_message(
            abort_codes::NFE_BATCH_SIZE_NOT_SUPPORTED,
            format!(
                "Batch size {} is not supported (must be 1, 2, 4, 8, or 16)",
                vs.len()
            ),
        ));
    }
    if vs.len() != v_blindings.len() {
        return Err(SafeNativeError::abort_with_message(
            abort_codes::NFE_VECTOR_LENGTHS_MISMATCH,
            format!(
                "Number of committed values ({}) must equal number of blinding factors ({})",
                vs.len(),
                v_blindings.len()
            ),
        ));
    }

    // Make sure only the first 64 bits are set for each Scalar.
    if !vs
        .iter()
        .all(|v| v.as_bytes()[8..].iter().all(|&byte| byte == 0u8))
    {
        return Err(SafeNativeError::abort(abort_codes::NFE_VALUE_OUTSIDE_RANGE));
    }

    // Convert each Scalar to u64.
    let vs = vs
        .iter()
        .map(|v| LittleEndian::read_u64(v.as_bytes()))
        .collect::<Vec<_>>();

    let mut t = Transcript::new(dst.as_slice());

    let pg = {
        let point_context = context.extensions().get::<NativeRistrettoPointContext>();
        let point_data = point_context.point_data.borrow_mut();