Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions ethbloom/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@
//! use std::str::FromStr;
//! let bloom = Bloom::from_str(
//! "00000000000000000000000000000000\
//! 00000000100000000000000000000000\
//! 00000000000000000000000000000000\
//! 00000000000000000000000000000000\
//! 00000000000000000000000000000000\
//! 00000000000000000000000000000000\
//! 00000002020000000000000000000000\
//! 00000000000000000000000800000000\
//! 10000000000000000000000000000000\
//! 00000000000000000000001000000000\
//! 00000000000000000000000000000000\
//! 00000000000000000000000000000000\
//! 00000000000000000000000000000000\
//! 00000000000000000000000000000000\
//! 00000000000000000000000000000000\
//! 00000000000000000000000000000000"
//! ).unwrap();
//! 00000000100000000000000000000000\
//! 00000000000000000000000000000000\
//! 00000000000000000000000000000000\
//! 00000000000000000000000000000000\
//! 00000000000000000000000000000000\
//! 00000002020000000000000000000000\
//! 00000000000000000000000800000000\
//! 10000000000000000000000000000000\
//! 00000000000000000000001000000000\
//! 00000000000000000000000000000000\
//! 00000000000000000000000000000000\
//! 00000000000000000000000000000000\
//! 00000000000000000000000000000000\
//! 00000000000000000000000000000000\
//! 00000000000000000000000000000000"
//! ).unwrap();
//! let address = hex!("ef2d6d194084c2de36e0dabfce45d046b37d1106");
//! let topic = hex!("02c69be41d0b7e40352fc85be1cd65eb03d40ef8427a0ca4596b1ead9a00e9fc");
//!
Expand Down
2 changes: 1 addition & 1 deletion fixed-hash/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ rand = { version = "0.7", optional = true, default-features = false }
rustc-hex = { version = "2.0", optional = true, default-features = false }
quickcheck = { version = "0.9", optional = true }
byteorder = { version = "1.2", optional = true, default-features = false }
static_assertions = "0.3"
static_assertions = "1.0.0"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm afraid this is technically a breaking change, since we pub use static_assertions;, but this is unlikely to be a problem in practice.


[dev-dependencies]
rand_xorshift = "0.2.0"
Expand Down
1 change: 0 additions & 1 deletion fixed-hash/src/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,6 @@ macro_rules! impl_ops_for_hash {
macro_rules! impl_fixed_hash_conversions {
($large_ty:ident, $small_ty:ident) => {
$crate::static_assertions::const_assert!(
VALID_SIZES;
$crate::core_::mem::size_of::<$small_ty>() < $crate::core_::mem::size_of::<$large_ty>()
);

Expand Down
2 changes: 1 addition & 1 deletion keccak-hash/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ mod tests {
keccak([0x41u8; 32]),
H256([
0x59, 0xca, 0xd5, 0x94, 0x86, 0x73, 0x62, 0x2c,
0x1d, 0x64, 0xe2, 0x32, 0x24, 0x88, 0xbf, 0x01,
0x1d, 0x64, 0xe2, 0x32, 0x24, 0x88, 0xbf, 0x01,
0x61, 0x9f, 0x7f, 0xf4, 0x57, 0x89, 0x74, 0x1b,
0x15, 0xa9, 0xf7, 0x82, 0xce, 0x92, 0x90, 0xa8
]),
Expand Down
2 changes: 1 addition & 1 deletion parity-crypto/benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ fn input_len(c: &mut Criterion) {
let mut dest = vec![0; *size];
let k = [0; 16];
let iv = [0; 16];

b.iter(||{
parity_crypto::aes::encrypt_128_ctr(&k[..], &iv[..], &data[..], &mut dest[..]).unwrap();
// same as encrypt but add it just in case
Expand Down
4 changes: 2 additions & 2 deletions parity-crypto/src/aes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ impl AesCtr256 {
))
}

/// In place encrypt a content without padding, the content length must be a multiple
/// In place encrypt a content without padding, the content length must be a multiple
/// of the block size.
pub fn encrypt(&mut self, content: &mut[u8]) -> Result<(), SymmError> {
self.0.try_apply_keystream(content)?;
Ok(())
}

/// In place decrypt a content without padding, the content length must be a multiple
/// In place decrypt a content without padding, the content length must be a multiple
/// of the block size.
pub fn decrypt(&mut self, content: &mut[u8]) -> Result<(), SymmError> {
self.0.try_apply_keystream(content)?;
Expand Down
1 change: 1 addition & 0 deletions uint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ byteorder = { version = "1", default-features = false }
rustc-hex = { version = "2.0", default-features = false }
quickcheck = { version = "0.6", optional = true }
crunchy = { version = "0.2", default-features = true }
static_assertions = "1.0.0"

[features]
default = ["std"]
Expand Down
2 changes: 2 additions & 0 deletions uint/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ pub use rustc_hex;
pub use quickcheck;

#[doc(hidden)]
pub use static_assertions;

pub use crunchy::unroll;

#[macro_use]
Expand Down
18 changes: 8 additions & 10 deletions uint/src/uint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,39 +74,37 @@ macro_rules! impl_try_from_for_primitive {
#[doc(hidden)]
macro_rules! uint_overflowing_binop {
($name:ident, $n_words: tt, $self_expr: expr, $other: expr, $fn:expr) => ({
use $crate::{core_ as core};
let $name(ref me) = $self_expr;
let $name(ref you) = $other;

let mut ret = unsafe { $crate::core_::mem::uninitialized() };
let mut ret = [0u64; $n_words];
let ret_ptr = &mut ret as *mut [u64; $n_words] as *mut u64;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let ret_ptr = &mut ret as *mut [u64; $n_words] as *mut u64;
let ret_ptr = ret.as_mut_ptr();

let mut carry = 0u64;
$crate::static_assertions::const_assert!(core::isize::MAX as usize / core::mem::size_of::<u64>() > $n_words);
Copy link
Copy Markdown
Contributor

@niklasad1 niklasad1 Oct 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

BTW, is isize::MAX used because of offset?


// `unroll!` is recursive, but doesn’t use `$crate::unroll`, so we need to ensure that it
// is in scope unqualified.
use $crate::unroll;
unroll! {
for i in 0..$n_words {
use $crate::core_::ptr;
use core::ptr;

if carry != 0 {
let (res1, overflow1) = ($fn)(me[i], you[i]);
let (res2, overflow2) = ($fn)(res1, carry);

unsafe {
ptr::write(
ret_ptr.offset(i as _),
res2
);
// SAFETY: `i` is within bounds and `i * size_of::<u64>() < isize::MAX`
*ret_ptr.offset(i as _) = res2
}
carry = (overflow1 as u8 + overflow2 as u8) as u64;
} else {
let (res, overflow) = ($fn)(me[i], you[i]);

unsafe {
ptr::write(
ret_ptr.offset(i as _),
res
);
// SAFETY: `i` is within bounds and `i * size_of::<u64>() < isize::MAX`
*ret_ptr.offset(i as _) = res
}

carry = overflow as u64;
Expand Down