def METHOD_NAME(seed, modifier, curve):
    k = seed
    while True:
        h = hmac.new(modifier, seed, hashlib.sha512).digest()
        key, chaincode = h[:32], h[32:]
        a = string_to_int(key)
        if curve == 'ed25519':
            break
        if a < curve.order and a != 0:
            break
        seed = h
    return key, chaincode