diff --git a/pages/make-contribution.vue b/pages/make-contribution.vue index 2f9128d..0015aaa 100644 --- a/pages/make-contribution.vue +++ b/pages/make-contribution.vue @@ -187,14 +187,12 @@ export default { await timeout(100) // allow UI to update before freezing in wasm console.log('Source params', data) - let msgBuffer = new TextEncoder('utf-8').encode(userInput) - let hashBuffer = await window.crypto.subtle.digest('SHA-256', msgBuffer) + const msgBuffer = new TextEncoder('utf-8').encode(userInput) + const hashBuffer = await window.crypto.subtle.digest('SHA-256', msgBuffer) const entropyFromUser = new Uint8Array(hashBuffer) // console.log('entropyFromUser', entropyFromUser.toString()) - msgBuffer = window.crypto.getRandomValues(new Uint8Array(1024)) - hashBuffer = await window.crypto.subtle.digest('SHA-256', msgBuffer) - const entropyFromBrowser = new Uint8Array(hashBuffer) + const entropyFromBrowser = window.crypto.getRandomValues(new Uint8Array(32)) // console.log('entropyFromBrowser', entropyFromBrowser.toString()) // suffle the browser and user random diff --git a/server/controllers/contribute.js b/server/controllers/contribute.js index dd151a4..600832a 100644 --- a/server/controllers/contribute.js +++ b/server/controllers/contribute.js @@ -8,7 +8,6 @@ const aws = require('aws-sdk') const express = require('express') const { Mutex } = require('async-mutex') const multer = require('multer') -const blake2 = require('blake2') const mutex = new Mutex() const s3 = new aws.S3() @@ -88,14 +87,14 @@ router.post('/response', upload.single('response'), async (req, res) => { await uploadToS3({ filename: req.file.filename, contributionIndex }) } console.log('Committing changes') - await Contribution.create({ name, company, handle, socialType, token }) - await fs.copyFile(`/tmp/tornado/${req.file.filename}`, './server/snark_files/current.params') await fs.copyFile( './server/snark_files/current.params', `./server/snark_files/response_${contributionIndex}` ) + await Contribution.create({ name, company, handle, socialType, token }) + console.log('Contribution finished.') res.json({ contributionIndex, token }) } catch (e) {