コード例 #1
0
def _DLEQ_derive_challenge(x, y, a1, a2):
    """ Compute (common) challenge e = H(x_1, y_1, a_11, a_21, ..., x_n, y_n, a_1n, a_2n).
        Compared to the SCRAPE paper the order of the arguments is changed for a consise implementation.
    """
    n = len(x)
    hasher = hashlib.sha512()
    for i in range(n):
        hasher.update(bytes(x[i]))
        hasher.update(bytes(y[i]))
        hasher.update(bytes(a1[i]))
        hasher.update(bytes(a2[i]))
    return Scalar.reduce(hasher.digest())
コード例 #2
0
def deterministic_random_scalar(purpose: Optional[str] = None, counter: Optional[int] = None):
    purpose = "__scalar__ || " + (purpose or "")
    return Scalar.reduce(deterministic_random_bytes(64, purpose, counter))