File tree Expand file tree Collapse file tree 3 files changed +26
-5
lines changed Expand file tree Collapse file tree 3 files changed +26
-5
lines changed Original file line number Diff line number Diff line change @@ -30,10 +30,10 @@ version = "0.16.0"
30
30
# features = ["bundled"]
31
31
32
32
[dependencies .ed25519-dalek ]
33
- version = " 1.0.0-pre.0"
33
+ version = " = 1.0.0-pre.0"
34
34
features = [" serde" ]
35
35
36
36
[dependencies .curve25519-dalek ]
37
- version = " 1.0.0-pre.0"
37
+ version = " = 1.0.0-pre.0"
38
38
features = [" serde" ]
39
39
Original file line number Diff line number Diff line change 8
8
- checkout
9
9
- run :
10
10
command : |
11
- rustup override set nightly && cargo build
11
+ cargo build
12
12
- run :
13
13
environment :
14
14
RUST_BACKTRACE : 1
15
15
BLOCKSTACK_DEBUG : 1
16
16
RUSTFLAGS : -Clink-dead-code
17
17
command : |
18
- rustup override set nightly && cargo kcov && bash <(curl -s https://codecov.io/bash)
18
+ cargo kcov && bash <(curl -s https://codecov.io/bash)
Original file line number Diff line number Diff line change @@ -105,6 +105,27 @@ pub fn native_div(args: &[Value]) -> InterpreterResult {
105
105
}
106
106
}
107
107
108
+ fn checked_pow ( mut base : i128 , mut exp : u32 ) -> Option < i128 > {
109
+ let mut acc: i128 = 1 ;
110
+
111
+ while exp > 1 {
112
+ if ( exp & 1 ) == 1 {
113
+ acc = acc. checked_mul ( base) ?;
114
+ }
115
+ exp /= 2 ;
116
+ base = base. checked_mul ( base) ?;
117
+ }
118
+
119
+ // Deal with the final bit of the exponent separately, since
120
+ // squaring the base afterwards is not necessary and may cause a
121
+ // needless overflow.
122
+ if exp == 1 {
123
+ acc = acc. checked_mul ( base) ?;
124
+ }
125
+
126
+ Some ( acc)
127
+ }
128
+
108
129
pub fn native_pow ( args : & [ Value ] ) -> InterpreterResult {
109
130
if args. len ( ) == 2 {
110
131
let base = type_force_integer ( & args[ 0 ] ) ?;
@@ -114,7 +135,7 @@ pub fn native_pow(args: &[Value]) -> InterpreterResult {
114
135
}
115
136
116
137
let power = power_i128 as u32 ;
117
- let checked_result = base . checked_pow ( power) ;
138
+ let checked_result = checked_pow ( base , power) ;
118
139
119
140
if let Some ( result) = checked_result{
120
141
Ok ( Value :: Int ( result) )
You can’t perform that action at this time.
0 commit comments