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

Get rid of a getter for ciphertext in EncryptionResult #24

Open
fjarri opened this issue Nov 30, 2020 · 3 comments
Open

Get rid of a getter for ciphertext in EncryptionResult #24

fjarri opened this issue Nov 30, 2020 · 3 comments
Assignees
Labels
blocked Blocked by a third-party library WASM Related to WASM bindings

Comments

@fjarri
Copy link
Contributor

fjarri commented Nov 30, 2020

EncryptionResult struct which we have to return from encrypt() because wasm-bindgen does not support returning tuples has a field ciphertext: Box<[u8]>. Box<[u8]> does not implement Copy, so the field must be private, and we have to define a getter; see rustwasm/wasm-bindgen#439.

Remove the getter when the issue is fixed, or maybe when wasm-bindgen starts supporting tuples.

@fjarri fjarri added WASM Related to WASM bindings blocked Blocked by a third-party library labels Nov 30, 2020
@vepkenez vepkenez self-assigned this Jul 20, 2021
@vepkenez
Copy link
Contributor

@fjarri
I'm not sure I understand what needs to be done here.

This struct as is provides a decent interface through JS like
let { ciphertext, capsule } = umbral.encrypt(alice_pk, plaintext_bytes);
which is pretty "tuple like".

What exactly are we going for here?

@fjarri
Copy link
Contributor Author

fjarri commented Sep 14, 2021

I guess it may be a little simpler to destructure lists if you do several encryptions in a row, e.g.

let { ciphertext: ciphertext1, capsule: capsule1 } = umbral.encrypt(alice_pk, plaintext1);
let { ciphertext: ciphertext2, capsule: capsule2 } = umbral.encrypt(alice_pk, plaintext2);

// as opposed to
let [ciphertext1, capsule1] = umbral.encrypt(alice_pk, plaintext1);
let [ciphertext2, capsule2] = umbral.encrypt(alice_pk, plaintext2);

But perhaps the former variant is safer and should be forced anyway.

@fjarri
Copy link
Contributor Author

fjarri commented Sep 19, 2022

For now we're using a custom type (EncryptionResult, declared as TS [Capsule, Uint8Array]) and a manual conversion to js_sys::Array. When wasm-bindgen fixes the underlying issue, the internals can be updated too. The API is now

let [ciphertext1, capsule1] = umbral.encrypt(alice_pk, plaintext1);

as desired.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked Blocked by a third-party library WASM Related to WASM bindings
Projects
None yet
Development

No branches or pull requests

2 participants