Files
Nova/examples/ecdsa/utils.rs
Arthur Greef ed915b2540 ecdsa signature proof (#92)
* ecdsa signature proof

* use the library-provided default circuit

* small reorg

Co-authored-by: Srinath Setty <srinath@microsoft.com>
2022-07-19 13:06:38 -07:00

30 lines
512 B
Rust

#[derive(Debug)]
pub struct BitIterator<E> {
t: E,
n: usize,
}
impl<E: AsRef<[u64]>> BitIterator<E> {
pub fn new(t: E) -> Self {
let n = t.as_ref().len() * 64;
BitIterator { t, n }
}
}
impl<E: AsRef<[u64]>> Iterator for BitIterator<E> {
type Item = bool;
fn next(&mut self) -> Option<bool> {
if self.n == 0 {
None
} else {
self.n -= 1;
let part = self.n / 64;
let bit = self.n - (64 * part);
Some(self.t.as_ref()[part] & (1 << bit) > 0)
}
}
}