Skip to content

Commit

Permalink
Fix compilation on WASM (arkworks-rs#794)
Browse files Browse the repository at this point in the history
Disable loop unrolling for `Fp::into_bigint` that led to WASM
miscompilations with too many local variables:

```
Error: failed to deserialize wasm module

Caused by:
    0: failed to parse code section
    1: locals exceed maximum (at offset 16977)
```

Issue diagnosed by @paberr and @ii-cruz.

Fixes arkworks-rs#615.

Co-authored-by: Pratyush Mishra <pratyushmishra@berkeley.edu>
  • Loading branch information
hrxi and Pratyush authored Feb 27, 2024
1 parent 2a8f518 commit 33d0868
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Pending

- [\#772](https://github.com/arkworks-rs/algebra/pull/772) (`ark-ff`) Implementation of `mul` method for `BigInteger`.
- [\#794](https://github.com/arkworks-rs/algebra/pull/794) (`ark-ff`) Fix `wasm` compilation.

### Breaking changes

Expand Down
3 changes: 2 additions & 1 deletion ff/src/fields/models/fp/montgomery_backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,8 @@ pub trait MontConfig<const N: usize>: 'static + Sync + Send + Sized {
}

#[inline]
#[unroll_for_loops(12)]
#[cfg_attr(not(target_family = "wasm"), unroll_for_loops(12))]
#[cfg_attr(target_family = "wasm", unroll_for_loops(6))]
#[allow(clippy::modulo_one)]
fn into_bigint(a: Fp<MontBackend<Self, N>, N>) -> BigInt<N> {
let mut r = (a.0).0;
Expand Down

0 comments on commit 33d0868

Please sign in to comment.