Skip to content

Commit

Permalink
style: Apply rustfmt default formatting (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
conr2d authored Jan 18, 2025
1 parent 2fb1735 commit 3822b29
Show file tree
Hide file tree
Showing 8 changed files with 470 additions and 489 deletions.
36 changes: 12 additions & 24 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,31 +1,19 @@
root = true

[*]
indent_style=tab
indent_size=tab
tab_width=4
end_of_line=lf
charset=utf-8
trim_trailing_whitespace=true
max_line_length=100
insert_final_newline=true
indent_style = space
indent_size = 4
tab_width = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.toml]
max_line_length=off
[*.{md,sh,toml,yml}]
indent_size = 2

[*.md]
max_line_length=80
indent_style=space
indent_size=2
max_line_length = 80

[*.yml]
indent_style=space
indent_size=2
tab_width=8
end_of_line=lf

[*.sh]
indent_style=space
indent_size=2
tab_width=8
end_of_line=lf
[*.rs]
max_line_length = 100
24 changes: 0 additions & 24 deletions .rustfmt.toml

This file was deleted.

38 changes: 21 additions & 17 deletions src/aux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,65 +9,69 @@

/// Private key size (in bytes). The size is exact.
pub const fn falcon_privkey_size(logn: usize) -> usize {
(if logn <= 3 { 3 << logn } else { ((10 - (logn >> 1)) << (logn - 2)) + (1 << logn) }) + 1
(if logn <= 3 {
3 << logn
} else {
((10 - (logn >> 1)) << (logn - 2)) + (1 << logn)
}) + 1
}

/// Public key size (in bytes). The size is exact.
pub const fn falcon_pubkey_size(logn: usize) -> usize {
(if logn <= 1 { 4 } else { 7 << (logn - 2) }) + 1
(if logn <= 1 { 4 } else { 7 << (logn - 2) }) + 1
}

/// Maximum signature size (in bytes) when using the COMPRESSED format.
pub const fn falcon_sig_compressed_maxsize(logn: usize) -> usize {
((((11 << logn) + (101 >> (10 - logn))) + 7) >> 3) + 41
((((11 << logn) + (101 >> (10 - logn))) + 7) >> 3) + 41
}

/// Signature size (in bytes) when using the PADDED format. The size is exact.
pub const fn falcon_sig_padded_size(logn: usize) -> usize {
44 + 3 * (256 >> (10 - logn))
+ 2 * (128 >> (10 - logn))
+ 3 * (64 >> (10 - logn))
+ 2 * (16 >> (10 - logn))
- 2 * (2 >> (10 - logn))
- 8 * (1 >> (10 - logn))
44 + 3 * (256 >> (10 - logn))
+ 2 * (128 >> (10 - logn))
+ 3 * (64 >> (10 - logn))
+ 2 * (16 >> (10 - logn))
- 2 * (2 >> (10 - logn))
- 8 * (1 >> (10 - logn))
}

/// Signature size (in bytes) when using the CT format. The size is exact.
pub const fn falcon_sig_ct_size(logn: usize) -> usize {
(3 << (logn - 1)) - if logn == 3 { 1 } else { 0 } + 41
(3 << (logn - 1)) - if logn == 3 { 1 } else { 0 } + 41
}

/// Temporary buffer size for key pair generation.
pub const fn falcon_tmpsize_keygen(logn: usize) -> usize {
(if logn <= 3 { 272 } else { 28 << logn }) + (3 << logn) + 7
(if logn <= 3 { 272 } else { 28 << logn }) + (3 << logn) + 7
}

/// Temporary buffer size for computing the public key from the private key.
pub const fn falcon_tmpsize_makepub(logn: usize) -> usize {
(6 << logn) + 1
(6 << logn) + 1
}

/// Temporary buffer size for generating a signature ("dynamic" variant).
pub const fn falcon_tmpsize_signdyn(logn: usize) -> usize {
(78 << logn) + 7
(78 << logn) + 7
}

/// Temporary buffer size for generating a signature ("tree" variant, with an expanded key).
pub const fn falcon_tmpsize_signtree(logn: usize) -> usize {
(50 << logn) + 7
(50 << logn) + 7
}

/// Temporary buffer size for expanding a private key.
pub const fn falcon_tmpsize_expandpriv(logn: usize) -> usize {
(52 << logn) + 7
(52 << logn) + 7
}

/// Size of an expanded private key.
pub const fn falcon_expandedkey_size(logn: usize) -> usize {
((8 * logn + 40) << logn) + 8
((8 * logn + 40) << logn) + 8
}

/// Temporary buffer size for verifying a signature.
pub const fn falcon_tmpsize_verify(logn: usize) -> usize {
(8 << logn) + 1
(8 << logn) + 1
}
Loading

0 comments on commit 3822b29

Please sign in to comment.