You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi! I was testing vsss-rs with arbitrary Shares, and expected this to pass (i.e., passing an empty share should not verify):
let sk = SecretKey::random(&mut osrng);let nzs = sk.to_secret_scalar();let(_shares, verifier):(_,FeldmanVerifier<Scalar,ProjectivePoint>) = Feldman{t:3,n:5}.split_secret(*nzs,None,&mut osrng).unwrap();assert!(!verifier.verify(&Share(vec![])));
but it panics with an out of bounds slice access:
thread 'main' panicked at 'range start index 1 out of range for slice of length 0', /home/john/.cargo/registry/src/github.com-1ecc6299db9ec823/vsss-rs-2.0.0-pre2/src/standard/share.rs:60:10
stack backtrace:
0: rust_begin_unwind
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:498:5
1: core::panicking::panic_fmt
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/panicking.rs:116:14
2: core::slice::index::slice_start_index_len_fail
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/slice/index.rs:35:5
3: <core::ops::range::RangeFrom<usize> as core::slice::index::SliceIndex<[T]>>::index
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/slice/index.rs:329:13
4: core::slice::index::<impl core::ops::index::Index<I> for [T]>::index
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/slice/index.rs:15:9
5: <alloc::vec::Vec<T,A> as core::ops::index::Index<I>>::index
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/alloc/src/vec/mod.rs:2520:9
6: vsss_rs::standard::share::Share::value
at /home/john/.cargo/registry/src/github.com-1ecc6299db9ec823/vsss-rs-2.0.0-pre2/src/standard/share.rs:60:10
7: vsss_rs::standard::verifier::feldman::FeldmanVerifier<F,G>::verify
at /home/john/.cargo/registry/src/github.com-1ecc6299db9ec823/vsss-rs-2.0.0-pre2/src/standard/verifier/feldman.rs:86:37
8: vsss_rs_panic::main
at ./src/main.rs:15:14
9: core::ops::function::FnOnce::call_once
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/ops/function.rs:227:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
It looks like Share's implementation assumes the vec it wraps is at least 1 byte long in all three of these methods. I could add a check that the vec isn't empty before creating the share, but it doesn't seem ideal that one can create a Share (using either the pub vec like I did above, or via the TryFrom<&[u8]> that always succeeds) that will then panic if used.
The text was updated successfully, but these errors were encountered:
I don't think this is directly relevant to the issue at hand so I omitted it from the main writeup, but I had a hard time finding a combination of crate versions that would compile. The above example was with
p256 = "0.9"rand = "0.8"vsss-rs = { version = "2.0.0-pre2", default-features = false, features = ["std"] }
Hi! I was testing vsss-rs with arbitrary
Share
s, and expected this to pass (i.e., passing an empty share should not verify):but it panics with an out of bounds slice access:
It looks like
Share
's implementation assumes the vec it wraps is at least 1 byte long in all three of these methods. I could add a check that the vec isn't empty before creating the share, but it doesn't seem ideal that one can create aShare
(using either thepub
vec like I did above, or via theTryFrom<&[u8]>
that always succeeds) that will then panic if used.The text was updated successfully, but these errors were encountered: