M = H(H(N) xor H(g), H(I), s, A, B, K)
765862
def client_proof(user, password, salt, A, B, a, hash_algo):
    
    N, g, k = get_prime()
    K = client_session(user, password, salt, A, B, a)

    n1 = bytes2long(hash_digest(hashlib.sha1, N))
    n2 = bytes2long(hash_digest(hashlib.sha1, g))
    if DEBUG_PRINT:
        print('n1-1=', binascii.b2a_hex(long2bytes(n1)), end='\n')
        print('n2-1=', binascii.b2a_hex(long2bytes(n2)), end='\n')

    n1 = pow(n1, n2, N)
    n2 = bytes2long(hash_digest(hashlib.sha1, user))

    M = hash_digest(hash_algo, n1, n2, salt, A, B, K)
    if DEBUG_PRINT:
        print('n1-2=', binascii.b2a_hex(long2bytes(n1)), end='\n')
        print('n2-2=', binascii.b2a_hex(long2bytes(n2)), end='\n')
        print('client_proof:M=', binascii.b2a_hex(M), end='\n')

    return M, K
459067
def _Aterm(N, h, m, k, dW):
    """"""
    sqrt2h = np.sqrt(2.0/h)
    Xk = np.random.normal(0.0, 1.0, (N, m, 1))
    Yk = np.random.normal(0.0, 1.0, (N, m, 1))
    term1 = _dot(Xk, _t(Yk + sqrt2h*dW))
    term2 = _dot(Yk + sqrt2h*dW, _t(Xk))
    return (term1 - term2)/k
225006
private static function rgb2hsl($r, $g, $b, &$h, &$s, &$l)
    {
        $r /= 255;
        $g /= 255;
        $b /= 255;

        $min = min([$r, $g, $b]);
        $max = max([$r, $g, $b]);

        $l = ($min + $max) / 2;
        $l = round($l, 2);

        if ($min == $max) {
            $s = 0;
            $h = 0;

            return;
        }

        if ($l < 0.5) {
            $s = ($max - $min) / ($max + $min);
        } else {
            $s = ($max - $min) / (2.0 - $max - $min);
        }

        if ($r == $max) {
            $h = ($g - $b) / ($max - $min);
        } elseif ($g == $max) {
            $h = 2.0 + ($b - $r) / ($max - $min);
        } else {
            $h = 4.0 + ($r - $g) / ($max - $min);
        }

        $h *= 60;
        $h = $h < 0 ? $h + 360 : $h;
        $h = (int)round($h);

        $s = round($s, 2);
    }
1054142
def fibs(n, m):
    
    a = b = 1
    for x in range(3, m + 1):
        a, b = b, a + b
        if x >= n:
            yield b
