-
Notifications
You must be signed in to change notification settings - Fork 151
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(tfhe): add safe deserialiation #572
Conversation
@slab-ci cpu_fast_test |
please don't request reviews on draft PRs :) reduces the inbox github noise |
63cabe6
to
03bf39d
Compare
@slab-ci cpu_fast_test |
03bf39d
to
aa5a479
Compare
@slab-ci cpu_fast_test |
aa5a479
to
7896560
Compare
@slab-ci cpu_fast_test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks !
7896560
to
ce3ed52
Compare
@slab-ci cpu_fast_test |
ce3ed52
to
665f7ce
Compare
@slab-ci cpu_fast_test |
1 similar comment
@slab-ci cpu_fast_test |
1a34ad4
to
e121038
Compare
@slab-ci cpu_fast_test |
e121038
to
571d1ee
Compare
@slab-ci cpu_fast_test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First batch of comment on the updated PR, haven't checked the tests for now
tfhe/src/lib.rs
Outdated
|
||
pub mod conformance; | ||
|
||
pub trait Named { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I would prefer not having anything other than modules and imports in the root lib.rs, not sure if there are some conventions around that in rust
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can create a module named
but I don't see the benefit as it would only be 3 lines long
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could it be part of the safe_deserialization ? as it's used by it ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, but it forces the impl Named
to be behing a #[cfg(safe-deserialization)]
which is why I put it out
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm how bad does it complicate things ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not too bad
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would https://doc.rust-lang.org/std/any/fn.type_name.html be an alternative to having a custom Named
trait ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from the page you linked
This is intended for diagnostic use. The exact contents and format of the string returned are not specified,
it was the first solution but did not seem robust
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, and also just moving the struct from one module to another would change the string thus breaking serialization
use super::*; | ||
use crate::conformance::ParameterSetConformant; | ||
use crate::core_crypto::prelude::UnsignedInteger; | ||
use crate::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's plan adding more tests later down the line using the create_parameterized_test pattern from elsewhere in the crate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really see the benefit to hav this test with many parameter sets (except if they increase coverage, for exemple by using a non native modulus)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's just a matter of completeness :)
plus the macro instantiation of tests is really not that bad
410e8f0
to
f9d5a4b
Compare
@slab-ci cpu_fast_test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nearly there, we are down to the last details, thanks a lot for all the work up to this point !
use super::*; | ||
use crate::conformance::ParameterSetConformant; | ||
use crate::core_crypto::prelude::UnsignedInteger; | ||
use crate::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's just a matter of completeness :)
plus the macro instantiation of tests is really not that bad
f9d5a4b
to
ec9df18
Compare
@slab-ci cpu_fast_test |
btw have you made progress on having the HL part in the C API ? |
options | ||
.with_limit(VERSION_LENGTH_LIMIT) | ||
.serialize_into::<_, String>(&mut writer, &SERIALIZATION_VERSION.to_owned())?; | ||
|
||
options | ||
.with_limit(TYPE_NAME_LENGTH_LIMIT) | ||
.serialize_into::<_, String>(&mut writer, &T::NAME.to_owned())?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need these .to_owned() ? passign the &'static str should work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For deserialization, I think we have to use the String
type
I'm not sure a serialized &str
is guaranted to be deserializable as a String
which is why I did it this way
ec9df18
to
4531f3a
Compare
@slab-ci cpu_fast_test |
4531f3a
to
fe48db0
Compare
@slab-ci cpu_fast_test |
fe48db0
to
57f954d
Compare
@slab-ci cpu_fast_test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All right let's start with this, thanks a lot for the work !
Pull Request has been approved 🎉 |
Some tests will need to be added