mirror of
https://github.com/privacy-scaling-explorations/mpc-hello.git
synced 2026-05-11 03:00:27 -04:00
Define circuit in regular files, add deployment link
This commit is contained in:
@@ -6,7 +6,9 @@ This is a template repository designed to be the hello-world of
|
||||
It's a minimal web app where users can make 1-to-1 connections with each other
|
||||
and compute the larger of two numbers.
|
||||
|
||||
## Usage
|
||||
Hosted on github pages: https://voltrevo.github.io/mpc-hello/.
|
||||
|
||||
## Running Locally
|
||||
|
||||
```sh
|
||||
npm install
|
||||
|
||||
3
src/circuit/isLarger.ts
Normal file
3
src/circuit/isLarger.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export default function isLarger(a: number, b: number): boolean {
|
||||
return a > b;
|
||||
}
|
||||
7
src/circuit/main.ts
Normal file
7
src/circuit/main.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
// This obviously doesn't need to be a separate file, but it's here to
|
||||
// demonstrate that you can split up your summon code like this.
|
||||
import isLarger from './isLarger.ts';
|
||||
|
||||
export default function main(a: number, b: number) {
|
||||
return isLarger(a, b) ? a : b;
|
||||
}
|
||||
@@ -1,17 +1,16 @@
|
||||
import * as summon from 'summon-ts';
|
||||
import { Protocol } from 'mpc-framework';
|
||||
import { EmpWasmBackend } from 'emp-wasm-backend';
|
||||
import getCircuitFiles from './getCircuitFiles';
|
||||
|
||||
export default async function generateProtocol() {
|
||||
await summon.init();
|
||||
|
||||
const circuit = summon.compileBoolean('/src/main.ts', 16, {
|
||||
'/src/main.ts': `
|
||||
export default function main(a: number, b: number) {
|
||||
return a > b ? a : b;
|
||||
}
|
||||
`,
|
||||
});
|
||||
const circuit = summon.compileBoolean(
|
||||
'circuit/main.ts',
|
||||
16,
|
||||
await getCircuitFiles(),
|
||||
);
|
||||
|
||||
const mpcSettings = [
|
||||
{
|
||||
|
||||
11
src/getCircuitFiles.ts
Normal file
11
src/getCircuitFiles.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
const files = import.meta.glob('./circuit/**/*.ts', { query: '?raw', import: 'default' });
|
||||
|
||||
export default async function getCircuitFiles() {
|
||||
const circuitFiles: Record<string, string> = {};
|
||||
|
||||
for (const [path, get] of Object.entries(files)) {
|
||||
circuitFiles[path.slice(2)] = (await get()) as string;
|
||||
}
|
||||
|
||||
return circuitFiles;
|
||||
}
|
||||
@@ -2,10 +2,16 @@
|
||||
"compilerOptions": {
|
||||
"target": "ES2020",
|
||||
"useDefineForClassFields": true,
|
||||
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
||||
"lib": [
|
||||
"ES2020",
|
||||
"DOM",
|
||||
"DOM.Iterable"
|
||||
],
|
||||
"module": "ESNext",
|
||||
"skipLibCheck": true,
|
||||
|
||||
"types": [
|
||||
"vite/client"
|
||||
],
|
||||
/* Bundler mode */
|
||||
"moduleResolution": "bundler",
|
||||
"allowImportingTsExtensions": true,
|
||||
@@ -13,13 +19,18 @@
|
||||
"isolatedModules": true,
|
||||
"noEmit": true,
|
||||
"jsx": "react-jsx",
|
||||
|
||||
/* Linting */
|
||||
"strict": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"noFallthroughCasesInSwitch": true
|
||||
},
|
||||
"include": ["src"],
|
||||
"references": [{ "path": "./tsconfig.node.json" }]
|
||||
}
|
||||
"include": [
|
||||
"src"
|
||||
],
|
||||
"references": [
|
||||
{
|
||||
"path": "./tsconfig.node.json"
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user