{"id":24206,"library":"passagemath-libecm","title":"passagemath-libecm","description":"passagemath-libecm provides Python bindings to GMP-ECM for elliptic curve method (ECM) integer factorization. Version 10.8.4 supports Python 3.11-3.14. It is part of the passagemath ecosystem and is released on a regular cadence alongside other components.","status":"active","version":"10.8.4","language":"python","source_language":"en","source_url":"https://github.com/passagemath/passagemath-libecm","tags":["factorization","ecm","number-theory","gmp-ecm","elliptic-curve"],"install":[{"cmd":"pip install passagemath-libecm","lang":"bash","label":"Install passagemath-libecm from PyPI"}],"dependencies":[{"reason":"Required for MPZ arithmetic used in the ECM implementation.","package":"gmpy2","optional":false},{"reason":"Often used side-by-side for number theory; not strictly required.","package":"passagemath-sage","optional":true}],"imports":[{"note":"Old package ecm is separate; passagemath-libecm uses the passagemath namespace.","wrong":"from ecm import find_factor","symbol":"find_factor","correct":"from passagemath.libecm import find_factor"},{"note":"The main class is ECM, not libecm.","wrong":"from passagemath.libecm import libecm","symbol":"ECM","correct":"from passagemath.libecm import ECM"}],"quickstart":{"code":"from passagemath.libecm import find_factor\n\n# Factor a composite number\nn = 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\nB1 = 1000000\nB2 = 100000000\nresult = find_factor(n, B1, B2)\nprint('Found factor:' if result else 'No factor found')","lang":"python","description":"Basic usage: attempt integer factorization with ECM using the find_factor function."},"warnings":[{"fix":"Remove the seed argument; RNG is now seeded automatically.","message":"The function signature changed between 10.8.2 and 10.8.3: the 'seed' parameter was removed and replaced by an internal RNG. Code using 'seed' will raise TypeError.","severity":"breaking","affected_versions":">=10.8.3"},{"fix":"Use 'from passagemath.libecm import ...'","message":"Do not import directly from 'ecm' or 'libecm' - the correct top-level module is 'passagemath.libecm'.","severity":"gotcha","affected_versions":"all"},{"fix":"Replace curves=10 with ncurves=10","message":"The 'curves' argument in ECM constructor is deprecated; use 'ncurves' instead.","severity":"deprecated","affected_versions":">=10.8.0"},{"fix":"Reduce B1 bounds or use the 'max_stage2_input' parameter.","message":"Passing large numbers (over ~1000 digits) may hang or exhaust memory; tune B1/B2 appropriately.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Install passagemath-libecm and import from passagemath.libecm.","cause":"Importing from the old 'ecm' package instead of 'passagemath.libecm'.","error":"ImportError: cannot import name 'find_factor' from 'ecm'"},{"fix":"Upgrade to passagemath-libecm >=10.8.0, and use 'from passagemath.libecm import ECM'.","cause":"Using an older version (pre-10.8.0) where the class name was 'ECMFactory' or simply a different layout.","error":"AttributeError: module 'passagemath.libecm' has no attribute 'ECM'"},{"fix":"Remove the seed argument; RNG is now automatic.","cause":"The 'seed' parameter was removed in version 10.8.3.","error":"TypeError: find_factor() got an unexpected keyword argument 'seed'"},{"fix":"Ensure B2 > B1.","cause":"Stage 2 bound B2 must be larger than stage 1 bound B1.","error":"ValueError: B1 must be less than B2"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}