some changes idk

This commit is contained in:
Christoph J. Scherr 2023-05-13 17:08:56 +02:00
parent cc1116c2ca
commit ebfce5ac7f
Signed by: PlexSheep
GPG Key ID: 25B4ACF7D88186CC
4 changed files with 15 additions and 3 deletions

View File

@ -1,6 +1,6 @@
[package]
name = "plexcryptool"
version = "0.2.0"
version = "0.2.1"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -38,6 +38,7 @@ fn register_binary_module(py: Python, parent_module: &PyModule) -> PyResult<()>
fn register_math_module(py: Python, parent_module: &PyModule) -> PyResult<()> {
let math_module = PyModule::new(py, "math")?;
math_module.add_function(wrap_pyfunction!(math::modexp::py_modular_exponentiation, math_module)?)?;
math_module.add_function(wrap_pyfunction!(math::pm1::py_p_minus_one, math_module)?)?;
parent_module.add_submodule(math_module)?;
Ok(())
}

View File

@ -31,7 +31,7 @@ use num_bigint;
/*************************************************************************************************/
// This is just structures for parsing Cli args
#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
#[clap(name="plexcryptool", author="Christoph J. Scherr", version, about="Various tools for use with math and cryptology, includes executable and a library.")]
struct Cli {
/// Which submodule to use
#[command(subcommand)]

View File

@ -8,7 +8,7 @@
/// License: MIT
/// Source: <https://git.cscherr.de/PlexSheep/plexcryptool/>
use pyo3::prelude::*;
use pyo3::{prelude::*, exceptions::PyArithmeticError};
use num::integer::gcd;
@ -93,6 +93,17 @@ pub fn p_minus_one(n: u128, max_prime: u128, verbose: bool) -> Result<Vec<u128>,
return Ok(prime_parts);
}
#[pyfunction]
#[pyo3(name = "p_minus_one")]
/// python wrapper for p_minus_one
pub fn py_p_minus_one(n: u128, max_prime: u128, verbose: bool)-> PyResult<Vec<u128>> {
let res = p_minus_one(n, max_prime, verbose);
match res {
Ok(vec) => Ok(vec),
Err(e) => Err(PyArithmeticError::new_err(e))
}
}
/// alternative simple implementation for gcd
pub fn alt_gcd(mut a: u128, mut b: u128) -> u128 {
let mut tmp: u128;