Generate keypair through subprocess
This commit is contained in:
parent
ef3064bbdd
commit
99103b84b8
1 changed files with 7 additions and 2 deletions
|
|
@ -1,6 +1,8 @@
|
||||||
/** @format */
|
/** @format */
|
||||||
const ECCrypto = require('eccrypto')
|
const ECCrypto = require('eccrypto')
|
||||||
const Storage = require('node-persist')
|
const Storage = require('node-persist')
|
||||||
|
const { fork } = require('child_process')
|
||||||
|
|
||||||
const FieldError = require('../fieldError')
|
const FieldError = require('../fieldError')
|
||||||
const logger = require('../../config/log')
|
const logger = require('../../config/log')
|
||||||
const {
|
const {
|
||||||
|
|
@ -12,6 +14,9 @@ const {
|
||||||
convertToEncryptedMessage,
|
convertToEncryptedMessage,
|
||||||
convertBase64ToBuffer
|
convertBase64ToBuffer
|
||||||
} = require('./crypto')
|
} = require('./crypto')
|
||||||
|
const { invoke } = require('./subprocess')
|
||||||
|
|
||||||
|
const cryptoSubprocess = fork('utils/ECC/subprocess')
|
||||||
|
|
||||||
const nodeKeyPairs = new Map()
|
const nodeKeyPairs = new Map()
|
||||||
const devicePublicKeys = new Map()
|
const devicePublicKeys = new Map()
|
||||||
|
|
@ -62,8 +67,8 @@ const generateKeyPair = async deviceId => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const privateKey = ECCrypto.generatePrivate()
|
const privateKey = await invoke('generatePrivate', [], cryptoSubprocess)
|
||||||
const publicKey = ECCrypto.getPublic(privateKey)
|
const publicKey = await invoke('getPublic', [privateKey], cryptoSubprocess)
|
||||||
const privateKeyBase64 = convertBufferToBase64(privateKey)
|
const privateKeyBase64 = convertBufferToBase64(privateKey)
|
||||||
const publicKeyBase64 = convertBufferToBase64(publicKey)
|
const publicKeyBase64 = convertBufferToBase64(publicKey)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue