Skip to content

Commit

Permalink
ff/baby_bear.hpp: add missing methods to the extension field.
Browse files Browse the repository at this point in the history
  • Loading branch information
dot-asm committed Sep 12, 2024
1 parent 73bcf65 commit b2a94ff
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions ff/baby_bear.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,14 @@ class __align__(16) bb31_4_t {
__host__ __device__ __forceinline__ bb31_4_t(int d, int f, int g, int h)
{ c[0] = bb31_t{d}; c[1] = bb31_t{f}; c[2] = bb31_t{g}; c[3] = bb31_t{h}; }

static inline bb31_4_t csel(const bb31_4_t& a, const bb31_4_t& b, int sel_a)
{
bb31_4_t ret;
for (size_t i = 0; i < 4; i++)
ret[i] = bb31_t::csel(a[i], b[i], sel_a);
return ret;
}

// Polynomial multiplication/squaring modulo x^4 - BETA
inline bb31_4_t& sqr()
{
Expand Down Expand Up @@ -618,6 +626,10 @@ class __align__(16) bb31_4_t {
{ batch_inversion<N>(inout, inout); }
# endif

inline void zero()
{ u[0] = u[1] = u[2] = u[3] = 0; }
static inline const bb31_4_t one()
{ return bb31_4_t{1}; }
inline bool is_one() const
{ return c[0].is_one() & u[1]==0 & u[2]==0 & u[3]==0; }
inline bool is_zero() const
Expand Down

0 comments on commit b2a94ff

Please sign in to comment.