1176271
def identities():
    

    circuit_identities = []

    # Pick random parameter
    theta = np.pi * np.random.uniform()

    # Single qubit gate identities

    name = "Hadamard is own inverse"
    circ0 = Circuit([H(0), H(0)])
    circ1 = Circuit([I(0)])
    circuit_identities.append([name, circ0, circ1])

    name = "Hadamards convert X to Z"
    circ0 = Circuit([H(0), X(0), H(0)])
    circ1 = Circuit([Z(0)])
    circuit_identities.append([name, circ0, circ1])

    name = "Hadamards convert Z to X"
    circ0 = Circuit([H(0), Z(0), H(0)])
    circ1 = Circuit([X(0)])
    circuit_identities.append([name, circ0, circ1])

    name = "S sandwich converts X to Y"
    circ0 = Circuit([S(0).H, X(0), S(0)])
    circ1 = Circuit([Y(0)])
    circuit_identities.append([name, circ0, circ1])

    name = "S sandwich converts Y to X"
    circ0 = Circuit([S(0), Y(0), S(0).H])
    circ1 = Circuit([X(0)])
    circuit_identities.append([name, circ0, circ1])

    name = "Hadamards convert RZ to RX"
    circ0 = Circuit([H(0), RZ(theta, 0), H(0)])
    circ1 = Circuit([RX(theta, 0)])
    circuit_identities.append([name, circ0, circ1])

    # ZYZ Decompositions

    name = "Hadamard ZYZ decomposition"
    circ0 = Circuit([H(0)])
    circ1 = Circuit([Z(0), Y(0)**0.5])
    circuit_identities.append([name, circ0, circ1])

    # CNOT identities

    name = "CZ to CNOT"
    circ0 = Circuit([CZ(0, 1)])
    circ1 = Circuit([H(1), CNOT(0, 1), H(1)])
    circuit_identities.append([name, circ0, circ1])

    name = "SWAP to 3 CNOTs"
    circ0 = Circuit([SWAP(0, 1)])
    circ1 = Circuit([CNOT(0, 1), CNOT(1, 0), CNOT(0, 1)])
    circuit_identities.append([name, circ0, circ1])

    name = "SWAP to 3 CZs"
    circ0 = Circuit([SWAP(0, 1)])
    circ1 = Circuit([H(1), CZ(0, 1), H(0), H(1), CZ(1, 0), H(0), H(1),
                     CZ(0, 1), H(1)])
    circuit_identities.append([name, circ0, circ1])

    name = "ISWAP decomposition to SWAP and CNOT"
    circ0 = Circuit([ISWAP(0, 1)])
    circ1 = Circuit([SWAP(0, 1), H(1), CNOT(0, 1), H(1), S(0), S(1)])
    circuit_identities.append([name, circ0, circ1])

    name = "ISWAP decomposition to SWAP and CZ"
    # This makes it clear why you can commute RZ's across ISWAP
    circ0 = Circuit([ISWAP(0, 1)])
    circ1 = Circuit([SWAP(0, 1), CZ(0, 1), S(0), S(1)])
    circuit_identities.append([name, circ0, circ1])

    # http://info.phys.unm.edu/~caves/courses/qinfo-f14/lectures/lectures21-23.pdf
    name = "CNOT sandwich with X on control"
    circ0 = Circuit([CNOT(0, 1), X(0), CNOT(0, 1)])
    circ1 = Circuit([X(0), X(1)])
    circuit_identities.append([name, circ0, circ1])

    # http://info.phys.unm.edu/~caves/courses/qinfo-f14/lectures/lectures21-23.pdf
    name = "CNOT sandwich with Z on target"
    circ0 = Circuit([CNOT(0, 1), Z(1), CNOT(0, 1)])
    circ1 = Circuit([Z(0), Z(1)])
    circuit_identities.append([name, circ0, circ1])

    name = "DCNOT (Double-CNOT) to iSWAP"
    circ0 = Circuit([CNOT(0, 1), CNOT(1, 0)])
    circ1 = Circuit([H(0), S(0).H, S(1).H, ISWAP(0, 1), H(1)])
    circuit_identities.append([name, circ0, circ1])

    # Commuting single qubit gates across 2 qubit games

    name = "Commute X on CNOT target"
    circ0 = Circuit([X(1), CNOT(0, 1)])
    circ1 = Circuit([CNOT(0, 1), X(1)])
    circuit_identities.append([name, circ0, circ1])

    name = "Commute X on CNOT control"
    circ0 = Circuit([X(0), CNOT(0, 1)])
    circ1 = Circuit([CNOT(0, 1), X(0), X(1)])
    circuit_identities.append([name, circ0, circ1])

    name = "Commute Z on CNOT target"
    circ0 = Circuit([Z(1), CNOT(0, 1)])
    circ1 = Circuit([CNOT(0, 1), Z(0), Z(1)])
    circuit_identities.append([name, circ0, circ1])

    name = "Commute Z on CNOT control"
    circ0 = Circuit([Z(0), CNOT(0, 1)])
    circ1 = Circuit([CNOT(0, 1), Z(0)])
    circuit_identities.append([name, circ0, circ1])

    #  Canonical gate identities

    name = "Canonical gates: CZ to ZZ"
    circ0 = Circuit([CZ(0, 1),
                     S(0),
                     S(1)])
    circ1 = Circuit([ZZ(0.5, 0, 1)])
    circuit_identities.append([name, circ0, circ1])

    name = "Canonical gates: XX to ZZ"
    circ0 = Circuit([H(0), H(1),
                     XX(0.5, 0, 1),
                     H(0), H(1)])
    circ1 = Circuit([ZZ(0.5, 0, 1)])
    circuit_identities.append([name, circ0, circ1])

    name = "Canonical gates: CNOT to XX"
    circ0 = Circuit([CNOT(0, 1)])
    circ1 = Circuit([H(0),
                     XX(0.5, 0, 1),
                     H(0), H(1),
                     S(0).H, S(1).H,
                     H(1)])
    circuit_identities.append([name, circ0, circ1])

    name = "Canonical gates: SWAP to Canonical"
    circ0 = Circuit([SWAP(0, 1)])
    circ1 = Circuit([CANONICAL(0.5, 0.5, 0.5, 0, 1)])
    circuit_identities.append([name, circ0, circ1])

    name = "ISWAP to Canonical"
    circ0 = Circuit([ISWAP(0, 1)])
    circ1 = Circuit([CANONICAL(0.5, 0.5, 1.0, 0, 1)])
    circuit_identities.append([name, circ0, circ1])

    name = "ISWAP to Canonical in Weyl chamber"
    circ0 = Circuit([ISWAP(0, 1)])
    circ1 = Circuit([X(0), CANONICAL(0.5, 0.5, 0.0, 0, 1), X(1)])
    circuit_identities.append([name, circ0, circ1])

    name = "DCNOT to Canonical"
    circ0 = Circuit([CNOT(0, 1), CNOT(1, 0)])
    circ1 = Circuit([H(0), S(0).H, S(1).H, X(0),
                     CANONICAL(0.5, 0.5, 0.0, 0, 1), X(1), H(1)])
    circuit_identities.append([name, circ0, circ1])

    # Multi-qubit circuits

    name = "CNOT controls commute"
    circ0 = Circuit([CNOT(1, 0), CNOT(1, 2)])
    circ1 = Circuit([CNOT(1, 2), CNOT(1, 0)])
    circuit_identities.append([name, circ0, circ1])

    name = "CNOT targets commute"
    circ0 = Circuit([CNOT(0, 1), CNOT(2, 1)])
    circ1 = Circuit([CNOT(2, 1), CNOT(0, 1)])
    circuit_identities.append([name, circ0, circ1])

    name = "Commutation of CNOT target/control"
    circ0 = Circuit([CNOT(0, 1), CNOT(1, 2)])
    circ1 = Circuit([CNOT(1, 2), CNOT(0, 2), CNOT(0, 1)])
    circuit_identities.append([name, circ0, circ1])

    name = "Indirect CNOT and 4 CNOTS with intermediate qubit"
    circ0 = Circuit([CNOT(0, 2), I(1)])
    circ1 = Circuit([CNOT(0, 1),
                     CNOT(1, 2),
                     CNOT(0, 1),
                     CNOT(1, 2)])
    circuit_identities.append([name, circ0, circ1])

    name = "CZs with shared shared qubit commute"
    circ0 = Circuit([CZ(0, 1), CZ(1, 2)])
    circ1 = Circuit([CZ(1, 2), CZ(0, 1)])
    circuit_identities.append([name, circ0, circ1])

    name = "Toffoli gate CNOT decomposition"
    circ0 = Circuit([CCNOT(0, 1, 2)])
    circ1 = ccnot_circuit([0, 1, 2])
    circuit_identities.append([name, circ0, circ1])

    # Parametric circuits

    name = "ZZ to CNOTs"  # 1108.4318
    circ0 = Circuit([ZZ(theta/np.pi, 0, 1)])
    circ1 = Circuit([CNOT(0, 1), RZ(theta, 1), CNOT(0, 1)])
    circuit_identities.append([name, circ0, circ1])

    name = "XX to CNOTs"  # 1108.4318
    circ0 = Circuit([XX(theta/np.pi, 0, 1)])
    circ1 = Circuit([H(0), H(1), CNOT(0, 1), RZ(theta, 1), CNOT(0, 1),
                     H(0), H(1)])
    circuit_identities.append([name, circ0, circ1])

    name = "XX to CNOTs (2)"
    circ0 = Circuit([XX(theta/np.pi, 0, 1)])
    circ1 = Circuit([Y(0)**0.5, Y(1)**0.5, CNOT(0, 1), RZ(theta, 1),
                     CNOT(0, 1), Y(0)**-0.5, Y(1)**-0.5])
    circuit_identities.append([name, circ0, circ1])

    name = "YY to CNOTs"
    circ0 = Circuit([YY(theta/np.pi, 0, 1)])
    circ1 = Circuit([X(0)**0.5, X(1)**0.5, CNOT(0, 1), RZ(theta, 1),
                     CNOT(0, 1), X(0)**-0.5, X(1)**-0.5])
    circuit_identities.append([name, circ0, circ1])

    def cphase_to_zz(gate: CPHASE):
        t = - gate.params['theta'] / (2 * np.pi)
        q0, q1 = gate.qubits
        circ = Circuit([ZZ(t, q0, q1), TZ(-t, q0), TZ(-t, q1)])
        return circ

    def cphase00_to_zz(gate: CPHASE00):
        t = - gate.params['theta'] / (2 * np.pi)
        q0, q1 = gate.qubits
        circ = Circuit([X(0), X(1),
                        ZZ(t, q0, q1), TZ(-t, q0), TZ(-t, q1),
                        X(0), X(1)])
        return circ

    def cphase01_to_zz(gate: CPHASE00):
        t = - gate.params['theta'] / (2 * np.pi)
        q0, q1 = gate.qubits
        circ = Circuit([X(0),
                        ZZ(t, q0, q1), TZ(-t, q0), TZ(-t, q1),
                        X(0)])
        return circ

    def cphase10_to_zz(gate: CPHASE00):
        t = - gate.params['theta'] / (2 * np.pi)
        q0, q1 = gate.qubits
        circ = Circuit([X(1),
                        ZZ(t, q0, q1), TZ(-t, q0), TZ(-t, q1),
                        X(1)])
        return circ

    name = "CPHASE to ZZ"
    gate = CPHASE(theta, 0, 1)
    circ0 = Circuit([gate])
    circ1 = cphase_to_zz(gate)
    circuit_identities.append([name, circ0, circ1])

    name = "CPHASE00 to ZZ"
    gate = CPHASE00(theta, 0, 1)
    circ0 = Circuit([gate])
    circ1 = cphase00_to_zz(gate)
    circuit_identities.append([name, circ0, circ1])

    name = "CPHASE01 to ZZ"
    gate = CPHASE01(theta, 0, 1)
    circ0 = Circuit([gate])
    circ1 = cphase01_to_zz(gate)
    circuit_identities.append([name, circ0, circ1])

    name = "CPHASE10 to ZZ"
    gate = CPHASE10(theta, 0, 1)
    circ0 = Circuit([gate])
    circ1 = cphase10_to_zz(gate)
    circuit_identities.append([name, circ0, circ1])

    return circuit_identities
