summaryrefslogtreecommitdiffstats
path: root/node_modules/public-encrypt/withPublic.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/public-encrypt/withPublic.js')
-rw-r--r--node_modules/public-encrypt/withPublic.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/node_modules/public-encrypt/withPublic.js b/node_modules/public-encrypt/withPublic.js
new file mode 100644
index 0000000..417a1bf
--- /dev/null
+++ b/node_modules/public-encrypt/withPublic.js
@@ -0,0 +1,12 @@
+var BN = require('bn.js')
+var Buffer = require('safe-buffer').Buffer
+
+function withPublic (paddedMsg, key) {
+ return Buffer.from(paddedMsg
+ .toRed(BN.mont(key.modulus))
+ .redPow(new BN(key.publicExponent))
+ .fromRed()
+ .toArray())
+}
+
+module.exports = withPublic