Skip to content

Commit

Permalink
Update comments in group-math
Browse files Browse the repository at this point in the history
  • Loading branch information
myl7 committed Jan 2, 2024
1 parent 04a1cf2 commit 11f501f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 9 deletions.
8 changes: 6 additions & 2 deletions group-math/src/byte.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
//! Group of bytes which defines addition as XOR
//! Group of bytes
//!
//! - Associative operation: Xor
//! - Identity element: All zero
//! - Inverse element: `x` itself
use std::ops::{Add, AddAssign};

use crate::Group;
use utils::xor_inplace;

/// See [`crate::byte`]
/// See [`self`]
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ByteGroup<const LAMBDA: usize>(pub [u8; LAMBDA]);

Expand Down
8 changes: 6 additions & 2 deletions group-math/src/int.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
//! Group of a integer which defines addition as integer (wrapping) addition
//! Group of an integer which defines addition as integer (wrapping) addition
//!
//! - Associative operation: Integer wrapping addition, `$(a + b) \mod 2^N$`
//! - Identity element: 0
//! - Inverse element: `-x`
use std::mem::size_of;
use std::ops::{Add, AddAssign};
Expand All @@ -7,7 +11,7 @@ use crate::Group;

macro_rules! decl_int_group {
($t:ty, $t_impl:ident) => {
/// See [`crate::int`]
/// See [`self`]
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct $t_impl(pub $t);

Expand Down
12 changes: 8 additions & 4 deletions group-math/src/int_prime.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
//! Prime ring.
//! `MOD` is a prime number as the cardinality of the prime ring.
//! Some prime numbers that are the max ones less than or equal to `u*::MAX` is provided as `PRIME_MAX_LE_U*_MAX`.
//! Group of an integer which is a `$p$`-group.
//! `MOD` as the `$p$` is a prime number as the cardinality of the group.
//! Some prime numbers that are the max ones less than or equal to `u*::MAX` are provided as `PRIME_MAX_LE_U*_MAX`.
//!
//! - Associative operation: Integer addition modulo `MOD`, `$(a + b) \mod MOD$`
//! - Identity element: 0
//! - Inverse element: `-x`
use std::mem::size_of;
use std::ops::{Add, AddAssign};
Expand All @@ -9,7 +13,7 @@ use crate::Group;

macro_rules! decl_int_prime_group {
($t:ty, $t_impl:ident) => {
/// See [`crate::int_prime`]
/// See [`self`]
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct $t_impl<const MOD: $t>(
/// Always less than `MOD`
Expand Down
3 changes: 2 additions & 1 deletion group-math/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ pub mod int_prime;

/// Group (mathematics) that can be converted from a byte array
///
/// `Into<[u8; LAMBDA]>` is not used so not included, but implemented by [`byte`] and [`int`]
/// `Into<[u8; LAMBDA]>` is not used in any fss crate so not included.
/// But it is implemented by all groups in the submodules.
pub trait Group<const LAMBDA: usize>
where
Self: Add<Output = Self>
Expand Down

0 comments on commit 11f501f

Please sign in to comment.