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
Several requirements on generic arguments of stdlib functions are only documented and not checked when they could be checked at compile-time.
E.g. for to_le_bits on Field:
/// # Safety/// Values of `N` equal to or greater than the number of bits necessary to represent the `Field` modulus/// (e.g. 254 for the BN254 field) allow for multiple bit decompositions. This is due to how the `Field` will/// wrap around due to overflow when verifying the decomposition.
#[builtin(to_le_bits)]
// docs:start:to_le_bitspubfnto_le_bits<letN: u32>(self: Self) -> [u1; N] {}
Happy Case
Find such stdlib functions
Add compile-time assertions, e.g.
#[builtin(to_le_bits_unsafe)]
fnto_le_bits_unsafe<letN: u32>(self: Self) -> [u1; N] {}
pubfnto_le_bits<letN: u32>(self: Self) -> [u1; N] {
static_assert(N < Field_modulus, "Values of `N` equal to or greater than..");
self.to_le_bits_unsafe::<N>()
}
Workaround
Yes
Workaround Description
Explicitly check inputs as per stdlib function docs
Additional Context
No response
Project Impact
Nice-to-have
Blocker Context
No response
Would you like to submit a PR for this Issue?
None
Support Needs
No response
The text was updated successfully, but these errors were encountered:
Problem
Several requirements on generic arguments of stdlib functions are only documented and not checked when they could be checked at compile-time.
E.g. for
to_le_bits
onField
:Happy Case
Workaround
Yes
Workaround Description
Explicitly check inputs as per stdlib function docs
Additional Context
No response
Project Impact
Nice-to-have
Blocker Context
No response
Would you like to submit a PR for this Issue?
None
Support Needs
No response
The text was updated successfully, but these errors were encountered: