privacy-scaling-explorations / ideas

4 stars 2 forks source link

FFJavascript Rewrite #6

Open AtHeartEngineer opened 1 year ago

AtHeartEngineer commented 1 year ago

Idea Proposal

FFJavascript rewrite

Short Description

Rewrite the ffjavascript library to be more flexible (change more of the finite field parameters) and to have better typing.

Problem Statement

The current ffjavascript library has some limitations, such as depending on web-workers which makes browser extension development difficult, and not being able to create custom fields/curves.

Solution

Fork ffjavascript, refactor with better typing, optional web-worker, and the ability to use custom curves/fields.

Key Stakeholders

@wanseob

Benefits

More flexibility and easier use of ffjavascript

Project Timeline

TBD

Project MVP

Adding Typescript types. Converting code base to typescript. Changing the build system from rollup to webpack to build with typescript. Compiling to commonjs and esmodule.

Nice to haves

Compiling with and without web-worker Adding ability to use custom fields.

Tech Stack

Node / Typescript / Webpack

aguzmant103 commented 1 year ago

Ideas board https://discord.com/channels/943612659163602974/1044988408373706762/1044988408373706762

sripwoud commented 1 year ago

github.com/AlDanial/cloc v 1.90 T=0.02 s (1837.1 files/s, 388193.7 lines/s)

Language files blank comment code

JavaScript 29 1087 206 4835

SUM: 29 1087 206 4835


Doesn't look "too" huge. But the 2 wasm deps don't have typings either. Would that need to be typed too? Or does anyone know alternative libraries?

 - wasmbuilder
   61 text files.

classified 59 files 59 unique files.
4 files ignored.

github.com/AlDanial/cloc v 1.90 T=0.04 s (1475.5 files/s, 561506.5 lines/s)

Language files blank comment code

JavaScript 49 3524 1065 14230 JSON 5 0 0 2817 YAML 2 6 3 30 Markdown 1 8 0 8

SUM: 57 3538 1068 17085


- wasmcurves
  20 text files.

classified 19 files 19 unique files.
4 files ignored.

github.com/AlDanial/cloc v 1.90 T=0.01 s (1491.6 files/s, 185980.5 lines/s)

Language files blank comment code

JavaScript 12 299 134 1479 JSON 1 0 0 36 YAML 2 6 3 30 Markdown 1 4 0 4

SUM: 16 309 137 1549

cedoor commented 1 year ago

wasmcurves contains a list of curves' implementations in WASM. However, the code is actually JS, as WASM operations are passed to JS functions. It might be interesting to create an abstraction of those curves in AssemblyScript (which is more user-friendly), so that anyone can create custom curves (probably very time-consuming though).

Or, if any Rust implementation to build custom curves/fields exists (e.g. arkworks ?), we could easily convert that crate to a WASM/JS package and re-write the remaining ffjavascript code in TS. The algebra should be the most difficult part.