pub fn sign_insecure(&self, message: &[u8]) -> (Signature<T>, T) {
        let zero = T::zero();
        let p = &self.params.p;
        let q = &self.params.q;
        let g = &self.params.g;

        let m = &T::from_bytes_be(&compute_sha1(message));

        let mut k: T;
        let mut r: T;
        let mut s: T;
        loop {
            k = gen_range(&T::from_u32(2), q);
            r = g.mod_exp(&k, p);
            r = r.remainder(q);
            if r == zero {
                continue;
            }
            s = &k.invmod(q).unwrap() * &(m + &(&r * &self.x)); // unwrap is ok
            s = s.remainder(q);
            if s == zero {
                continue;
            }
            break;
        }
        (Signature { r, s }, k)
    }
// We only leak k for testing purposes. It is of course NOT part of the signature.
We only leak k for testing purposes. It is of course NOT part of the signature.
We only leak k for testing purposes . It is of course NOT part of the signature .
pub fn sign_insecure(&self, message: &[u8]) -> (Signature<T>, T) {
        let zero = T::zero();
        let p = &self.params.p;
        let q = &self.params.q;
        let g = &self.params.g;
        let m = &T::from_bytes_be(&compute_sha1(message));
        let mut k: T;
        let mut r: T;
        let mut s: T;
        loop {
            k = gen_range(&T::from_u32(2), q);
            r = g.mod_exp(&k, p);
            r = r.remainder(q);
            if r == zero {
                continue;
            }
            s = &k.invmod(q).unwrap() * &(m + &(&r * &self.x)); // unwrap is ok
            s = s.remainder(q);
            if s == zero {
                continue;
            }
            break;
        }
        (Signature { r, s }, k)
    }
pub fn sign_insecure ( & self , message : & [ u8 ] ) -> ( Signature < T > , T ) { let zero = T :: zero ( ) ; let p = & self . params . p ; let q = & self . params . q ; let g = & self . params . g ; let m = & T :: from_bytes_be ( & compute_sha1 ( message ) ) ; let mut k : T ; let mut r : T ; let mut s : T ; loop { k = gen_range ( & T :: from_u32 ( 2 ) , q ) ; r = g . mod_exp ( & k , p ) ; r = r . remainder ( q ) ; if r == zero { continue ; } s = & k . invmod ( q ) . unwrap ( ) * & ( m + & ( & r * & self . x ) ) ; // unwrap is ok s = s . remainder ( q ) ; if s == zero { continue ; } break ; } ( Signature { r , s } , k ) }
We only leak k for testing purposes.
We only leak k for testing purposes .
&self
message
&[u8]
&self
message
&[u8]