-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: the G1 curve should support element conversion ( PROOF-666 ) (#22)
* feat: the bls12-381 base field have an operation to move uint8_t elements ( PROOF-666 ) * feat: the g1 curve should be able to move affine elements ( PROOF-666 ) * refactor: the g1 affine element should use uint8_t to represent infinity ( PROOF-666 ) * feat: add converstion between g1 projective and affine elements ( PROOF-666 ) * chore: remove unnecessary namespace prefix ( PROOF-666 ) * feat: add affine to projective element conversion ( PROOF-666 ) * chore: correct test section name ( PROOF-666 ) * refactor: rewrite convert to match conversion_ultilty in curve21 package ( PROOF-666 ) * refactor: move curve_g1 affine identity to element_affine component ( PROOF-666 ) * refactor: move coversion_ultility component to type package ( PROOF-666 ) * remove element_affine cmov function to avoid circular dependencies * refactor: move generic cmov to base/num package ( PROOF-666 )
- Loading branch information
1 parent
d1e8fad
commit d7ef890
Showing
18 changed files
with
342 additions
and
39 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/** Proofs GPU - Space and Time's cryptographic proof algorithms on the CPU and GPU. | ||
* | ||
* Copyright 2023-present Space and Time Labs, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
#include "sxt/base/num/cmov.h" | ||
|
||
#include "sxt/base/test/unit_test.h" | ||
|
||
using namespace sxt; | ||
using namespace sxt::basn; | ||
|
||
TEST_CASE("cmov correctly moves") { | ||
SECTION("uint8_t elements") { | ||
uint8_t h{0}; | ||
uint8_t g{0}; | ||
constexpr uint8_t i{1}; | ||
|
||
cmov(h, i, true); | ||
cmov(g, i, false); | ||
|
||
REQUIRE(h == i); | ||
REQUIRE(g == 0); | ||
} | ||
|
||
SECTION("uint16_t elements") { | ||
uint16_t h{0}; | ||
uint16_t g{0}; | ||
constexpr uint16_t i{1}; | ||
|
||
cmov(h, i, true); | ||
cmov(g, i, false); | ||
|
||
REQUIRE(h == i); | ||
REQUIRE(g == 0); | ||
} | ||
|
||
SECTION("uint32_t elements") { | ||
uint32_t h{0}; | ||
uint32_t g{0}; | ||
constexpr uint32_t i{1}; | ||
|
||
cmov(h, i, true); | ||
cmov(g, i, false); | ||
|
||
REQUIRE(h == i); | ||
REQUIRE(g == 0); | ||
} | ||
|
||
SECTION("uint64_t elements") { | ||
uint64_t h{0}; | ||
uint64_t g{0}; | ||
constexpr uint64_t i{1}; | ||
|
||
cmov(h, i, true); | ||
cmov(g, i, false); | ||
|
||
REQUIRE(h == 1); | ||
REQUIRE(g == 0); | ||
} | ||
|
||
SECTION("signed int elements") { | ||
int h{0}; | ||
int g{0}; | ||
constexpr int i{-1}; | ||
|
||
cmov(h, i, true); | ||
cmov(g, i, false); | ||
|
||
REQUIRE(h == i); | ||
REQUIRE(g == 0); | ||
} | ||
} |
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
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** Proofs GPU - Space and Time's cryptographic proof algorithms on the CPU and GPU. | ||
* | ||
* Copyright 2023-present Space and Time Labs, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
#include "sxt/curve_g1/type/conversion_utility.h" |
Oops, something went wrong.