Skip to content

Commit 78e9d6d

Browse files
committed
pin version on ed25519-dalek because the .1 version change was breaking...
1 parent 3099555 commit 78e9d6d

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ version = "0.16.0"
3030
# features = ["bundled"]
3131

3232
[dependencies.ed25519-dalek]
33-
version = "1.0.0-pre.0"
33+
version = "=1.0.0-pre.0"
3434
features = ["serde"]
3535

3636
[dependencies.curve25519-dalek]
37-
version = "1.0.0-pre.0"
37+
version = "=1.0.0-pre.0"
3838
features = ["serde"]
3939

circle.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ jobs:
88
- checkout
99
- run:
1010
command: |
11-
rustup override set nightly && cargo build
11+
cargo build
1212
- run:
1313
environment:
1414
RUST_BACKTRACE: 1
1515
BLOCKSTACK_DEBUG: 1
1616
RUSTFLAGS: -Clink-dead-code
1717
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)

src/vm/functions/arithmetic.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,27 @@ pub fn native_div(args: &[Value]) -> InterpreterResult {
105105
}
106106
}
107107

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+
108129
pub fn native_pow(args: &[Value]) -> InterpreterResult {
109130
if args.len() == 2 {
110131
let base = type_force_integer(&args[0])?;
@@ -114,7 +135,7 @@ pub fn native_pow(args: &[Value]) -> InterpreterResult {
114135
}
115136

116137
let power = power_i128 as u32;
117-
let checked_result = base.checked_pow(power);
138+
let checked_result = checked_pow(base, power);
118139

119140
if let Some(result) = checked_result{
120141
Ok(Value::Int(result))

0 commit comments

Comments
 (0)