Skip to content

Add Array sizes up to 5000 (some of which are required for NTRU-Prime) #79

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

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions gen_large.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
start = 1025
Copy link
Member

Choose a reason for hiding this comment

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

Please don't use non-Rust languages for codegen

Copy link
Author

Choose a reason for hiding this comment

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

noted! I will try to rework something with proc-macros

end = 5000
skip_list = [2048, 4096]

print("//! do not edit, auto generated by:\n//!\tpython gen_large.py > src/sizes/auto_gen.rs\n")
print("use super::{impl_array_sizes, impl_array_sizes_with_import, uint};\n")

# first we implement the missing ArraySizes up to 1024
print("impl_array_sizes_with_import! {")
for i in range(513, 1024):
if i%16 == 0:
continue
print(" " + str(i) + " => " + "U" + str(i) + ",")
print("}\n")

for i in range(start, end):
if i in skip_list:
continue
print("pub type U" + str(i) + " = uint!(" + " ".join(bin(i)[2:][::-1]) + ");")

print("impl_array_sizes! {")
for i in range(start, end):
if i in skip_list:
continue
print(" " + str(i) + " => " + "U" + str(i) + ",")
print("}")
5 changes: 2 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
clippy::checked_conversions,
clippy::from_iter_instead_of_collect,
clippy::missing_errors_doc,
clippy::mod_module_files,
clippy::implicit_saturating_sub,
clippy::panic,
clippy::panic_in_result_fn,
Expand Down Expand Up @@ -207,7 +206,7 @@ where
U: Add<N>,
Sum<U, N>: ArraySize,
{
self.into_iter().chain(other.into_iter()).collect()
self.into_iter().chain(other).collect()
}

/// Splits `self` at index `N` in two arrays.
Expand Down Expand Up @@ -766,7 +765,7 @@ where

#[inline]
fn try_from(slice: &'a [T]) -> Result<Array<T, U>, TryFromSliceError> {
<&'a Self>::try_from(slice).map(Clone::clone)
<&'a Self>::try_from(slice).cloned()
}
}

Expand Down
Loading
Loading