fn sanity_check(bitmap: &BitVec<u32>, signatures: &ByteArray, pubkeys: &ByteArray) -> Result<u64> {
    let bitmap_len = bitmap.len();
    let signatures_len = signatures.len();
    let public_keys_len = pubkeys.len();

    // Ensure a BITMAP_SIZE bitmap.
    if bitmap_len != BITMAP_SIZE {
        bail!("Invalid bitmap length");
    }

    let mut bitmap_last_bit_set: usize = 0; // This is fine as we expect at least one set bit.
    let mut bitmap_count_ones: usize = 0;
    for (i, bit) in bitmap.iter().enumerate() {
        if bit {
            bitmap_count_ones += 1;
            bitmap_last_bit_set = i;
        }
    }
    if bitmap_count_ones == 0 {
        bail!("Bitmap is all zeros");
    }
    // Ensure we have as many signatures as the number of set bits in bitmap.
    if bitmap_count_ones * 64 != signatures_len {
        bail!("Mismatch between Bitmap Hamming weight and number of signatures");
    }
    // Ensure that we have at least as many keys as the index of the last set bit in bitmap.
    if public_keys_len < 32 * bitmap_last_bit_set {
        bail!("Bitmap points to a non-existent key");
    }
    // Ensure no more than BITMAP_SIZE keys.
    if public_keys_len > 32 * BITMAP_SIZE {
        bail!("Length of bytes of concatenated keys exceeds the maximum allowed");
    }
    // Ensure ByteArray for keys is a multiple of 32 bytes.
    if public_keys_len % 32 != 0 {
        bail!("Concatenated Ed25519 public keys should be a multiple of 32 bytes");
    }
    Ok(bitmap_count_ones as u64)
}
// Check for correct input sizes and return the number of submitted signatures iff everything is
// valid.
Check for correct input sizes and return the number of submitted signatures iff everything is
valid.
Check for correct input sizes and return the number of submitted signatures iff everything is valid .
fn sanity_check(bitmap: &BitVec<u32>, signatures: &ByteArray, pubkeys: &ByteArray) -> Result<u64> {
    let bitmap_len = bitmap.len();
    let signatures_len = signatures.len();
    let public_keys_len = pubkeys.len();
    // Ensure a BITMAP_SIZE bitmap.
    if bitmap_len != BITMAP_SIZE {
        bail!("Invalid bitmap length");
    }
    let mut bitmap_last_bit_set: usize = 0; // This is fine as we expect at least one set bit.
    let mut bitmap_count_ones: usize = 0;
    for (i, bit) in bitmap.iter().enumerate() {
        if bit {
            bitmap_count_ones += 1;
            bitmap_last_bit_set = i;
        }
    }
    if bitmap_count_ones == 0 {
        bail!("Bitmap is all zeros");
    }
    // Ensure we have as many signatures as the number of set bits in bitmap.
    if bitmap_count_ones * 64 != signatures_len {
        bail!("Mismatch between Bitmap Hamming weight and number of signatures");
    }
    // Ensure that we have at least as many keys as the index of the last set bit in bitmap.
    if public_keys_len < 32 * bitmap_last_bit_set {
        bail!("Bitmap points to a non-existent key");
    }
    // Ensure no more than BITMAP_SIZE keys.
    if public_keys_len > 32 * BITMAP_SIZE {
        bail!("Length of bytes of concatenated keys exceeds the maximum allowed");
    }
    // Ensure ByteArray for keys is a multiple of 32 bytes.
    if public_keys_len % 32 != 0 {
        bail!("Concatenated Ed25519 public keys should be a multiple of 32 bytes");
    }
    Ok(bitmap_count_ones as u64)
}
fn sanity_check ( bitmap : & BitVec < u32 > , signatures : & ByteArray , pubkeys : & ByteArray ) -> Result < u64 > { let bitmap_len = bitmap . len ( ) ; let signatures_len = signatures . len ( ) ; let public_keys_len = pubkeys . len ( ) ; // Ensure a BITMAP_SIZE bitmap. if bitmap_len != BITMAP_SIZE { bail ! ( " " ) ; } let mut bitmap_last_bit_set : usize = 0 ; // This is fine as we expect at least one set bit. let mut bitmap_count_ones : usize = 0 ; for ( i , bit ) in bitmap . iter ( ) . enumerate ( ) { if bit { bitmap_count_ones += 1 ; bitmap_last_bit_set = i ; } } if bitmap_count_ones == 0 { bail ! ( " " ) ; } // Ensure we have as many signatures as the number of set bits in bitmap. if bitmap_count_ones * 64 != signatures_len { bail ! ( " " ) ; } // Ensure that we have at least as many keys as the index of the last set bit in bitmap. if public_keys_len < 32 * bitmap_last_bit_set { bail ! ( " " ) ; } // Ensure no more than BITMAP_SIZE keys. if public_keys_len > 32 * BITMAP_SIZE { bail ! ( " " ) ; } // Ensure ByteArray for keys is a multiple of 32 bytes. if public_keys_len % 32 != 0 { bail ! ( " " ) ; } Ok ( bitmap_count_ones as u64 ) }
Check for correct input sizes and return the number of submitted signatures iff everything is
valid.
Check for correct input sizes and return the number of submitted signatures iff everything is valid .
bitmap
&BitVec<u32>
signatures
&ByteArray
pubkeys
&ByteArray
bitmap
&BitVec<u32>
signatures
&ByteArray
pubkeys
&ByteArray