예제 #1
0
def test_cannot_set_default_curve_twice():
    config = _copy_config_for_testing()

    # pyumbral even supports untrustworthy curves!
    config.set_default_curve(ec.SECP256R1)

    # Our default curve has been set...
    assert config.default_curve() == ec.SECP256R1
    # ...and used to set the order of our default parameters.
    assert config.default_params().order == Point.get_order_from_curve(
        ec.SECP256R1)

    # ...but once set, you can't set the default curve again, even if you've found a better one.
    with pytest.raises(config._CONFIG.UmbralConfigurationError):
        config.set_default_curve(ec.SECP256K1)
예제 #2
0
파일: params.py 프로젝트: osagga/proxyChat
    def __init__(self, curve: ec.EllipticCurve):
        from umbral.point import Point, unsafe_hash_to_point
        from umbral.utils import get_curve_keysize_bytes

        self.curve = curve

        self.g = Point.get_generator_from_curve(self.curve)
        self.order = Point.get_order_from_curve(self.curve)

        g_bytes = self.g.to_bytes(is_compressed=True)

        self.CURVE_MINVAL_SHA512 = (1 << 512) % int(self.order)
        self.CURVE_KEY_SIZE_BYTES = get_curve_keysize_bytes(self.curve)

        parameters_seed = b'NuCypherKMS/UmbralParameters/'
        self.u = unsafe_hash_to_point(g_bytes, self, parameters_seed + b'u')