439674
public void xor(BitMatrix mask) {
    if (width != mask.getWidth() || height != mask.getHeight()
        || rowSize != mask.getRowSize()) {
      throw new IllegalArgumentException("input matrix dimensions do not match");
    }
    BitArray rowArray = new BitArray(width);
    for (int y = 0; y < height; y++) {
      int offset = y * rowSize;
      int[] row = mask.getRow(y, rowArray).getBitArray();
      for (int x = 0; x < rowSize; x++) {
        bits[offset + x] ^= row[x];
      }
    }
  }
699861
function(a, b) {

    // gcd = a * s  +  b * t

    var s = 0, t = 1, u = 1, v = 0;
    while (a !== 0) {

      var q = b / a | 0, r = b % a;
      var m = s - u * q, n = t - v * q;

      b = a;
      a = r;
      s = u;
      t = v;
      u = m;
      v = n;
    }
    return [b /* gcd*/, s, t];
  }
294129
function mpn_shr1(r, n, l) {
	var c = 0;
	while (l > 0) {
		var w = n[--l] | c;
		c = w << 31;
		r[l] = w >>> 1;
	}
	return c;
}
1289664
void d2xy(int n, int d, int[] xy) {
        int rx, ry, s, t = d;
        xy[0] = 0;
        xy[1] = 0;
        for (s = 1; s != n; s <<= 1) {
            rx = 1 & (t >> 1);
            ry = 1 & (t ^ rx);
            rot(s, xy, rx, ry);
            // if s was bits then shift
            xy[0] += s * rx;
            xy[1] += s * ry;
            t /= 4;
        }
    }
