Skip to content

Building for wasm doesn't work (well, building works but running does not) #124

Closed
@apoelstra

Description

@apoelstra
Member

Related to #119

We currently depend on the following symbols:

  • malloc
  • free

(We additionally depended on abort and printf until #115 )

This prevents use with rust-wasm for this library and all downstream users (e.g. rust-bitcoin). While doing any cryptography in a browser is very ill-advised, rust-secp does a lot more than just signing and verification (it can also parse and display keys), and its downstream deps such as rust-bitcoin do many things that certainly should be possible and easy to do with rust-wasm.

We also don't want to encourage users to find other pure-Rust secp256k1 libraries with dramatically less review and QA on them, and to use these in a Bitcoin context.

See rust-bitcoin/rust-bitcoin#240 for earlier discussion.

Activity

apoelstra

apoelstra commented on Jul 4, 2019

@apoelstra
MemberAuthor

I was able to get a wasm application working which parses and Javascript alerts a public key. Unfortunately to do so I needed to

  1. Hack Implementing pre allocation context creation #116 to eliminate all calls to context_create and context_destroy (this I expected).
  2. Actually delete context_create, scratch_space_create, context_destroy, scratch_space_destroy from the libsecp source. Deleting the FFI bindings was not enough (this I did not expect).
elichai

elichai commented on Jul 4, 2019

@elichai
Member

Yeah, we need to eliminate the symbols, we don't use the scratch space, right?

apoelstra

apoelstra commented on Jul 4, 2019

@apoelstra
MemberAuthor

Correct, we do not use the scratch space. (It will eventually be used for MuSig but before then we'll figure out a preallocated solution for it.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @apoelstra@elichai

      Issue actions

        Building for wasm doesn't work (well, building works but running does not) · Issue #124 · rust-bitcoin/rust-secp256k1