Skip to content

Update Ciphertext bindings#155

Merged
KPrasch merged 10 commits intomainfrom
update-ciphertext-api
Aug 27, 2023
Merged

Update Ciphertext bindings#155
KPrasch merged 10 commits intomainfrom
update-ciphertext-api

Conversation

@piotr-roslaniec
Copy link

@piotr-roslaniec piotr-roslaniec commented Aug 14, 2023

Type of PR:

  • Feature

Required reviews:

  • 2

What this does:

  • Exposes Ciphertext.header -> CiphertextHeader and Ciphertext.payload -> bytes from Python bindings

Issues fixed/closed:

Why it's needed:

Explain how this PR fits in the greater context of the NuCypher Network.
E.g., if this PR address a nucypher/productdev issue, let reviewers know!

Notes for reviewers:

  • TODO: Only merge after testing these changes in the downstream
  • TODO: Make sure to also update nucypher-core stub files, *.pyi, upon updating
  • Based on Revamping Ferveo Ciphertexts (breaking changes ⚠️ ) #149 - Please review & merge it first
    • There's only one commit to review here: 1800d3c
  • Who is using Ciphertext.payload and how? Decrypter? Can we keep using Ciphertext instead?

@codecov-commenter
Copy link

Codecov Report

Merging #155 (5062f40) into main (03b4e35) will decrease coverage by 0.59%.
The diff coverage is 27.08%.

@@            Coverage Diff             @@
##             main     #155      +/-   ##
==========================================
- Coverage   77.96%   77.38%   -0.59%     
==========================================
  Files          23       23              
  Lines        4979     5005      +26     
==========================================
- Hits         3882     3873       -9     
- Misses       1097     1132      +35     
Files Changed Coverage Δ
ferveo/src/bindings_python.rs 50.59% <0.00%> (-1.39%) ⬇️
tpke/src/ciphertext.rs 88.02% <40.00%> (-1.40%) ⬇️
ferveo/src/api.rs 87.32% <44.00%> (-2.64%) ⬇️

@derekpierre
Copy link
Member

derekpierre commented Aug 14, 2023

Looks good so far. Two comments from me:

  • Would love to see some tests for Ciphertext/CiphertextHeader/payload bindings.

Should we also make these methods available to WASM bindings? Why?

  • I believe you will need WASM bindings for the Ciphertext/CiphertextHeader. The ThresholdDecryptionRequest created from nucypher-ts would also only use the CiphertextHeader and not Ciphertext, no?

@derekpierre
Copy link
Member

derekpierre commented Aug 14, 2023

One more question: How does creating a decryption share work now that only the CiphertextHeader is needed in the ThresholdDecryptionRequest and sent, and not the original ferveo Ciphertext object..? Are additional changes needed in that area i.e. create_decryption_share_simple(...)...?

@piotr-roslaniec
Copy link
Author

piotr-roslaniec commented Aug 16, 2023

@derekpierre Thanks for your input, now I have a clear picture of what should be the scope of this PR. I'm going to turn it into a draft and add some changes.

@piotr-roslaniec piotr-roslaniec marked this pull request as draft August 16, 2023 08:39
Co-authored-by: Derek Pierre <derek.pierre@gmail.com>
Copy link
Member

@derekpierre derekpierre left a comment

Choose a reason for hiding this comment

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

🎸

Copy link
Member

@cygnusv cygnusv left a comment

Choose a reason for hiding this comment

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

Just some minor comments. Great work @piotr-roslaniec !

})
}
pub fn payload(&self) -> Vec<u8> {
self.ciphertext.clone()
Copy link
Member

Choose a reason for hiding this comment

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

Why clone?

Copy link
Author

Choose a reason for hiding this comment

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

Because &self.ciphertext is hidden behind &self reference, and we need to take the ownership of those bytes to be used in bindings

rng,
)
.unwrap();
let _rng = &mut thread_rng();
Copy link
Member

Choose a reason for hiding this comment

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

Isn't this handled by L56?

Copy link
Author

Choose a reason for hiding this comment

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

It's an unused variable, removing it now.

rng,
)
.unwrap();
let _rng = &mut thread_rng();
Copy link
Member

Choose a reason for hiding this comment

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

Same as above.

Copy link
Author

Choose a reason for hiding this comment

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

It's an unused variable, removing it now.

@KPrasch KPrasch removed the do not merge 🛑 Do not merge please label Aug 27, 2023
@KPrasch KPrasch merged commit bc0a6a5 into main Aug 27, 2023
@piotr-roslaniec piotr-roslaniec deleted the update-ciphertext-api branch August 28, 2023 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Completed

Development

Successfully merging this pull request may close these issues.

5 participants