Wasm compile with ic_bls12_381

hello everyone , I’m developing ethereum lightclient on ICP, I need verify the signature of ethereum commutee on consensus. so I import the ic_bls12_381 for it. then I can compile the canister . but when i extract the did file, I got a error:
Error: unknown import: __wbindgen_placeholder__::__wbindgen_describe has not been defined

How can I fix it?

Normally this happened because one of the dependencies not support in canister runtime

but the package is developed by dfinity for canister

I don’t mean this package, it can be another one.

but when I don’t import ic_bls12_381, all things is ok.

The ic_bls12_381 canister was created for use within the IC replicas, we (at least on the cryptography team) have not tested it in canisters at all. The crate is pure Rust so I’m not sure what the problem might be in terms of compiling it for webassembly.

I was reminded that we do use ic_bls12_381 in a couple of canisters such as VetKD API mock canister, without any apparent problems. Can you post some kind of minimal example that replicates the problem you’re seeing?

when I import this:
use ic_bls12_381::{
hash_to_curve::{ExpandMsgXmd, HashToCurve},
multi_miller_loop, G1Affine, G1Projective, G2Affine, G2Prepared, G2Projective, Gt, Scalar,
};
I got the error above

Here is an example canister which has similar imports

This compiles without issue, so I imagine there is something else going on. I would need more details, ideally a repository with a full reproducing testcase, in order to assist.

It’s probably that ic_bls12_381 has some optional dependency that depends on the getrandom crate.
In the example canister from Jack above, the crate only turns on the experimental feature instead of turning on all default features.
Could you try if you can do the same thing in your project?

If the getrandom dependency is inevitable, you can try the solution here.

@StewartYe I believe we identified the issue and that it should be resolved once Work around a Rust/LLVM issue affecting wasm32 targets by randombit · Pull Request #17 · dfinity/bls12_381 · GitHub is rolled out through the new crate versions.
You can also try to apply the same change in your project (via [patch] or in some other way) and report if it worked for you.