You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

12 lines
275 B

4 years ago
  1. var BN = require('bn.js')
  2. var Buffer = require('safe-buffer').Buffer
  3. function withPublic (paddedMsg, key) {
  4. return Buffer.from(paddedMsg
  5. .toRed(BN.mont(key.modulus))
  6. .redPow(new BN(key.publicExponent))
  7. .fromRed()
  8. .toArray())
  9. }
  10. module.exports = withPublic