Skip to content

Commit

Permalink
add file io test
Browse files Browse the repository at this point in the history
  • Loading branch information
rnburn committed Oct 18, 2024
1 parent a980436 commit 0f77b4e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions cbindings/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ sxt_cc_component(
],
test_deps = [
":backend",
"//sxt/base/test:temp_file",
"//sxt/base/test:unit_test",
"//sxt/curve21/operation:add",
"//sxt/curve21/operation:double",
Expand Down
20 changes: 20 additions & 0 deletions cbindings/fixed_pedersen.t.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <vector>

#include "cbindings/backend.h"
#include "sxt/base/test/temp_file.h"
#include "sxt/base/test/unit_test.h"
#include "sxt/curve21/operation/add.h"
#include "sxt/curve21/operation/double.h"
Expand Down Expand Up @@ -75,6 +76,25 @@ TEST_CASE("we can compute multi-exponentiations with a fixed set of generators")
REQUIRE(res == generators[0] + 2 * 256 * generators[1]);
}

SECTION("we can read and write a handle to a file") {
bastst::temp_file temp_file{std::ios::binary};
temp_file.stream().close();

wrapped_handle h{generators.data(), 2};
REQUIRE(h.h != nullptr);

sxt_multiexp_handle_write_to_file(h.h, temp_file.name().c_str());

auto hp = sxt_multiexp_handle_new_from_file(SXT_CURVE_RISTRETTO255, temp_file.name().c_str());

uint8_t scalars[] = {1, 0, 0, 2};
c21t::element_p3 res;
sxt_fixed_multiexponentiation(&res, hp, 2, 1, 2, scalars);
REQUIRE(res == generators[0] + 2 * 256 * generators[1]);

sxt_multiexp_handle_free(hp);
}

SECTION("we can compute a multiexponentiation in packed form") {
cbn::reset_backend_for_testing();
const sxt_config config = {SXT_GPU_BACKEND, 0};
Expand Down

0 comments on commit 0f77b4e

Please sign in to comment.