Skip to content

Instantly share code, notes, and snippets.

@et4te
Created January 15, 2019 15:39
Show Gist options
  • Save et4te/94fed9f956605af147e72860e0e32147 to your computer and use it in GitHub Desktop.
Save et4te/94fed9f956605af147e72860e0e32147 to your computer and use it in GitHub Desktop.
Wrap the compiled js_of_ocaml with a function (here I called it OCamlLoader()), load some dependencies and then load the OCaml
let HACL = HaclLoader();
let sha256_init = HACL._Hacl_SHA2_256_init;
let sha256_update = HACL._Hacl_SHA2_256_update;
let sha256_finish = HACL._Hacl_SHA2_256_finish;
let state
let state_buffer
let message
let message_buffer
let hash
let hash_buffer
let sizeof_blake2b_state = function(s) {
console.log('sizeof_blake2b_state');
return 0;
}
let sizeof_secp256k1_num = function(s) {
console.log('sizeof_secp256k1_num');
return 0;
}
let caml_fill_bigstring = function(val, val_ofs, val_len, val_byte) {
console.log('ml_secp256k1_fe_const_bytecode');
// Fill val_buf with val_byte
for (let i = 0; i < val_len; i++) {
val.data[i + val_ofs] = val_byte;
}
}
let ml_secp256k1_fe_const_bytecode = function(argv, argn) {
console.log('ml_secp256k1_fe_const_bytecode');
console.log(argv);
for (let i = 0; i < 9; i++) {
console.log(argv.data[i]);
}
console.log('argn: ' + argn);
return 0;
}
let ml_secp256k1_ge_of_fields = function(s) {
console.log('ml_secp256k1_ge_of_fields');
return 0;
}
let uECC_curve_stub = function(s) {
console.log('uECC_curve_stub');
return 0;
}
let uECC_curve_private_key_stub = function(s) {
console.log('uECC_curve_private_key_stub');
return 0;
}
let uECC_curve_private_key_size_stub = function(s) {
console.log('uECC_curve_private_key_size_stub');
return 0;
}
let uECC_curve_public_key_size_stub = function(s) {
console.log('uECC_curve_public_key_size_stub');
return 0;
}
let ml_Hacl_SHA2_256_init = HACL._Hacl_SHA2_256_init;
let ml_Hacl_SHA2_256_update = HACL._Hacl_SHA2_256_update;
let ml_Hacl_SHA2_256_update_last = HACL._Hacl_SHA2_256_update_last;
let ml_Hacl_SHA2_256_finish = HACL._Hacl_SHA2_256_finish;
HACL.onRuntimeInitialized = function() {
// Load secp256k1 wasm
// Load uECC wasm
OCamlLoader();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment