-
Notifications
You must be signed in to change notification settings - Fork 652
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: added feature flag to core crypto to support wasm build #6387
Conversation
If we want to do this in the future, one question I would have is why do we want this crate to be compatible with wasm |
My use case:I am working with yew.rs to build Dapp. However, there is only For future use case:It enables developers can build web Dapp in Rust. My motivation:I build product in one programming language. So my team can manage the product from frontend to backend. It is important to me to enable scaling team smoothly. Since everyone work in Rust. I am not sure if it is the way near will do. I will keep the logic in my repository first. |
@matklad if you are interested to the SDK, you can check https://github.com/russellwmy/near-api-rs. But it is still WIP. |
Can you be more specific about what you are looking for? Is there some functionality that is missing from the secp/ed libraries in Rust, or is it just that you'd like a library that handles the different key types together with a shared API?
Unlikely it would come into the SDK, since it sounds like this would not be used within a contract. Some library could potentially be built out to expose a simple API that handles NEAR supported crypto operations, which could be used in the SDK or any other Rust tooling lib. Edit: it seems like you just wanted ed key support, but would it be beneficial to have secp also included with a wasm compatible package? If only using ED25519, I'm missing the motivation for using the nearcore internal crate |
I am looking for a Rust SDK can run in browser. So my application can interact with Near platform in browser. Which my application frontend is built with Rust framework yew.rs. I only find Rust SDK for interact with smart contract.
That would be good to have Rust SDK to do that. I did research for awhile. I cannot find one.
The internal crate using https://crates.io/crates/secp256k1. I try to build it but it seems it cannot compile into wasm. Maybe you have idea to make it works. But I noticed |
You can use https://github.com/near/near-jsonrpc-client-rs (cc @miraclx) or even https://github.com/near/workspaces-rs/ (although this is primarily just used as a testing framework for now) The Rust SDK is for building smart contracts, not for interacting with them
But you could just use a ed25519 library that compiles to wasm? What comes with the nearcore crate that doesn't exist there? A simpler API? |
added
In that case, I can do that, just create another things to the same things that nearcore provides. But I am thinking I am reinventing the wheel. Btw, I also think |
Drive by, but I've learned today that https://docs.rs/ed25519-compact/latest/ed25519_compact/ exists, and, from the cursory look, it might be better suited for wasm than |
@matklad Yes, we can replace the library. But we should replace BTW, I am successfully compile |
I just check their code. It is cool, small and less dependencies. We can check what is the security level first if we want to employ into nearcore. It is good for near if near is going to target embedded system in the future. |
Background:
There is not a good package to support
secp256k1
in WASM build. Therefore, we should add a feature flag to disablesecp256k1
to allow developer to build withoutsecp256k1
.Changes:
secp256k1
secp256k1
as default featureHow to test:
cargo build
, it should build successfullycargo build --no-default-features --target wasm32-unknown-unknown
, it should build successfully