@@ -917,17 +917,8 @@ impl Scalar {
917
917
918
918
let mut naf = [ 0i8 ; 256 ] ;
919
919
920
- // work-around for https://github.com/rust-lang/rust/issues/86693
921
- // riscv32i targets mis-align u64 types, leading to the lower 32 bits being aliased to the upper 32 bits
922
- // the AlignedU64Slice wrapper forces the enclosed structure to be aligned, thus avoiding this problem.
923
- #[ repr( align( 32 ) ) ]
924
- struct AlignedU64Slice ( [ u64 ; 5 ] ) ;
925
-
926
- let mut x_u64 = AlignedU64Slice ( [ 0u64 ; 5 ] ) ;
927
- LittleEndian :: read_u64_into ( & self . bytes , & mut x_u64. 0 [ 0 ..4 ] ) ;
928
-
929
- #[ cfg( feature = "betrusted" ) ]
930
- log:: trace!( "x_u64: {:?}" , x_u64. 0 ) ;
920
+ let mut x_u64 = [ 0u64 ; 5 ] ;
921
+ LittleEndian :: read_u64_into ( & self . bytes , & mut x_u64[ 0 ..4 ] ) ;
931
922
932
923
let width = 1 << w;
933
924
let window_mask = width - 1 ;
@@ -941,10 +932,10 @@ impl Scalar {
941
932
let bit_buf: u64 ;
942
933
if bit_idx < 64 - w {
943
934
// This window's bits are contained in a single u64
944
- bit_buf = x_u64. 0 [ u64_idx] >> bit_idx;
935
+ bit_buf = x_u64[ u64_idx] >> bit_idx;
945
936
} else {
946
937
// Combine the current u64's bits with the bits from the next u64
947
- bit_buf = ( x_u64. 0 [ u64_idx] >> bit_idx) | ( x_u64. 0 [ 1 +u64_idx] << ( 64 - bit_idx) ) ;
938
+ bit_buf = ( x_u64[ u64_idx] >> bit_idx) | ( x_u64[ 1 +u64_idx] << ( 64 - bit_idx) ) ;
948
939
}
949
940
950
941
// Add the carry into the current window
@@ -960,17 +951,9 @@ impl Scalar {
960
951
}
961
952
962
953
if window < width/2 {
963
- #[ cfg( feature = "betrusted" ) ]
964
- log:: trace!( "carry 0 width {} naf[{}] = {}; c.{} bb.{:x} wm.{} idx64.{} idxbit.{} xu64[0].{:x}" , width, pos, window,
965
- carry, bit_buf, window_mask, u64_idx, bit_idx, x_u64. 0 [ 0 ] ,
966
- ) ;
967
954
carry = 0 ;
968
955
naf[ pos] = window as i8 ;
969
956
} else {
970
- #[ cfg( feature = "betrusted" ) ]
971
- log:: trace!( "carry 1 width {} naf[{}] = {}/{}; c.{} bb.{:x} wm.{} idx64.{} idxbit.{} xu64[0].{:x}" , width, pos, window, ( window as i8 ) . wrapping_sub( width as i8 ) ,
972
- carry, bit_buf, window_mask, u64_idx, bit_idx, x_u64. 0 [ 0 ]
973
- ) ;
974
957
carry = 1 ;
975
958
naf[ pos] = ( window as i8 ) . wrapping_sub ( width as i8 ) ;
976
959
}
0 commit comments