1274579
function xor(buffer1, buffer2) {
    var length = Math.min(buffer1.length, buffer2.length);
    var retBuffer = new Buffer(length);
    for (var i = 0; i < length; i++) {
        retBuffer[i] = buffer1[i] ^ buffer2[i];
    }
    return retBuffer;
}
686608
function core_sha256(m, l)
{
    var HASH = new Array(1779033703, -1150833019, 1013904242, -1521486534, 1359893119, -1694144372, 528734635, 1541459225);
    var W = new Array(64);
    var a, b, c, d, e, f, g, h;
    var i, j, T1, T2;

    /* append padding */
    m[l >> 5] |= 0x80 << (24 - l % 32);
    m[((l + 64 >> 9) << 4) + 15] = l;

    for(i = 0; i < m.length; i += 16) {
      a = HASH[0];
      b = HASH[1];
      c = HASH[2];
      d = HASH[3];
      e = HASH[4];
      f = HASH[5];
      g = HASH[6];
      h = HASH[7];

      for(j = 0; j < 64; j++)  {
        if (j < 16) W[j] = m[j + i]; else W[j] = safe_add(safe_add(safe_add(sha256_Gamma1256(W[j - 2]), W[j - 7]), sha256_Gamma0256(W[j - 15])), W[j - 16]);
        T1 = safe_add(safe_add(safe_add(safe_add(h, sha256_Sigma1256(e)), sha256_Ch(e, f, g)), sha256_K[j]), W[j]);
        T2 = safe_add(sha256_Sigma0256(a), sha256_Maj(a, b, c));
        h = g;
        g = f;
        f = e;
        e = safe_add(d, T1);
        d = c;
        c = b;
        b = a;
        a = safe_add(T1, T2);
      }

      HASH[0] = safe_add(a, HASH[0]);
      HASH[1] = safe_add(b, HASH[1]);
      HASH[2] = safe_add(c, HASH[2]);
      HASH[3] = safe_add(d, HASH[3]);
      HASH[4] = safe_add(e, HASH[4]);
      HASH[5] = safe_add(f, HASH[5]);
      HASH[6] = safe_add(g, HASH[6]);
      HASH[7] = safe_add(h, HASH[7]);
    }
    return HASH;
}
270342
function xor(/* arguments */) {
    var arrays = Array.prototype.slice.call(arguments);
    var equals = _.isFunction(_.last(arrays))
        ? arrays.pop()
        : defaultEquals;

    var all = _.reduce(arrays, function(memo, arr) {
        return memo.concat(arr);
    }, []);

    return _.reduce(all, function(memo, item) {
        var itemIndexes = _.map(arrays, function(arr) {
            return _.findIndex(arr, function(arrItem) {
                return equals(arrItem, item);
            });
        });

        var itemFoundTimes = _.sum(_.map(itemIndexes, function(index) {
            var wasFound = index !== -1;
            return wasFound ? 1 : 0;
        }));

        if (itemFoundTimes !== 1) {
            return memo;
        }
        return [].concat(memo).concat([item]);
    }, []);
}
1012902
def Iaaxn(mt, x, n, *args):
    
    return (Sx(mt, x) - Sx(nt, x + n) - n * Nx(nt, x + n)) / Dx(nt, x)
