Performs scalar multiplication between point P \in G, scalar a \in Z, 
    using the function @relicScalarMult. @n is the order of the group G.

def _scalarMultiply(P, a, n, relicScalarMult):
    """
    Performs scalar multiplication between point P \in G, scalar a \in Z, 
    using the function @relicScalarMult. @n is the order of the group G.
    """
    # Ensure the scalar is a BigInt
    a = coerceBigInt(a)
    if not a:
        return NotImplemented

    # Shrink large scalars.
    a %= n

    # Create a point to hold the result and multiply.
    result = type(P)()
    relicScalarMult(byref(result), byref(P), byref(a))
    return result