Skip to content
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

WASM bindings #78

Merged
merged 17 commits into from
Jan 23, 2022
Merged

WASM bindings #78

merged 17 commits into from
Jan 23, 2022

Conversation

piotr-roslaniec
Copy link
Contributor

@piotr-roslaniec piotr-roslaniec commented Dec 15, 2021

@piotr-roslaniec piotr-roslaniec changed the title [WIP] Wasm bindings [WIP] WASM bindings Dec 15, 2021
@fjarri fjarri added the WASM Related to WASM bindings label Dec 30, 2021
@piotr-roslaniec piotr-roslaniec force-pushed the wasm-bindings branch 2 times, most recently from 1d6b304 to 87ad212 Compare January 11, 2022 12:10
@piotr-roslaniec piotr-roslaniec changed the title [WIP] WASM bindings WASM bindings Jan 16, 2022

#[wasm_bindgen]
pub struct SecretKey {
backend: umbral_pre::SecretKey,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you switch from anonymous fields to backend?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had some issues with serde_wasm_bindgen, where anonymous fields would not be properly serialized o JSON. But I don't think this is relevant anymore. And I'm going to switch to builder patterns anyway.

I will change it back.

}

impl SecretKey {
pub fn inner(&self) -> &umbral_pre::SecretKey {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that for use in nucypher_core? Perhaps it can be done similarly to the Python bindings (AsBackend and FromBackend traits)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will try this out, thanks!

}

#[wasm_bindgen]
#[derive(Serialize, Deserialize)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are those for use in nucypher_core as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

base64 = { version = "0.13", default-features = false, features = ["alloc"] }
pyo3 = { version = "0.15", optional = true }
js-sys = { version = "0.3", optional = true }
wasm-bindgen = {version = "0.2.74", optional = true }
wee_alloc = { version = "0.4", optional = true }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it need to be here? It's only used in umbral-pre-wasm

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wee_alloc can go, but I need to keep others there because I need #[wasm-bindgen] and mapping errors with js_sys::Error. I feel like this is similar to keeping pyo3 for python-bindings here, no?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, I agree about the other too, I was asking about wee_alloc specifically

@piotr-roslaniec
Copy link
Contributor Author

@fjarri Thank you for your comments. I think some of the things you've pointed out will be solved when I switch some of the nucypher_core WASM bindings to the builder pattern. That should simplify some dependencies etc.

@codecov-commenter
Copy link

codecov-commenter commented Jan 17, 2022

Codecov Report

Merging #78 (e11773a) into master (7e2e098) will decrease coverage by 7.51%.
The diff coverage is 1.82%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #78      +/-   ##
==========================================
- Coverage   67.75%   60.23%   -7.52%     
==========================================
  Files          16       17       +1     
  Lines        1290     1451     +161     
==========================================
  Hits          874      874              
- Misses        416      577     +161     
Impacted Files Coverage Δ
umbral-pre/src/bindings_wasm.rs 0.00% <0.00%> (ø)
umbral-pre/src/capsule_frag.rs 88.19% <ø> (ø)
umbral-pre/src/key_frag.rs 89.94% <ø> (ø)
umbral-pre/src/serde.rs 86.66% <ø> (ø)
umbral-pre/src/capsule.rs 91.26% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7e2e098...e11773a. Read the comment docs.

@fjarri fjarri merged commit c4b1304 into nucypher:master Jan 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WASM Related to WASM bindings
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants