-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update components to support four limbs
- Loading branch information
1 parent
db2d628
commit 8005aca
Showing
11 changed files
with
43 additions
and
53 deletions.
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
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 |
---|---|---|
|
@@ -14,18 +14,10 @@ | |
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
/** | ||
* Adopted from zkcrypto/bls12_381 | ||
* | ||
* Copyright (c) 2021 | ||
* Sean Bowe <[email protected]> | ||
* Jack Grigg <[email protected]> | ||
* | ||
* See third_party/license/zkcrypto.LICENSE | ||
*/ | ||
#include "sxt/field25/property/lexicographically_largest.h" | ||
|
||
#include "sxt/base/test/unit_test.h" | ||
#include "sxt/field25/base/montgomery.h" | ||
#include "sxt/field25/constant/one.h" | ||
#include "sxt/field25/constant/zero.h" | ||
#include "sxt/field25/type/element.h" | ||
|
@@ -34,25 +26,25 @@ using namespace sxt; | |
using namespace sxt::f25p; | ||
|
||
TEST_CASE("lexicographically largest correctly identifies") { | ||
SECTION("zero is not largest") { REQUIRE(!lexicographically_largest(f12cn::zero_v)); } | ||
SECTION("zero is not largest") { REQUIRE(!lexicographically_largest(f25cn::zero_v)); } | ||
|
||
SECTION("one is not largest") { REQUIRE(!lexicographically_largest(f12cn::one_v)); } | ||
SECTION("one is not largest") { REQUIRE(!lexicographically_largest(f25cn::one_v)); } | ||
|
||
SECTION("pre-computed value that is not largest") { | ||
constexpr f12t::element e{0xa1fafffffffe5557, 0x995bfff976a3fffe, 0x03f41d24d174ceb4, | ||
0xf6547998c1995dbd, 0x778a468f507a6034, 0x020559931f7f8103}; | ||
REQUIRE(!lexicographically_largest(e)); | ||
} | ||
SECTION("(p_v-1)/2 in Montgomery form is not largest") { | ||
constexpr f25t::element e{0x9e10460b6c3e7ea3, 0xcbc0b548b438e546, 0xdc2822db40c0ac2e, | ||
0x183227397098d014}; | ||
f25t::element e_montgomery; | ||
f25b::to_montgomery_form(e_montgomery.data(), e.data()); | ||
|
||
SECTION("pre-computed value that is largest") { | ||
constexpr f12t::element e{0x1804000000015554, 0x855000053ab00001, 0x633cb57c253c276f, | ||
0x6e22d1ec31ebb502, 0xd3916126f2d14ca2, 0x17fbb8571a006596}; | ||
REQUIRE(lexicographically_largest(e)); | ||
REQUIRE(!lexicographically_largest(e_montgomery)); | ||
} | ||
|
||
SECTION("another pre-computed value that is largest") { | ||
constexpr f12t::element e{0x43f5fffffffcaaae, 0x32b7fff2ed47fffd, 0x07e83a49a2e99d69, | ||
0xeca8f3318332bb7a, 0xef148d1ea0f4c069, 0x040ab3263eff0206}; | ||
REQUIRE(lexicographically_largest(e)); | ||
SECTION("((p_v-1)/2)+1 in Montgomery form is largest") { | ||
constexpr f25t::element e{0x9e10460b6c3e7ea4, 0xcbc0b548b438e546, 0xdc2822db40c0ac2e, | ||
0x183227397098d014}; | ||
f25t::element e_montgomery; | ||
f25b::to_montgomery_form(e_montgomery.data(), e.data()); | ||
|
||
REQUIRE(lexicographically_largest(e_montgomery)); | ||
} | ||
} |
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
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