🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

@yaffle/ecm

Package Overview
Dependencies
Maintainers
0
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@yaffle/ecm

Lenstra elliptic-curve factorization method

0.0.19
latest
Source
npm
Version published
Weekly downloads
1
-50%
Maintainers
0
Weekly downloads
 
Created
Source
  • Lenstra elliptic-curve factorization

Usage:

npm install @yaffle/ecm


import ecm from './ecm.js';

console.log(ecm(2n**128n + 1n, true)); // 59649589127497217n, it takes about 2 seconds

function factors(n, count) {
  const f = ecm(n, true);
  return [f].concat(count === 2 ? [n / f] : factors(n / f, count - 1));
}

console.time();
console.log(factors(2n**2048n+1n, 5)); //  ~3 minutes
console.timeEnd();

console.time();
console.log(factors(2n**1024n+1n, 4)); //  ~2 days
console.timeEnd();

By default it searches for small factors only. The second argument unlimits the search to look for bigger factors. If a factor is not found 0n is returned.

Do not call for prime numbers.

Keywords

integer

FAQs

Package last updated on 01 Jan 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts