You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some traits are currently only implemented for specific Uint sizes, like Encoding, ConcatMixed/SplitMixed, WideningMul, and some others. This creates problems when working with big Uints of non-standard sizes, and increases compilation time because of all the macros creating the implementations.
I wonder if there's any desire to try and make these traits implementable generically, or make analogous traits that can be implemented generically, to exist side by side?
E.g. in my library I would like to use ConcatMixed, but can't, since it's only implemented up to U1024. So I have a trait Extendable, such that
That is, the output length has to be provided explicitly, and if it is not consistent with the Uint length, a compile-time error is raised. Arguably, it is a clearer compile-time error compared to what you get if you try to use ConcatMixed with a type for which it is not implemented. Although, of course, in order to get it, you need to actually use to_wide() somewhere in your code, which is a downside.
I have a similar trait for the widening multiplication, where there's a compile-time check that the sum of the lengths of two arguments is equal to the output length.
The problem with having it defined locally is that I have to wrap Uints in a newtype in order to use it.
Alternatively, it is possible to implement generic non-allocating Serialize/Deserialize for Uint (without it having to depend on Encoding), but it requires the use of zerocopy or bytemuck to transmute between &[Limb] and &[u8].
Any interest of bringing any of that into crypto-bigint?
The text was updated successfully, but these errors were encountered:
Ideally I think all traits would be implemented for all sizes, yes. If you can remove the hardcoded size limitations and implement things for all sizes, that'd be great. The const comparison is a nice hack.
Where this is very difficult currently is safegcd which uses precalculated conversions between the sizes needed for an integer and its unsaturated 62-bit representation used for safegcd, but hopefully #755 could help address that.
Some traits are currently only implemented for specific
Uint
sizes, likeEncoding
,ConcatMixed
/SplitMixed
,WideningMul
, and some others. This creates problems when working with big Uints of non-standard sizes, and increases compilation time because of all the macros creating the implementations.I wonder if there's any desire to try and make these traits implementable generically, or make analogous traits that can be implemented generically, to exist side by side?
E.g. in my library I would like to use
ConcatMixed
, but can't, since it's only implemented up toU1024
. So I have a traitExtendable
, such thatThat is, the output length has to be provided explicitly, and if it is not consistent with the
Uint
length, a compile-time error is raised. Arguably, it is a clearer compile-time error compared to what you get if you try to useConcatMixed
with a type for which it is not implemented. Although, of course, in order to get it, you need to actually useto_wide()
somewhere in your code, which is a downside.I have a similar trait for the widening multiplication, where there's a compile-time check that the sum of the lengths of two arguments is equal to the output length.
For serialization, I have
The problem with having it defined locally is that I have to wrap
Uint
s in a newtype in order to use it.Alternatively, it is possible to implement generic non-allocating
Serialize/Deserialize
forUint
(without it having to depend onEncoding
), but it requires the use ofzerocopy
orbytemuck
to transmute between&[Limb]
and&[u8]
.Any interest of bringing any of that into
crypto-bigint
?The text was updated successfully, but these errors were encountered: