# Path: petlib/bindings.py
# _FFI = ffi
# 
# _C = lib
# 
# def get_errors():
#     errors = []
#     err = _C.ERR_get_error()
#     while err != 0:
#         errors += [err]
#         err = _C.ERR_get_error()
#     assert isinstance(errors, list)
#     return errors


from .bindings import _FFI, _C, get_errors
from functools import wraps
from copy import copy, deepcopy
from binascii import hexlify, unhexlify  # pylint: disable=unused-import
    from builtins import int        # pylint: disable=redefined-builtin
    from builtins import object     # pylint: disable=redefined-builtin
    from future.utils import python_2_unicode_compatible
import pytest
import threading
    import time

            return f(*new_args, **kwargs)

        return new_f
    return convert_nth


def _check(return_val):
    """Checks the return code of the C calls"""
    if __debug__:
        if isinstance(return_val, int) and return_val == 1:
            return
        if isinstance(return_val, bool) and return_val == True:
            return

    if return_val == True and return_val == 1:
        return

    errs = get_errors()
    raise Exception("BN exception: %s" % errs)


class BnCtx(object):
    """ A Bn Context for use by the petlib library """

    __slots__ = ['bnctx', '_C']

    def __init__(self):
        self._C = _C
        self.bnctx = self._C.BN_CTX_new()

# Path: petlib/bindings.py
# _FFI = ffi
# 
# _C = lib
# 
# def get_errors():
#     errors = []
#     err = _C.ERR_get_error()
#     while err != 0:
#         errors += [err]
#         err = _C.ERR_get_error()
#     assert isinstance(errors, list)
#     return errors


# Path: petlib/bn.py
from .bindings import _FFI, _C, get_errors
from functools import wraps
from copy import copy, deepcopy
from binascii import hexlify, unhexlify  # pylint: disable=unused-import
    from builtins import int        # pylint: disable=redefined-builtin
    from builtins import object     # pylint: disable=redefined-builtin
    from future.utils import python_2_unicode_compatible
import pytest
import threading
    import time


            return f(*new_args, **kwargs)

        return new_f
    return convert_nth


def _check(return_val):
    """Checks the return code of the C calls"""
    if __debug__:
        if isinstance(return_val, int) and return_val == 1:
            return
        if isinstance(return_val, bool) and return_val == True:
            return

    if return_val == True and return_val == 1:
        return

    errs = get_errors()
    raise Exception("BN exception: %s" % errs)


class BnCtx(object):
    """ A Bn Context for use by the petlib library """

    __slots__ = ['bnctx', '_C']

    def __init__(self):
        self._C = _C
        self.bnctx = self._C.BN_CTX_new()

        _check(self.bnctx != _FFI.NULL)