mirror of
https://github.com/tornadocash/trusted-setup-server.git
synced 2024-11-21 17:36:54 +01:00
providing user entropy
This commit is contained in:
parent
2e8f758d38
commit
3406debde0
@ -64,3 +64,12 @@ $ docker-compose up -d
|
|||||||
1. The `current.params` file is your initial challenge file.
|
1. The `current.params` file is your initial challenge file.
|
||||||
1. copy `current.params`, `withdraw.json` and `phase1radix*` to `./server/snark_files` folder.
|
1. copy `current.params`, `withdraw.json` and `phase1radix*` to `./server/snark_files` folder.
|
||||||
1. `mv withdraw.json circuit.json`
|
1. `mv withdraw.json circuit.json`
|
||||||
|
|
||||||
|
|
||||||
|
## In case of WASM module changes
|
||||||
|
1. go to `phase2` folder in [phase2-bn254](https://github.com/tornadocash/phase2-bn254) (ceremony branch for now) and run the following command:
|
||||||
|
1. `wasm-pack build --release --target web -- --no-default-features --features wasm`
|
||||||
|
1. it will generate wasm modules in `pkg` folder, then you need to copy it to this project
|
||||||
|
1. `cp -r pkg/* <path_to_current_project>/lib/phase2 && cp pkg/phase2_bg.wasm <path_to_current_project>/static/_nuxt/lib/phase2/`
|
||||||
|
|
||||||
|
Example: `wasm-pack build --release --target web -- --no-default-features --features wasm && cp -r pkg/* ../../trusted-setup-nuxt/lib/phase2 && cp pkg/phase2_bg.wasm ../../trusted-setup-nuxt/static/_nuxt/lib/phase2/`
|
||||||
|
@ -20,5 +20,5 @@
|
|||||||
"module": "phase2.js",
|
"module": "phase2.js",
|
||||||
"homepage": "https://github.com/ebfull/phase2",
|
"homepage": "https://github.com/ebfull/phase2",
|
||||||
"types": "phase2.d.ts",
|
"types": "phase2.d.ts",
|
||||||
"sideEffects": "false"
|
"sideEffects": false
|
||||||
}
|
}
|
3
lib/phase2/phase2.d.ts
vendored
3
lib/phase2/phase2.d.ts
vendored
@ -2,9 +2,10 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
/**
|
/**
|
||||||
* @param {Uint8Array} params
|
* @param {Uint8Array} params
|
||||||
|
* @param {Uint8Array} entropy
|
||||||
* @returns {Uint8Array}
|
* @returns {Uint8Array}
|
||||||
*/
|
*/
|
||||||
export function contribute(params: Uint8Array): Uint8Array;
|
export function contribute(params: Uint8Array, entropy: Uint8Array): Uint8Array;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If `module_or_path` is {RequestInfo}, makes a request and
|
* If `module_or_path` is {RequestInfo}, makes a request and
|
||||||
|
@ -70,17 +70,20 @@ function getArrayU8FromWasm0(ptr, len) {
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @param {Uint8Array} params
|
* @param {Uint8Array} params
|
||||||
|
* @param {Uint8Array} entropy
|
||||||
* @returns {Uint8Array}
|
* @returns {Uint8Array}
|
||||||
*/
|
*/
|
||||||
export function contribute(params) {
|
export function contribute(params, entropy) {
|
||||||
var ptr0 = passArray8ToWasm0(params, wasm.__wbindgen_malloc);
|
var ptr0 = passArray8ToWasm0(params, wasm.__wbindgen_malloc);
|
||||||
var len0 = WASM_VECTOR_LEN;
|
var len0 = WASM_VECTOR_LEN;
|
||||||
wasm.contribute(8, ptr0, len0);
|
var ptr1 = passArray8ToWasm0(entropy, wasm.__wbindgen_malloc);
|
||||||
|
var len1 = WASM_VECTOR_LEN;
|
||||||
|
wasm.contribute(8, ptr0, len0, ptr1, len1);
|
||||||
var r0 = getInt32Memory0()[8 / 4 + 0];
|
var r0 = getInt32Memory0()[8 / 4 + 0];
|
||||||
var r1 = getInt32Memory0()[8 / 4 + 1];
|
var r1 = getInt32Memory0()[8 / 4 + 1];
|
||||||
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
var v2 = getArrayU8FromWasm0(r0, r1).slice();
|
||||||
wasm.__wbindgen_free(r0, r1 * 1);
|
wasm.__wbindgen_free(r0, r1 * 1);
|
||||||
return v1;
|
return v2;
|
||||||
}
|
}
|
||||||
|
|
||||||
let cachedTextEncoder = new TextEncoder('utf-8');
|
let cachedTextEncoder = new TextEncoder('utf-8');
|
||||||
|
2
lib/phase2/phase2_bg.d.ts
vendored
2
lib/phase2/phase2_bg.d.ts
vendored
@ -1,7 +1,7 @@
|
|||||||
/* tslint:disable */
|
/* tslint:disable */
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
export const memory: WebAssembly.Memory;
|
export const memory: WebAssembly.Memory;
|
||||||
export function contribute(a: number, b: number, c: number): void;
|
export function contribute(a: number, b: number, c: number, d: number, e: number): void;
|
||||||
export function __wbindgen_malloc(a: number): number;
|
export function __wbindgen_malloc(a: number): number;
|
||||||
export function __wbindgen_free(a: number, b: number): void;
|
export function __wbindgen_free(a: number, b: number): void;
|
||||||
export function __wbindgen_realloc(a: number, b: number, c: number): number;
|
export function __wbindgen_realloc(a: number, b: number, c: number): number;
|
||||||
|
Binary file not shown.
@ -60,7 +60,7 @@
|
|||||||
<div class="buttons is-centered">
|
<div class="buttons is-centered">
|
||||||
<b-button
|
<b-button
|
||||||
v-if="!isContributeBtnSnown"
|
v-if="!isContributeBtnSnown"
|
||||||
@click="makeContribution"
|
@click="getUserRandom"
|
||||||
:disabled="isContributeBtnDisabled"
|
:disabled="isContributeBtnDisabled"
|
||||||
type="is-primary"
|
type="is-primary"
|
||||||
outlined
|
outlined
|
||||||
@ -150,8 +150,22 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions('user', ['makeTweet', 'logOut', 'getUserData']),
|
...mapActions('user', ['makeTweet', 'logOut', 'getUserData']),
|
||||||
async makeContribution({ retry = 0 } = {}) {
|
getUserRandom() {
|
||||||
|
this.$buefy.dialog.prompt({
|
||||||
|
title: 'Contribution',
|
||||||
|
message: `Please provide a random input. The input, along with browser randomness, will be used as a source of entropy for your contribution.`,
|
||||||
|
inputAttrs: {
|
||||||
|
maxlength: 300
|
||||||
|
},
|
||||||
|
trapFocus: true,
|
||||||
|
onConfirm: (userInput) => {
|
||||||
|
this.makeContribution({ userInput })
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
async makeContribution({ userInput, retry = 0 } = {}) {
|
||||||
try {
|
try {
|
||||||
|
const contribute = await this.$contribute()
|
||||||
this.isContributeBtnSnown = true
|
this.isContributeBtnSnown = true
|
||||||
this.status.msg = ''
|
this.status.msg = ''
|
||||||
this.status.type = ''
|
this.status.type = ''
|
||||||
@ -162,12 +176,22 @@ export default {
|
|||||||
this.$root.$emit('enableLoading', 'Generating random contribution')
|
this.$root.$emit('enableLoading', 'Generating random contribution')
|
||||||
await timeout(100) // allow UI to update before freezing in wasm
|
await timeout(100) // allow UI to update before freezing in wasm
|
||||||
console.log('Source params', data)
|
console.log('Source params', data)
|
||||||
const contribute = await this.$contribute()
|
|
||||||
const result = contribute(data)
|
const encoder = new TextEncoder(userInput)
|
||||||
|
const entropyFromUser = encoder.encode(userInput)
|
||||||
|
|
||||||
|
const entropy = new Uint8Array(userInput.length)
|
||||||
|
const entropyFromBrowser = window.crypto.getRandomValues(entropy)
|
||||||
|
// suffle the browser and user random
|
||||||
|
for (let i = 0; i < entropyFromBrowser.length; i++) {
|
||||||
|
entropy[i] = entropyFromBrowser[i] + entropyFromUser[i]
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('entropy', entropy)
|
||||||
|
const result = contribute(data, entropy)
|
||||||
console.log('Updated params', result)
|
console.log('Updated params', result)
|
||||||
|
|
||||||
this.$root.$emit('enableLoading', 'Uploading and verifying your contribution')
|
this.$root.$emit('enableLoading', 'Uploading and verifying your contribution')
|
||||||
console.log('this.user.name', this.userName, this.userHandle, this.userCompany)
|
|
||||||
const formData = new FormData()
|
const formData = new FormData()
|
||||||
formData.append('response', new Blob([result], { type: 'application/octet-stream' }))
|
formData.append('response', new Blob([result], { type: 'application/octet-stream' }))
|
||||||
if (this.contributionType !== 'anonymous') {
|
if (this.contributionType !== 'anonymous') {
|
||||||
@ -202,7 +226,7 @@ export default {
|
|||||||
this.isContributeBtnSnown = false
|
this.isContributeBtnSnown = false
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e.message)
|
console.error(e)
|
||||||
this.status.msg = e.message
|
this.status.msg = e.message
|
||||||
this.status.type = 'is-danger'
|
this.status.type = 'is-danger'
|
||||||
this.isContributeBtnSnown = false
|
this.isContributeBtnSnown = false
|
||||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user