# quadraticsievefactorization

> Quadratic Sieve integer factorization method for JavaScript bigints

Latest version **1.0.78** (published 2024-11-11) · 0 weekly downloads

## Install

```sh
npm install quadraticsievefactorization
pnpm add quadraticsievefactorization
yarn add quadraticsievefactorization
bun add quadraticsievefactorization
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.78 |
| Published | 2024-11-11 |
| First published | 2021-12-24 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 112.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | Yaffe |
| Maintainers | yaffle |
| Keywords | quadratic, sieve, integer, factorization, prime, bigint, mpqs, siqs |

## Links

- npm: https://www.npmjs.com/package/quadraticsievefactorization
- Repository: https://github.com/Yaffle/QuadraticSieveFactorization
- Homepage: https://github.com/Yaffle/QuadraticSieveFactorization#readme
- Issues: https://github.com/Yaffle/QuadraticSieveFactorization/issues
- npm.io page: https://npm.io/package/quadraticsievefactorization

## Dependencies (1)

- [pollardsrho](https://npm.io/package/pollardsrho.md) ^1.0.5

## Alternatives

- [random-seedable](https://npm.io/package/random-seedable.md) — 27.9K weekly downloads
- [n2words](https://npm.io/package/n2words.md) — 22.2K weekly downloads
- [@stdlib/math-base-special-factorialln](https://npm.io/package/@stdlib/math-base-special-factorialln.md) — 5.7K weekly downloads
- [@stdlib/math-base-special-abs2](https://npm.io/package/@stdlib/math-base-special-abs2.md) — 1.7K weekly downloads
- [commons-math-interpolation](https://npm.io/package/commons-math-interpolation.md) — 1.4K weekly downloads

## Recent versions

- 1.0.78 (latest) — 2024-11-11
- 1.0.77 — 2024-06-26
- 1.0.76 — 2024-05-04
- 1.0.75 — 2024-05-04
- 1.0.74 — 2024-05-04
- 1.0.73 — 2024-04-21
- 1.0.72 — 2023-05-07
- 1.0.71 — 2023-04-19
- 1.0.70 — 2023-04-19
- 1.0.69 — 2023-04-15
- 1.0.67 — 2023-04-13
- 1.0.66 — 2023-04-13
- 1.0.65 — 2023-03-26
- 1.0.64 — 2023-03-21
- 1.0.63 — 2023-02-01
- … 60 more at https://npm.io/package/quadraticsievefactorization/versions

## README

# QuadraticSieveFactorization
Integer factorization using [Quadratic Sieve](https://en.wikipedia.org/wiki/Quadratic_sieve) algorithm in JavaScript.
The variant is multipolynomial self-initializing with two large-primes.

There is series of videos explaining the algorithm at https://www.youtube.com/playlist?list=PL0OUqr2O9PxLd35SgBiWIxuLgm7mYksfp .
Useful info can also be found at https://www.rieselprime.de/ziki/Self-initializing_quadratic_sieve and at https://www.enseignement.polytechnique.fr/informatique/INF558/TD/td_5/S0025-5718-1987-0866119-8.pdf .

See other links in the code.

# Example
```javascript
import factorize from './QuadraticSieveFactorization.js';
console.time();
const f = factorize(2n**128n + 1n);
console.timeEnd();
// ~50ms
console.assert(f === 5704689200685129054721n || f === 59649589127497217n, f);
```

# Usage notes:
* Do not call for the **prime numbers**. It may hang for them. Check if the number is prime instead.
* Do not call for the **[perfect powers](https://en.wikipedia.org/wiki/Perfect_power)**. it may hang for them. Check if the number is a perfect power instead. 
* Do not call for the **numbers with a small factor**, it is as slow as for semiprimes with similar factor size for them. Try other algorithms to check for small factors instead.
* The returned value is a some factor, not necessary prime.

See https://www.rieselprime.de/ziki/Factorization for the more detailed usage notes.

# Demo
See [demo](https://yaffle.github.io/QuadraticSieveFactorization/demo.html).

# Performance

The code uses only single thread.
It takes approximately 1.5 hours to factor [RSA-100](https://en.wikipedia.org/wiki/RSA_numbers#RSA-100) 
and 13.5 hours to factor [RSA-110](https://en.wikipedia.org/wiki/RSA_numbers#RSA-110) on Core i7-1165G7

Probably larger numbers will cause lack of memory.

---
_Source: https://npm.io/package/quadraticsievefactorization · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
