awslabs / mls-rs

An implementation of Messaging Layer Security (RFC 9420)
Apache License 2.0
99 stars 19 forks source link

feat(WASM): add nodejs webcrypto provider through feature gate #189

Open nicdard opened 2 months ago

nicdard commented 2 months ago

Issues:

Resolves #ISSUE-NUMBER1 Addresses #ISSUE-NUMBER2

Description of changes:

As NodeJs is implementing the WebCrypto API specification, adding the possibility to conditionally compile the webcrypto provider for NodeJs environment. This can be useful to enhance interoperability. In my case specifically, I need to have a node compatible provider to simplify testing and benchmarking my application using this library compiled to WASM.

Call-outs:

I am still a beginner in Rust and WASM

Testing:

This change is currently used in my master thesis project (@mulmarta we contacted you a while ago, David Balbás wrote you an email to ask around exporting the epoch secret).

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT license.

nicdard commented 1 month ago

Thanks @nicdard and hope to see the thesis / paper at some point!

Thanks! sure I will share later on when I have the thesis ready if you are interested :)

nicdard commented 3 weeks ago

@mulmarta @tomleavy I found another compatibility issue with NodeJS: While Chrome generates the public key from a EC private key when importing it fro pkcs8 format, NodeJs doesn't, therefore an empty commit or an update proposal would fail. I am importing the key in jwk to force the generation of the public key part.

The same issue is also present in safari and firefox, with the difference that those are throwing an exception already when you try to import a pkcs8 key as a CryptoKey if it contains only the secret key bytes, so the workaround for Node cannot be applied there.