-
Notifications
You must be signed in to change notification settings - Fork 1
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
Least authority remediation #40
Open
trbritt
wants to merge
18
commits into
main
Choose a base branch
from
LEAST_AUTHORITY_REMEDIATION
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
c42983b
removed naf + montgomery ladder
trbritt ce0504b
test fp6 edge cases
trbritt 8e7d8ee
basic fp12 sparse mul test
trbritt 5bc4d2a
added secrets for keys and sigs
trbritt 2bc426c
added secrets for keys and sigs
trbritt 76bbd62
removed inaccurate and unused fp2 is_square
trbritt 48de24e
correct instantiation of field extension default
trbritt 7f40ac0
corrected comments and refs throughout
trbritt c30fc34
require libsodium for CI
trbritt 60e20cb
clippy
trbritt 00bde90
added docs throughout + tests in secrets
trbritt d730164
fixed broken test to avoid compiler reording optimizations
trbritt 0c7388d
increased code cov on high level fcns
trbritt ecdc09d
added forgotten test for ptr on fp2
trbritt 42ddc85
Revert "added forgotten test for ptr on fp2"
trbritt 649313f
enhanced randomness of tests
trbritt 8b0bfa4
changed method of ran group element generation
trbritt 3226731
clippy
trbritt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -101,6 +101,9 @@ Shallue-van de Woestijne encoding for elliptic curve points. | |
The multiprecision arithmetic operations are implemented in constant time, ensuring resistance to side-channel attacks. | ||
Constant-time operations are used whenever possible, and there are currently no variable-time functions used in Sylow. | ||
|
||
Furthermore, all key generation and manipulation utilities utilize the `secrets` crate, to ensure that all keys and | ||
signatures are `mprotect`-ed during the entirety of the application runtime. | ||
|
||
If you discover any security issues, please report them to [[email protected]](mailto:[email protected]). | ||
|
||
## Documentation | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -552,26 +552,9 @@ | |
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
use crypto_bigint::{rand_core::OsRng, U256}; | ||
use crypto_bigint::rand_core::OsRng; | ||
use subtle::ConstantTimeEq; | ||
|
||
fn create_field(value: [u64; 4]) -> Fp { | ||
Fp::new(U256::from_words(value)) | ||
} | ||
fn create_field_extension(v: [[u64; 4]; 12]) -> Fp12 { | ||
Fp12::new(&[ | ||
Fp6::new(&[ | ||
Fp2::new(&[create_field(v[0]), create_field(v[1])]), | ||
Fp2::new(&[create_field(v[2]), create_field(v[3])]), | ||
Fp2::new(&[create_field(v[4]), create_field(v[5])]), | ||
]), | ||
Fp6::new(&[ | ||
Fp2::new(&[create_field(v[6]), create_field(v[7])]), | ||
Fp2::new(&[create_field(v[8]), create_field(v[9])]), | ||
Fp2::new(&[create_field(v[10]), create_field(v[11])]), | ||
]), | ||
]) | ||
} | ||
mod addition_tests { | ||
use super::*; | ||
#[test] | ||
|
@@ -623,53 +606,14 @@ | |
|
||
#[test] | ||
fn test_multiplication_cases() { | ||
let a = create_field_extension([ | ||
[1, 0, 0, 0], | ||
[0, 2, 0, 0], | ||
[0, 0, 3, 0], | ||
[0, 0, 0, 4], | ||
[5, 0, 0, 0], | ||
[0, 6, 0, 0], | ||
[1, 0, 0, 0], | ||
[0, 2, 0, 0], | ||
[0, 0, 3, 0], | ||
[0, 0, 0, 4], | ||
[5, 0, 0, 0], | ||
[0, 6, 0, 0], | ||
]); | ||
let b = create_field_extension([ | ||
[0, 6, 0, 0], | ||
[5, 0, 0, 0], | ||
[0, 0, 0, 4], | ||
[0, 0, 3, 0], | ||
[0, 2, 0, 0], | ||
[1, 0, 0, 0], | ||
[0, 6, 0, 0], | ||
[5, 0, 0, 0], | ||
[0, 0, 0, 4], | ||
[0, 0, 3, 0], | ||
[0, 2, 0, 0], | ||
[1, 0, 0, 0], | ||
]); | ||
let a = Fp12::rand(&mut OsRng); | ||
let b = Fp12::rand(&mut OsRng); | ||
Comment on lines
+609
to
+610
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They'd prefer nondeterministic unit tests? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, they want fuzz/property tests. This is correct IMO. |
||
assert_eq!(a.square(), a * a, "Squaring and mul failed"); | ||
assert_eq!(b.square(), b * b, "Squaring and mul failed"); | ||
} | ||
#[test] | ||
fn test_frobenius() { | ||
let a = create_field_extension([ | ||
[1, 0, 0, 0], | ||
[0, 2, 0, 0], | ||
[0, 0, 3, 0], | ||
[0, 0, 0, 4], | ||
[5, 0, 0, 0], | ||
[0, 6, 0, 0], | ||
[1, 0, 0, 0], | ||
[0, 2, 0, 0], | ||
[0, 0, 3, 0], | ||
[0, 0, 0, 4], | ||
[5, 0, 0, 0], | ||
[0, 6, 0, 0], | ||
]); | ||
let a = Fp12::rand(&mut OsRng); | ||
assert_eq!( | ||
a, | ||
a.frobenius(1) | ||
|
@@ -707,6 +651,28 @@ | |
"Frobenius failed at cycle order 2" | ||
); | ||
} | ||
#[test] | ||
fn test_sparse() { | ||
let a = Fp12::rand(&mut OsRng); | ||
let two = Fp12::one() + Fp12::one(); | ||
|
||
let [ell0, ell_vv, ell_vw] = two.0[0].0; | ||
// this is an element of the form, in the 2x 𝔽ₚ⁶ representation: | ||
// f = [[g0, g1, g2], [h0, h1, h2]] = [ [2, 0, 0], [0, 0, 0]] = g + hw, | ||
// which would then be, in the 6x 𝔽ₚ² representation | ||
// f = g_0 + h_0w + g_1w^2 + h_1w^3 + g_2w^4 + h_2w^5 | ||
// = [2, 0, 0, 0, 0, 0] | ||
// The elements at indices (0, 2, 4) and therefore (2, 0, 0) respectively | ||
assert_eq!(ell0, Fp2::one() + Fp2::one(), "Index 0 extraction failed"); | ||
assert_eq!(ell_vv, Fp2::zero(), "Index 2 extraction failed"); | ||
assert_eq!(ell_vw, Fp2::zero(), "Index 4 extraction failed"); | ||
|
||
assert_eq!( | ||
a.sparse_mul(ell0, ell_vv, ell_vw), | ||
a * two, | ||
"Sparse mul failed" | ||
); | ||
} | ||
} | ||
mod division_tests { | ||
use super::*; | ||
|
@@ -728,6 +694,8 @@ | |
|
||
assert_eq!(a / one, a, "Division by one failed"); | ||
assert_eq!((a / b) * b, a, "Division-Mult composition failed"); | ||
|
||
assert_eq!(a.inv(), Fp12::one() / a, "Inverse failed"); | ||
} | ||
#[test] | ||
// #[should_panic(expected = "assertion failed: self.is_some.is_true_vartime()")] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
What's the change here?
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.
@trbritt