Skip to content

Commit

Permalink
Use BF_VALUE
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastinas committed Feb 6, 2025
1 parent 72daa46 commit 7acd035
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions fields.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,16 +186,18 @@ ATTR_CONST ATTR_ALWAYS_INLINE static inline bf64_t bf64_from_bit(uint8_t bit) {
return bit & 1;
}

ATTR_PURE ATTR_ALWAYS_INLINE static inline bool bf128_eq(bf128_t a, bf128_t b) {
return memcmp(&a, &b, 16) == 0;
ATTR_ALWAYS_INLINE static inline bool bf128_eq(bf128_t a, bf128_t b) {
return BF_VALUE(a, 0) == BF_VALUE(b, 0) && BF_VALUE(a, 1) == BF_VALUE(b, 1);
}

ATTR_PURE ATTR_ALWAYS_INLINE static inline bool bf192_eq(bf192_t a, bf192_t b) {
return memcmp(&a, &b, 24) == 0;
ATTR_ALWAYS_INLINE static inline bool bf192_eq(bf192_t a, bf192_t b) {
return BF_VALUE(a, 0) == BF_VALUE(b, 0) && BF_VALUE(a, 1) == BF_VALUE(b, 1) &&
BF_VALUE(a, 2) == BF_VALUE(b, 2);
}

ATTR_PURE ATTR_ALWAYS_INLINE static inline bool bf256_eq(bf256_t a, bf256_t b) {
return memcmp(&a, &b, 32) == 0;
ATTR_ALWAYS_INLINE static inline bool bf256_eq(bf256_t a, bf256_t b) {
return BF_VALUE(a, 0) == BF_VALUE(b, 0) && BF_VALUE(a, 1) == BF_VALUE(b, 1) &&
BF_VALUE(a, 3) == BF_VALUE(b, 3);
}

// GF(2^128) implementation
Expand Down

0 comments on commit 7acd035

Please sign in to comment.