From eb383b8e1622c07da2d5d6599a8b0e17a0deee0f Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Sun, 19 Nov 2023 20:32:16 -0500 Subject: [PATCH] Update docs Thanks to Bing Shi --- gf2n.cpp | 8 ++++++++ gf2n.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/gf2n.cpp b/gf2n.cpp index 452e6982..8993baae 100644 --- a/gf2n.cpp +++ b/gf2n.cpp @@ -135,6 +135,9 @@ PolynomialMod2 PolynomialMod2::Monomial(size_t i) PolynomialMod2 PolynomialMod2::Trinomial(size_t t0, size_t t1, size_t t2) { + CRYPTOPP_ASSERT(t0 > t1); + CRYPTOPP_ASSERT(t1 > t2); + PolynomialMod2 r((word)0, t0+1); r.SetBit(t0); r.SetBit(t1); @@ -144,6 +147,11 @@ PolynomialMod2 PolynomialMod2::Trinomial(size_t t0, size_t t1, size_t t2) PolynomialMod2 PolynomialMod2::Pentanomial(size_t t0, size_t t1, size_t t2, size_t t3, size_t t4) { + CRYPTOPP_ASSERT(t0 > t1); + CRYPTOPP_ASSERT(t1 > t2); + CRYPTOPP_ASSERT(t2 > t3); + CRYPTOPP_ASSERT(t3 > t4); + PolynomialMod2 r((word)0, t0+1); r.SetBit(t0); r.SetBit(t1); diff --git a/gf2n.h b/gf2n.h index 4aef31ee..38e2a910 100644 --- a/gf2n.h +++ b/gf2n.h @@ -69,9 +69,11 @@ public: static PolynomialMod2 CRYPTOPP_API Monomial(size_t i); /// \brief Provides x^t0 + x^t1 + x^t2 /// \return x^t0 + x^t1 + x^t2 + /// \pre The coefficients should be provided in descending order. That is,
t0 > t1 > t2
.
 		static PolynomialMod2 CRYPTOPP_API Trinomial(size_t t0, size_t t1, size_t t2);
 		/// \brief Provides x^t0 + x^t1 + x^t2 + x^t3 + x^t4
 		/// \return x^t0 + x^t1 + x^t2 + x^t3 + x^t4
+		/// \pre The coefficients should be provided in descending order. That is, 
t0 > t1 > t2 > t3 > t4
.
 		static PolynomialMod2 CRYPTOPP_API Pentanomial(size_t t0, size_t t1, size_t t2, size_t t3, size_t t4);
 		/// \brief Provides x^(n-1) + ... + x + 1
 		/// \return x^(n-1) + ... + x + 1