Skip to content

Commit

Permalink
Fix incorrect WASM memory offset
Browse files Browse the repository at this point in the history
reserved_offset was two bytes off, this was causing adjustWebGL to
replace two bytes of the xoring array in memory, which changed the
farbling outcome on subsequent WebGL farbling runs.
  • Loading branch information
Martet committed Jul 4, 2023
1 parent 10ae9ae commit 141ee1d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions common/code_builders.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,10 +371,10 @@ function insert_wasm_code(code) {
// | CRC table | Xoring table | Reserved | Data
// | 256 * u16 | 8 * u32 | |
// +-----------------+--------------+----------+---------------------------------------- - -
// 0 512 542 1024
// 0 512 544 1024
const crc_offset = 0;
const xoring_offset = 512;
const reserved_offset = 542;
const reserved_offset = 544;
const data_offset = 1024;

WebAssembly.instantiateStreaming(fetch("/* WASM_URL */"), {env: {memory: wasm_memory}}).then(result => {
Expand Down
4 changes: 2 additions & 2 deletions wasm/assembly/farble.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
// | CRC table | Xoring table | Reserved | Data
// | 256 * u16 | 8 * u32 | |
// +-----------------+--------------+----------+---------------------------------------- - -
// 0 512 542 1024
// 0 512 544 1024
const crc_offset: usize = 0;
const xoring_offset: usize = 512;
const reserved_offset: usize = 542;
const reserved_offset: usize = 544;
const data_offset: usize = 1024;

var seed: u64;
Expand Down

0 comments on commit 141ee1d

Please sign in to comment.