Initial import of libdpf.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
commit
e4e666f459
4563 changed files with 1690372 additions and 0 deletions
10
examples/output_types/bit.cpp
Normal file
10
examples/output_types/bit.cpp
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
#include <iostream>
|
||||
#include "dpf.hpp"
|
||||
|
||||
int main()
|
||||
{
|
||||
auto [k0, k1] = dpf::make_dpf(std::uint8_t{3}, dpf::bit::one);
|
||||
auto y0 = dpf::eval_point(k0, std::uint8_t{3});
|
||||
auto y1 = dpf::eval_point(k1, std::uint8_t{3});
|
||||
std::cout << (static_cast<dpf::bit>(y0) + static_cast<dpf::bit>(y1)) << "\n";
|
||||
}
|
||||
12
examples/output_types/bitstring.cpp
Normal file
12
examples/output_types/bitstring.cpp
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#include <iostream>
|
||||
#include "dpf.hpp"
|
||||
|
||||
int main()
|
||||
{
|
||||
using bits = dpf::bitstring<8>;
|
||||
auto programmed = bits(0b10101001);
|
||||
auto [k0, k1] = dpf::make_dpf(std::uint8_t{2}, programmed);
|
||||
auto y0 = dpf::eval_point(k0, std::uint8_t{2});
|
||||
auto y1 = dpf::eval_point(k1, std::uint8_t{2});
|
||||
std::cout << (static_cast<bits>(y0) + static_cast<bits>(y1)) << "\n";
|
||||
}
|
||||
26
examples/output_types/custom.cpp
Normal file
26
examples/output_types/custom.cpp
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#include <cstdint>
|
||||
#include <iostream>
|
||||
#include "dpf.hpp"
|
||||
|
||||
struct point
|
||||
{
|
||||
std::uint32_t v{};
|
||||
point operator+(point rhs) const { return point{v + rhs.v}; }
|
||||
point operator-(point rhs) const { return point{v - rhs.v}; }
|
||||
bool operator==(point rhs) const { return v == rhs.v; }
|
||||
};
|
||||
|
||||
namespace dpf::leaf_arithmetic
|
||||
{
|
||||
template <> struct add_t<point, simde__m128i> final : detail::add4x32_t {};
|
||||
template <> struct subtract_t<point, simde__m128i> final : detail::sub4x32_t {};
|
||||
template <> struct multiply_t<point, simde__m128i> final : detail::mul4x32_t {};
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
auto [k0, k1] = dpf::make_dpf(std::uint8_t{9}, point{5});
|
||||
auto y0 = dpf::eval_point(k0, std::uint8_t{9});
|
||||
auto y1 = dpf::eval_point(k1, std::uint8_t{9});
|
||||
std::cout << (static_cast<point>(y0) + static_cast<point>(y1)).v << "\n";
|
||||
}
|
||||
11
examples/output_types/extended_types.cpp
Normal file
11
examples/output_types/extended_types.cpp
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
#include <iostream>
|
||||
#include "dpf.hpp"
|
||||
|
||||
int main()
|
||||
{
|
||||
auto [k0, k1] = dpf::make_dpf(std::uint8_t{1}, simde_uint128{7});
|
||||
auto y0 = dpf::eval_point(k0, std::uint8_t{1});
|
||||
auto y1 = dpf::eval_point(k1, std::uint8_t{1});
|
||||
auto sum = static_cast<simde_uint128>(y0) + static_cast<simde_uint128>(y1);
|
||||
std::cout << (sum == simde_uint128{7}) << "\n";
|
||||
}
|
||||
11
examples/output_types/integral_types.cpp
Normal file
11
examples/output_types/integral_types.cpp
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
#include <cstdint>
|
||||
#include <iostream>
|
||||
#include "dpf.hpp"
|
||||
|
||||
int main()
|
||||
{
|
||||
auto [k0, k1] = dpf::make_dpf(std::uint16_t{42}, std::uint32_t{7});
|
||||
auto y0 = dpf::eval_point(k0, std::uint16_t{42});
|
||||
auto y1 = dpf::eval_point(k1, std::uint16_t{42});
|
||||
std::cout << (static_cast<std::uint32_t>(y0) + static_cast<std::uint32_t>(y1)) << "\n";
|
||||
}
|
||||
18
examples/output_types/wildcard.cpp
Normal file
18
examples/output_types/wildcard.cpp
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
#include <iostream>
|
||||
|
||||
#include "dpf.hpp"
|
||||
|
||||
int main(int argc, char * argv[])
|
||||
{
|
||||
using input_type = uint8_t;
|
||||
using output_type = dpf::wildcard_value<uint32_t>;
|
||||
using dpf_type = dpf::utils::dpf_type_t<dpf::prg::aes128, dpf::prg::aes128, input_type, output_type>;
|
||||
input_type x = 12;
|
||||
output_type y;
|
||||
auto [dpf0, dpf1] = dpf::make_dpf(x, y);
|
||||
|
||||
|
||||
std::array<input_type, 5> points{12, 34, 56, 78, 90};
|
||||
auto recipe0 = dpf::make_sequence_recipe(dpf0, std::begin(points), std::end(points));
|
||||
auto recipe1 = dpf::make_sequence_recipe(dpf1, std::begin(points), std::end(points));
|
||||
}
|
||||
11
examples/output_types/xor_wrapper.cpp
Normal file
11
examples/output_types/xor_wrapper.cpp
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
#include <iostream>
|
||||
#include "dpf.hpp"
|
||||
|
||||
int main()
|
||||
{
|
||||
using x32 = dpf::xor_wrapper<std::uint32_t>;
|
||||
auto [k0, k1] = dpf::make_dpf(std::uint8_t{4}, x32{0x11});
|
||||
auto y0 = dpf::eval_point(k0, std::uint8_t{4});
|
||||
auto y1 = dpf::eval_point(k1, std::uint8_t{4});
|
||||
std::cout << (static_cast<x32>(y0) + static_cast<x32>(y1)) << "\n";
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue