react-native-modpow
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

react-native-modpow

Export native BigInteger.modPow() function that will not freeze your UX for more than a minute.

Installation

npm install react-native-modpow

Linking:

react-native link react-native-modpow

Usage

import modPow from 'react-native-modpow'

const result = modPow({
  target: 2, // number
  value: 2, // power
  modifier: 3 // Congruence
})
// result = 0

Usage as patch for Forge

Use this snippet to patch BigInteger.modPow() from node-forge. The goal is to improve Forge's performance on React-Native significantly, in particular the generation of RSA keys.

import Forge from 'node-forge'
import modPow from 'react-native-modpow'

Forge.jsbn.BigInteger.prototype.modPow = function nativeModPow (e, m) {
  const result = modPow({
    target: this.toString(16),
    value: e.toString(16),
    modifier: m.toString(16)
  })

  return new Forge.jsbn.BigInteger(result, 16)
}

Package Sidebar

Install

npm i react-native-modpow

Weekly Downloads

1,601

Version

1.1.0

License

MIT

Unpacked Size

235 kB

Total Files

23

Last publish

Collaborators

  • arantes
  • seald
  • tex0l