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

feat(wasm): bind CompactListExpander::get_kind_of #1496

Merged
merged 2 commits into from
Aug 30, 2024
Merged

Conversation

tmontaigu
Copy link
Contributor

And other things to allow wasm users to explore
what kind of data is stored in the compact list.

And other things to allow wasm users to explore
what kind of data is stored in the compact list.
@cla-bot cla-bot bot added the cla-signed label Aug 28, 2024
@tmontaigu tmontaigu requested a review from IceTDrinker August 28, 2024 17:36
@tmontaigu
Copy link
Contributor Author

tmontaigu commented Aug 28, 2024

Technically, the get_kind_of API could be implemented on the CompactCiphertextList and ProvenCompactCiphertextList types

This would allow users to chek the data kinds at each slot before having to expand or verify the zk proof, is it something that we want to have ?

@IceTDrinker
Copy link
Member

For BC we need to be able to do it without expanding

Copy link
Member

@IceTDrinker IceTDrinker left a comment

Choose a reason for hiding this comment

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

As discussed it would likely be better to be able to call those functions on the objects themselves as the issue is to be able to fetch metadata without expanding (as if there is packing currently it's not possible to run PBSes in wasm to unpack the blocks)

This adds the ability to query the length and types
contained in a CompactCiphertextList and ProvenCompactCiphertextList
without having to expand or verify the proof(s)
@tmontaigu tmontaigu requested a review from IceTDrinker August 29, 2024 12:25
tfhe/src/high_level_api/compact_list.rs Show resolved Hide resolved
Comment on lines +93 to +97
pub fn get_kind_of(&self, index: usize) -> Option<crate::FheTypes> {
self.0.get_kind_of(index).and_then(|data_kind| {
crate::FheTypes::from_data_kind(data_kind, self.0.ct_list.message_modulus)
})
}
Copy link
Member

Choose a reason for hiding this comment

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

does not work for packed lists ? the modulus would be message_modulus * carry_modulus ?

Copy link
Contributor Author

@tmontaigu tmontaigu Aug 29, 2024

Choose a reason for hiding this comment

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

Yes, it work because the metada is metadata, it does not care whether the actual block are packed or not

The integer metadata keeps the bool or signed/unsigned kind with the number of blocks of the original input, the hlapi list just require the message modulus to be able to know how many bits a block encrypts to then be able to translate a num blocks in a num bits

@IceTDrinker
Copy link
Member

damn it may not be possible to properly return the data kind without expansion if we have a block ending at a boundary in a ciphertext when things are packed ?

Copy link
Member

@IceTDrinker IceTDrinker left a comment

Choose a reason for hiding this comment

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

Thanks for the clarifications !

@tmontaigu
Copy link
Contributor Author

The test of get_kind_of used on ProvenCompactCiphertextList (which iirc is packed) should prove that things are ok even when data is packed

@tmontaigu tmontaigu merged commit 8ddee20 into main Aug 30, 2024
90 checks passed
@tmontaigu tmontaigu deleted the tm/wasm-get-kind-of branch August 30, 2024 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants