Annotate noexcept and constexpr with HEDLEY, and add interval containment, ChaCha, and the dyadic range tables.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Ryan Henry 2026-09-24 20:44:07 -06:00
parent 875f09fec1
commit 0d8a5a8131
97 changed files with 9212 additions and 1159 deletions

View file

@ -13,9 +13,11 @@
#include <atomic>
#include <cstring>
#include <stdexcept>
#include <type_traits>
#include "dpf/prg_aes.hpp"
#include "dpf/prg_chacha.hpp"
#include "dpf/prg_dummy.hpp"
#include "dpf/prg_lowmc.hpp"
#include "dpf/secret_share.hpp"
@ -63,23 +65,34 @@ auto expand_as_share(typename PRG::block_type seed,
template <typename AesKey>
template <typename T, std::size_t Party>
HEDLEY_NO_THROW
auto aes<AesKey>::expand(block_type seed, psnip_uint32_t pos) noexcept
{
return detail::expand_as_share<aes<AesKey>, T, Party>(seed, pos);
}
template <typename T, std::size_t Party>
HEDLEY_NO_THROW
auto dummy::expand(block_type seed, psnip_uint32_t pos) noexcept
{
return detail::expand_as_share<dummy, T, Party>(seed, pos);
}
template <typename T, std::size_t Party>
HEDLEY_NO_THROW
auto lowmc128::expand(block_type seed, psnip_uint32_t pos) noexcept
{
return detail::expand_as_share<lowmc128, T, Party>(seed, pos);
}
template <unsigned Rounds>
template <typename T, std::size_t Party>
HEDLEY_NO_THROW
auto chacha<Rounds>::expand(block_type seed, psnip_uint32_t pos) noexcept
{
return detail::expand_as_share<chacha<Rounds>, T, Party>(seed, pos);
}
template <typename PRG>
struct counter_wrapper final
{
@ -101,17 +114,22 @@ struct counter_wrapper final
return PRG::eval01(seed);
}
HEDLEY_NO_THROW
HEDLEY_ALWAYS_INLINE
static void eval(block_type seed, block_type * HEDLEY_RESTRICT output,
psnip_uint32_t count, psnip_uint32_t pos = 0) noexcept
psnip_uint32_t count, psnip_uint32_t pos = 0)
{
if (count > 1 &&
pos > static_cast<psnip_uint32_t>(~static_cast<psnip_uint32_t>(0)) - (count - 1u))
{
throw std::invalid_argument("prg lane index is out of range");
}
count_.fetch_add(count, std::memory_order::memory_order_relaxed);
PRG::eval(seed, output, count, pos);
}
HEDLEY_NO_THROW
HEDLEY_ALWAYS_INLINE
HEDLEY_NON_NULL(1, 2, 3)
static void eval01_x4(const block_type * HEDLEY_RESTRICT seeds,
block_type * HEDLEY_RESTRICT left,
block_type * HEDLEY_RESTRICT right) noexcept
@ -122,6 +140,7 @@ struct counter_wrapper final
HEDLEY_NO_THROW
HEDLEY_ALWAYS_INLINE
HEDLEY_NON_NULL(1, 2)
static void eval_x4(const block_type * HEDLEY_RESTRICT seeds,
block_type * HEDLEY_RESTRICT output, psnip_uint32_t pos = 0) noexcept
{
@ -131,6 +150,7 @@ struct counter_wrapper final
HEDLEY_NO_THROW
HEDLEY_ALWAYS_INLINE
HEDLEY_NON_NULL(1, 2)
static void eval_x8(const block_type * HEDLEY_RESTRICT seeds,
block_type * HEDLEY_RESTRICT output, psnip_uint32_t pos = 0) noexcept
{