482288
function(buf, V) {
    var M = Array(8);
    var a = Array(8);
    var b = Array(8);
    M[0] = buf[0];
    M[1] = buf[1];
    M[2] = buf[2];
    M[3] = buf[3];
    M[4] = buf[4];
    M[5] = buf[5];
    M[6] = buf[6];
    M[7] = buf[7];
    o.xORTable(a, V[0], V[1], 8);
    o.xORTable(b, V[2], V[3], 8);
    o.xORTable(a, a, b, 8);
    o.xORTable(a, a, V[4], 8);
    M2(a, a);
    o.xORTable(V[0], a, V[0], 8);
    o.xORTable(V[1], a, V[1], 8);
    o.xORTable(V[2], a, V[2], 8);
    o.xORTable(V[3], a, V[3], 8);
    o.xORTable(V[4], a, V[4], 8);
    M2(b, V[0]);
    o.xORTable(b, b, V[1], 8);
    M2(V[1], V[1]);
    o.xORTable(V[1], V[1], V[2], 8);
    M2(V[2], V[2]);
    o.xORTable(V[2], V[2], V[3], 8);
    M2(V[3], V[3]);
    o.xORTable(V[3], V[3], V[4], 8);
    M2(V[4], V[4]);
    o.xORTable(V[4], V[4], V[0], 8);
    M2(V[0], b);
    o.xORTable(V[0], V[0], V[4], 8);
    M2(V[4], V[4]);
    o.xORTable(V[4], V[4], V[3], 8);
    M2(V[3], V[3]);
    o.xORTable(V[3], V[3], V[2], 8);
    M2(V[2], V[2]);
    o.xORTable(V[2], V[2], V[1], 8);
    M2(V[1], V[1]);
    o.xORTable(V[1], V[1], b, 8);
    o.xORTable(V[0], V[0], M, 8);
    M2(M, M);
    o.xORTable(V[1], V[1], M, 8);
    M2(M, M);
    o.xORTable(V[2], V[2], M, 8);
    M2(M, M);
    o.xORTable(V[3], V[3], M, 8);
    M2(M, M);
    o.xORTable(V[4], V[4], M, 8);
}
578068
public static void sc_muladd(byte[] s, byte[] a, byte[] b, byte[] c) {
        long a0 = 2097151 & load_3(a, 0);
        long a1 = 2097151 & (load_4(a, 2) >>> 5);
        long a2 = 2097151 & (load_3(a, 5) >>> 2);
        long a3 = 2097151 & (load_4(a, 7) >>> 7);
        long a4 = 2097151 & (load_4(a, 10) >>> 4);
        long a5 = 2097151 & (load_3(a, 13) >>> 1);
        long a6 = 2097151 & (load_4(a, 15) >>> 6);
        long a7 = 2097151 & (load_3(a, 18) >>> 3);
        long a8 = 2097151 & load_3(a, 21);
        long a9 = 2097151 & (load_4(a, 23) >>> 5);
        long a10 = 2097151 & (load_3(a, 26) >>> 2);
        long a11 = (load_4(a, 28) >>> 7);
        long b0 = 2097151 & load_3(b, 0);
        long b1 = 2097151 & (load_4(b, 2) >>> 5);
        long b2 = 2097151 & (load_3(b, 5) >>> 2);
        long b3 = 2097151 & (load_4(b, 7) >>> 7);
        long b4 = 2097151 & (load_4(b, 10) >>> 4);
        long b5 = 2097151 & (load_3(b, 13) >>> 1);
        long b6 = 2097151 & (load_4(b, 15) >>> 6);
        long b7 = 2097151 & (load_3(b, 18) >>> 3);
        long b8 = 2097151 & load_3(b, 21);
        long b9 = 2097151 & (load_4(b, 23) >>> 5);
        long b10 = 2097151 & (load_3(b, 26) >>> 2);
        long b11 = (load_4(b, 28) >>> 7);
        long c0 = 2097151 & load_3(c, 0);
        long c1 = 2097151 & (load_4(c, 2) >>> 5);
        long c2 = 2097151 & (load_3(c, 5) >>> 2);
        long c3 = 2097151 & (load_4(c, 7) >>> 7);
        long c4 = 2097151 & (load_4(c, 10) >>> 4);
        long c5 = 2097151 & (load_3(c, 13) >>> 1);
        long c6 = 2097151 & (load_4(c, 15) >>> 6);
        long c7 = 2097151 & (load_3(c, 18) >>> 3);
        long c8 = 2097151 & load_3(c, 21);
        long c9 = 2097151 & (load_4(c, 23) >>> 5);
        long c10 = 2097151 & (load_3(c, 26) >>> 2);
        long c11 = (load_4(c, 28) >>> 7);
        long s0;
        long s1;
        long s2;
        long s3;
        long s4;
        long s5;
        long s6;
        long s7;
        long s8;
        long s9;
        long s10;
        long s11;
        long s12;
        long s13;
        long s14;
        long s15;
        long s16;
        long s17;
        long s18;
        long s19;
        long s20;
        long s21;
        long s22;
        long s23;
        long carry0;
        long carry1;
        long carry2;
        long carry3;
        long carry4;
        long carry5;
        long carry6;
        long carry7;
        long carry8;
        long carry9;
        long carry10;
        long carry11;
        long carry12;
        long carry13;
        long carry14;
        long carry15;
        long carry16;
        long carry17;
        long carry18;
        long carry19;
        long carry20;
        long carry21;
        long carry22;

        s0 = c0 + a0 * b0;
        s1 = c1 + a0 * b1 + a1 * b0;
        s2 = c2 + a0 * b2 + a1 * b1 + a2 * b0;
        s3 = c3 + a0 * b3 + a1 * b2 + a2 * b1 + a3 * b0;
        s4 = c4 + a0 * b4 + a1 * b3 + a2 * b2 + a3 * b1 + a4 * b0;
        s5 = c5 + a0 * b5 + a1 * b4 + a2 * b3 + a3 * b2 + a4 * b1 + a5 * b0;
        s6 = c6 + a0 * b6 + a1 * b5 + a2 * b4 + a3 * b3 + a4 * b2 + a5 * b1 + a6 * b0;
        s7 = c7 + a0 * b7 + a1 * b6 + a2 * b5 + a3 * b4 + a4 * b3 + a5 * b2 + a6 * b1 + a7 * b0;
        s8 = c8 + a0 * b8 + a1 * b7 + a2 * b6 + a3 * b5 + a4 * b4 + a5 * b3 + a6 * b2 + a7 * b1 + a8 * b0;
        s9 = c9 + a0 * b9 + a1 * b8 + a2 * b7 + a3 * b6 + a4 * b5 + a5 * b4 + a6 * b3 + a7 * b2 + a8 * b1 + a9 * b0;
        s10 = c10 + a0 * b10 + a1 * b9 + a2 * b8 + a3 * b7 + a4 * b6 + a5 * b5 + a6 * b4 + a7 * b3 + a8 * b2 + a9 * b1 + a10 * b0;
        s11 = c11 + a0 * b11 + a1 * b10 + a2 * b9 + a3 * b8 + a4 * b7 + a5 * b6 + a6 * b5 + a7 * b4 + a8 * b3 + a9 * b2 + a10 * b1 + a11 * b0;
        s12 = a1 * b11 + a2 * b10 + a3 * b9 + a4 * b8 + a5 * b7 + a6 * b6 + a7 * b5 + a8 * b4 + a9 * b3 + a10 * b2 + a11 * b1;
        s13 = a2 * b11 + a3 * b10 + a4 * b9 + a5 * b8 + a6 * b7 + a7 * b6 + a8 * b5 + a9 * b4 + a10 * b3 + a11 * b2;
        s14 = a3 * b11 + a4 * b10 + a5 * b9 + a6 * b8 + a7 * b7 + a8 * b6 + a9 * b5 + a10 * b4 + a11 * b3;
        s15 = a4 * b11 + a5 * b10 + a6 * b9 + a7 * b8 + a8 * b7 + a9 * b6 + a10 * b5 + a11 * b4;
        s16 = a5 * b11 + a6 * b10 + a7 * b9 + a8 * b8 + a9 * b7 + a10 * b6 + a11 * b5;
        s17 = a6 * b11 + a7 * b10 + a8 * b9 + a9 * b8 + a10 * b7 + a11 * b6;
        s18 = a7 * b11 + a8 * b10 + a9 * b9 + a10 * b8 + a11 * b7;
        s19 = a8 * b11 + a9 * b10 + a10 * b9 + a11 * b8;
        s20 = a9 * b11 + a10 * b10 + a11 * b9;
        s21 = a10 * b11 + a11 * b10;
        s22 = a11 * b11;
        s23 = 0;

        carry0 = (s0 + (1 << 20)) >> 21;
        s1 += carry0;
        s0 -= carry0 << 21;
        carry2 = (s2 + (1 << 20)) >> 21;
        s3 += carry2;
        s2 -= carry2 << 21;
        carry4 = (s4 + (1 << 20)) >> 21;
        s5 += carry4;
        s4 -= carry4 << 21;
        carry6 = (s6 + (1 << 20)) >> 21;
        s7 += carry6;
        s6 -= carry6 << 21;
        carry8 = (s8 + (1 << 20)) >> 21;
        s9 += carry8;
        s8 -= carry8 << 21;
        carry10 = (s10 + (1 << 20)) >> 21;
        s11 += carry10;
        s10 -= carry10 << 21;
        carry12 = (s12 + (1 << 20)) >> 21;
        s13 += carry12;
        s12 -= carry12 << 21;
        carry14 = (s14 + (1 << 20)) >> 21;
        s15 += carry14;
        s14 -= carry14 << 21;
        carry16 = (s16 + (1 << 20)) >> 21;
        s17 += carry16;
        s16 -= carry16 << 21;
        carry18 = (s18 + (1 << 20)) >> 21;
        s19 += carry18;
        s18 -= carry18 << 21;
        carry20 = (s20 + (1 << 20)) >> 21;
        s21 += carry20;
        s20 -= carry20 << 21;
        carry22 = (s22 + (1 << 20)) >> 21;
        s23 += carry22;
        s22 -= carry22 << 21;

        carry1 = (s1 + (1 << 20)) >> 21;
        s2 += carry1;
        s1 -= carry1 << 21;
        carry3 = (s3 + (1 << 20)) >> 21;
        s4 += carry3;
        s3 -= carry3 << 21;
        carry5 = (s5 + (1 << 20)) >> 21;
        s6 += carry5;
        s5 -= carry5 << 21;
        carry7 = (s7 + (1 << 20)) >> 21;
        s8 += carry7;
        s7 -= carry7 << 21;
        carry9 = (s9 + (1 << 20)) >> 21;
        s10 += carry9;
        s9 -= carry9 << 21;
        carry11 = (s11 + (1 << 20)) >> 21;
        s12 += carry11;
        s11 -= carry11 << 21;
        carry13 = (s13 + (1 << 20)) >> 21;
        s14 += carry13;
        s13 -= carry13 << 21;
        carry15 = (s15 + (1 << 20)) >> 21;
        s16 += carry15;
        s15 -= carry15 << 21;
        carry17 = (s17 + (1 << 20)) >> 21;
        s18 += carry17;
        s17 -= carry17 << 21;
        carry19 = (s19 + (1 << 20)) >> 21;
        s20 += carry19;
        s19 -= carry19 << 21;
        carry21 = (s21 + (1 << 20)) >> 21;
        s22 += carry21;
        s21 -= carry21 << 21;

        s11 += s23 * 666643;
        s12 += s23 * 470296;
        s13 += s23 * 654183;
        s14 -= s23 * 997805;
        s15 += s23 * 136657;
        s16 -= s23 * 683901;
        s23 = 0;

        s10 += s22 * 666643;
        s11 += s22 * 470296;
        s12 += s22 * 654183;
        s13 -= s22 * 997805;
        s14 += s22 * 136657;
        s15 -= s22 * 683901;
        s22 = 0;

        s9 += s21 * 666643;
        s10 += s21 * 470296;
        s11 += s21 * 654183;
        s12 -= s21 * 997805;
        s13 += s21 * 136657;
        s14 -= s21 * 683901;
        s21 = 0;

        s8 += s20 * 666643;
        s9 += s20 * 470296;
        s10 += s20 * 654183;
        s11 -= s20 * 997805;
        s12 += s20 * 136657;
        s13 -= s20 * 683901;
        s20 = 0;

        s7 += s19 * 666643;
        s8 += s19 * 470296;
        s9 += s19 * 654183;
        s10 -= s19 * 997805;
        s11 += s19 * 136657;
        s12 -= s19 * 683901;
        s19 = 0;

        s6 += s18 * 666643;
        s7 += s18 * 470296;
        s8 += s18 * 654183;
        s9 -= s18 * 997805;
        s10 += s18 * 136657;
        s11 -= s18 * 683901;
        s18 = 0;

        carry6 = (s6 + (1 << 20)) >> 21;
        s7 += carry6;
        s6 -= carry6 << 21;
        carry8 = (s8 + (1 << 20)) >> 21;
        s9 += carry8;
        s8 -= carry8 << 21;
        carry10 = (s10 + (1 << 20)) >> 21;
        s11 += carry10;
        s10 -= carry10 << 21;
        carry12 = (s12 + (1 << 20)) >> 21;
        s13 += carry12;
        s12 -= carry12 << 21;
        carry14 = (s14 + (1 << 20)) >> 21;
        s15 += carry14;
        s14 -= carry14 << 21;
        carry16 = (s16 + (1 << 20)) >> 21;
        s17 += carry16;
        s16 -= carry16 << 21;

        carry7 = (s7 + (1 << 20)) >> 21;
        s8 += carry7;
        s7 -= carry7 << 21;
        carry9 = (s9 + (1 << 20)) >> 21;
        s10 += carry9;
        s9 -= carry9 << 21;
        carry11 = (s11 + (1 << 20)) >> 21;
        s12 += carry11;
        s11 -= carry11 << 21;
        carry13 = (s13 + (1 << 20)) >> 21;
        s14 += carry13;
        s13 -= carry13 << 21;
        carry15 = (s15 + (1 << 20)) >> 21;
        s16 += carry15;
        s15 -= carry15 << 21;

        s5 += s17 * 666643;
        s6 += s17 * 470296;
        s7 += s17 * 654183;
        s8 -= s17 * 997805;
        s9 += s17 * 136657;
        s10 -= s17 * 683901;
        s17 = 0;

        s4 += s16 * 666643;
        s5 += s16 * 470296;
        s6 += s16 * 654183;
        s7 -= s16 * 997805;
        s8 += s16 * 136657;
        s9 -= s16 * 683901;
        s16 = 0;

        s3 += s15 * 666643;
        s4 += s15 * 470296;
        s5 += s15 * 654183;
        s6 -= s15 * 997805;
        s7 += s15 * 136657;
        s8 -= s15 * 683901;
        s15 = 0;

        s2 += s14 * 666643;
        s3 += s14 * 470296;
        s4 += s14 * 654183;
        s5 -= s14 * 997805;
        s6 += s14 * 136657;
        s7 -= s14 * 683901;
        s14 = 0;

        s1 += s13 * 666643;
        s2 += s13 * 470296;
        s3 += s13 * 654183;
        s4 -= s13 * 997805;
        s5 += s13 * 136657;
        s6 -= s13 * 683901;
        s13 = 0;

        s0 += s12 * 666643;
        s1 += s12 * 470296;
        s2 += s12 * 654183;
        s3 -= s12 * 997805;
        s4 += s12 * 136657;
        s5 -= s12 * 683901;
        s12 = 0;

        carry0 = (s0 + (1 << 20)) >> 21;
        s1 += carry0;
        s0 -= carry0 << 21;
        carry2 = (s2 + (1 << 20)) >> 21;
        s3 += carry2;
        s2 -= carry2 << 21;
        carry4 = (s4 + (1 << 20)) >> 21;
        s5 += carry4;
        s4 -= carry4 << 21;
        carry6 = (s6 + (1 << 20)) >> 21;
        s7 += carry6;
        s6 -= carry6 << 21;
        carry8 = (s8 + (1 << 20)) >> 21;
        s9 += carry8;
        s8 -= carry8 << 21;
        carry10 = (s10 + (1 << 20)) >> 21;
        s11 += carry10;
        s10 -= carry10 << 21;

        carry1 = (s1 + (1 << 20)) >> 21;
        s2 += carry1;
        s1 -= carry1 << 21;
        carry3 = (s3 + (1 << 20)) >> 21;
        s4 += carry3;
        s3 -= carry3 << 21;
        carry5 = (s5 + (1 << 20)) >> 21;
        s6 += carry5;
        s5 -= carry5 << 21;
        carry7 = (s7 + (1 << 20)) >> 21;
        s8 += carry7;
        s7 -= carry7 << 21;
        carry9 = (s9 + (1 << 20)) >> 21;
        s10 += carry9;
        s9 -= carry9 << 21;
        carry11 = (s11 + (1 << 20)) >> 21;
        s12 += carry11;
        s11 -= carry11 << 21;

        s0 += s12 * 666643;
        s1 += s12 * 470296;
        s2 += s12 * 654183;
        s3 -= s12 * 997805;
        s4 += s12 * 136657;
        s5 -= s12 * 683901;
        s12 = 0;

        carry0 = s0 >> 21;
        s1 += carry0;
        s0 -= carry0 << 21;
        carry1 = s1 >> 21;
        s2 += carry1;
        s1 -= carry1 << 21;
        carry2 = s2 >> 21;
        s3 += carry2;
        s2 -= carry2 << 21;
        carry3 = s3 >> 21;
        s4 += carry3;
        s3 -= carry3 << 21;
        carry4 = s4 >> 21;
        s5 += carry4;
        s4 -= carry4 << 21;
        carry5 = s5 >> 21;
        s6 += carry5;
        s5 -= carry5 << 21;
        carry6 = s6 >> 21;
        s7 += carry6;
        s6 -= carry6 << 21;
        carry7 = s7 >> 21;
        s8 += carry7;
        s7 -= carry7 << 21;
        carry8 = s8 >> 21;
        s9 += carry8;
        s8 -= carry8 << 21;
        carry9 = s9 >> 21;
        s10 += carry9;
        s9 -= carry9 << 21;
        carry10 = s10 >> 21;
        s11 += carry10;
        s10 -= carry10 << 21;
        carry11 = s11 >> 21;
        s12 += carry11;
        s11 -= carry11 << 21;

        s0 += s12 * 666643;
        s1 += s12 * 470296;
        s2 += s12 * 654183;
        s3 -= s12 * 997805;
        s4 += s12 * 136657;
        s5 -= s12 * 683901;
        s12 = 0;

        carry0 = s0 >> 21;
        s1 += carry0;
        s0 -= carry0 << 21;
        carry1 = s1 >> 21;
        s2 += carry1;
        s1 -= carry1 << 21;
        carry2 = s2 >> 21;
        s3 += carry2;
        s2 -= carry2 << 21;
        carry3 = s3 >> 21;
        s4 += carry3;
        s3 -= carry3 << 21;
        carry4 = s4 >> 21;
        s5 += carry4;
        s4 -= carry4 << 21;
        carry5 = s5 >> 21;
        s6 += carry5;
        s5 -= carry5 << 21;
        carry6 = s6 >> 21;
        s7 += carry6;
        s6 -= carry6 << 21;
        carry7 = s7 >> 21;
        s8 += carry7;
        s7 -= carry7 << 21;
        carry8 = s8 >> 21;
        s9 += carry8;
        s8 -= carry8 << 21;
        carry9 = s9 >> 21;
        s10 += carry9;
        s9 -= carry9 << 21;
        carry10 = s10 >> 21;
        s11 += carry10;
        s10 -= carry10 << 21;

        s[0] = (byte) (s0 >> 0);
        s[1] = (byte) (s0 >> 8);
        s[2] = (byte) ((s0 >> 16) | (s1 << 5));
        s[3] = (byte) (s1 >> 3);
        s[4] = (byte) (s1 >> 11);
        s[5] = (byte) ((s1 >> 19) | (s2 << 2));
        s[6] = (byte) (s2 >> 6);
        s[7] = (byte) ((s2 >> 14) | (s3 << 7));
        s[8] = (byte) (s3 >> 1);
        s[9] = (byte) (s3 >> 9);
        s[10] = (byte) ((s3 >> 17) | (s4 << 4));
        s[11] = (byte) (s4 >> 4);
        s[12] = (byte) (s4 >> 12);
        s[13] = (byte) ((s4 >> 20) | (s5 << 1));
        s[14] = (byte) (s5 >> 7);
        s[15] = (byte) ((s5 >> 15) | (s6 << 6));
        s[16] = (byte) (s6 >> 2);
        s[17] = (byte) (s6 >> 10);
        s[18] = (byte) ((s6 >> 18) | (s7 << 3));
        s[19] = (byte) (s7 >> 5);
        s[20] = (byte) (s7 >> 13);
        s[21] = (byte) (s8 >> 0);
        s[22] = (byte) (s8 >> 8);
        s[23] = (byte) ((s8 >> 16) | (s9 << 5));
        s[24] = (byte) (s9 >> 3);
        s[25] = (byte) (s9 >> 11);
        s[26] = (byte) ((s9 >> 19) | (s10 << 2));
        s[27] = (byte) (s10 >> 6);
        s[28] = (byte) ((s10 >> 14) | (s11 << 7));
        s[29] = (byte) (s11 >> 1);
        s[30] = (byte) (s11 >> 9);
        s[31] = (byte) (s11 >> 17);
    }
365099
def determinant(self):
        
        a, b, c, d, e, f, g, h, i = self
        return a * e - b * d
1181128
def generate_k(order, secexp, hash_func, data):
    '''
        
    '''

    qlen = bit_length(order)
    holen = hash_func().digest_size
    rolen = (qlen + 7) / 8
    bx = number_to_string(secexp, order) + bits2octets(data, order)

    # Step B
    v = b('\x01') * holen

    # Step C
    k = b('\x00') * holen

    # Step D

    k = hmac.new(k, v+b('\x00')+bx, hash_func).digest()

    # Step E
    v = hmac.new(k, v, hash_func).digest()

    # Step F
    k = hmac.new(k, v+b('\x01')+bx, hash_func).digest()

    # Step G
    v = hmac.new(k, v, hash_func).digest()

    # Step H
    while True:
        # Step H1
        t = b('')

        # Step H2
        while len(t) < rolen:
            v = hmac.new(k, v, hash_func).digest()
            t += v

        # Step H3
        secret = bits2int(t, qlen)

        if secret >= 1 and secret < order:
            return secret

        k = hmac.new(k, v+b('\x00'), hash_func).digest()
        v = hmac.new(k, v, hash_func).digest()