Get rid of a getter for `ciphertext` in EncryptionResult
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 https://github.com/rustwasm/wasm-bindgen/issues/439.
Remove the getter when the issue is fixed, or maybe when wasm-bindgen starts supporting tuples.
@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?
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.
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.