miracl / core

MIRACL Core
Apache License 2.0
206 stars 68 forks source link

pow(0) crash #25

Closed blynn closed 3 years ago

blynn commented 4 years ago

Raising an element of bls12381::FP12 to the power of 0 crashes.

For example:

extern crate core;
use core::bls12381::fp12::FP12;
use core::bls12381::big::BIG;

fn main() {
    let mut g = FP12::new();
    g.one();
    let mut z = BIG::new();
    z.one();
    println!("{}", g.pow(&z).tostring());
    z.zero();
    println!("{}", g.pow(&z).tostring());
}

crashes on the last line with:

thread 'main' panicked at 'index out of bounds: the len is 7 but the index is 318047311615681924', src/bls12381/big.rs:526:13
mcarrickscott commented 4 years ago

Good catch, thanks..

mcarrickscott commented 4 years ago

Now fixed..