File tree Expand file tree Collapse file tree 2 files changed +28
-15
lines changed
src/lib/crypto/kimchi_bindings/js Expand file tree Collapse file tree 2 files changed +28
-15
lines changed Original file line number Diff line number Diff line change 11#! /usr/bin/env bash
22set -euo pipefail
33
4- CURRENT_DIRECTORY=$( pwd)
5- PROOF_SYSTEMS_ROOT=$( cd ../../../proof-systems && pwd)
4+ SCRIPT_DIR=$( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd)
5+ CURRENT_DIRECTORY=" ${SCRIPT_DIR} "
6+ PROOF_SYSTEMS_ROOT=$( cd " ${SCRIPT_DIR} /../../../proof-systems" && pwd)
7+ PLONK_NAPI_ROOT=" ${PROOF_SYSTEMS_ROOT} /plonk-napi"
68
7- cargo build \
8- --manifest-path " ${PROOF_SYSTEMS_ROOT} /Cargo.toml" \
9- --release \
10- -p plonk-napi
9+ TARGET_ROOT=" ${CARGO_TARGET_DIR:- " ${PROOF_SYSTEMS_ROOT} /target" } "
10+ export CARGO_TARGET_DIR=" ${TARGET_ROOT} "
1111
12- TARGET_ROOT=${CARGO_TARGET_DIR:- " ${PROOF_SYSTEMS_ROOT} /target" }
12+ cargo build \
13+ --manifest-path " ${PLONK_NAPI_ROOT} /Cargo.toml" \
14+ --release
1315
1416case " $( uname -s) " in
1517 Darwin* ) LIB_NAME=" libplonk_napi.dylib" ;;
Original file line number Diff line number Diff line change 11// Provides: plonk_wasm
22var plonk_wasm = require ( './plonk_wasm.js' ) ;
33var native = null ;
4- try {
5- native = require ( '../native/plonk_napi.node' ) ;
4+ try {
5+ native = require ( '../native/plonk_napi.node' ) ;
66} catch ( e ) {
7- // native not available, keep WASM
7+ // native not available, keep WASM
88}
99
10- // Overwrite only the functions that are already available in native
11- if ( native && native . caml_pasta_fp_poseidon_block_cipher ) {
12- plonk_wasm . caml_pasta_fp_poseidon_block_cipher = native . caml_pasta_fp_poseidon_block_cipher ;
10+ function snakeToCamel ( name ) {
11+ return name . replace ( / _ ( [ a - z ] ) / g, function ( _match , ch ) {
12+ return ch . toUpperCase ( ) ;
13+ } ) ;
1314}
14- if ( native && native . caml_pasta_fq_poseidon_block_cipher ) {
15- plonk_wasm . caml_pasta_fq_poseidon_block_cipher = native . caml_pasta_fq_poseidon_block_cipher ;
15+
16+ function override ( functionName ) {
17+ if ( ! native ) return ;
18+ var camel = snakeToCamel ( functionName ) ;
19+ var impl = native [ functionName ] || native [ camel ] ;
20+ if ( typeof impl === 'function' ) {
21+ plonk_wasm [ functionName ] = impl ;
22+ }
1623}
24+
25+ // Overwrite only the functions that are already available in native
26+ override ( 'caml_pasta_fp_poseidon_block_cipher' ) ;
27+ override ( 'caml_pasta_fq_poseidon_block_cipher' ) ;
You can’t perform that action at this time.
0 commit comments