47 lines
1.7 KiB
Python
47 lines
1.7 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
# IMPORTS
|
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
from src.thirdparty.code import *;
|
|
|
|
from models.generated.commands import *;
|
|
from src.core.calls import *;
|
|
from src.setup import config;
|
|
from src.algorithms.pollard_rho import *;
|
|
|
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
# EXPORTS
|
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
__all__ = [
|
|
'endpoint_pollard_rho',
|
|
];
|
|
|
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
# ENDPOINT
|
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
@run_safely()
|
|
def endpoint_pollard_rho(command: CommandPollard) -> Result[CallResult, CallError]:
|
|
match command.growth:
|
|
case EnumPollardGrowthRate.linear:
|
|
result = pollard_rho_algorithm_linear(
|
|
n = command.number,
|
|
x_init = command.x_init,
|
|
verbose = config.OPTIONS.pollard_rho.verbose,
|
|
);
|
|
pass;
|
|
case EnumPollardGrowthRate.exponential:
|
|
result = pollard_rho_algorithm_exponential(
|
|
n = command.number,
|
|
x_init = command.x_init,
|
|
verbose = config.OPTIONS.pollard_rho.verbose,
|
|
);
|
|
pass;
|
|
case _ as growth:
|
|
raise Exception(f'No algorithm implemented for \x1b[1m{growth.value}\x1b[0m as growth rate.');
|
|
return Ok(CallResult(action_taken=True, message=result));
|