Skip to content

Commit 772453b

Browse files
authored
version 5.1.2 (#11)
1 parent 0452634 commit 772453b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+574
-570
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
cmake_minimum_required( VERSION 3.14 )
1818

19-
project( scl VERSION 5.1.1 DESCRIPTION "Secure Computation Library" )
19+
project( scl VERSION 5.1.2 DESCRIPTION "Secure Computation Library" )
2020

2121
if(NOT CMAKE_BUILD_TYPE)
2222
set(CMAKE_BUILD_TYPE Release)

RELEASE.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
5.1.2: Style changes
2+
- Change naming style of private field members.
3+
14
5.1.1: Bug fixes and simplifications
25
- Simplifed the NextToRun logic because a greedy strategy too often results in
36
rollbacks.

include/scl/math/curves/secp256k1.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,17 @@ struct Secp256k1 {
4141
/**
4242
* @brief Name of the secp256k1 field.
4343
*/
44-
constexpr static const char* kName = "secp256k1_field";
44+
constexpr static const char* NAME = "secp256k1_field";
4545

4646
/**
4747
* @brief Byte size of a secp256k1 field element.
4848
*/
49-
constexpr static const std::size_t kByteSize = 4 * sizeof(mp_limb_t);
49+
constexpr static const std::size_t BYTE_SIZE = 4 * sizeof(mp_limb_t);
5050

5151
/**
5252
* @brief Bit size of a secp256k1 field element.
5353
*/
54-
constexpr static const std::size_t kBitSize = 8 * kByteSize;
54+
constexpr static const std::size_t BIT_SIZE = 8 * BYTE_SIZE;
5555
};
5656

5757
/**
@@ -66,17 +66,17 @@ struct Secp256k1 {
6666
/**
6767
* @brief Name of the field.
6868
*/
69-
constexpr static const char* kName = "secp256k1_order";
69+
constexpr static const char* NAME = "secp256k1_order";
7070

7171
/**
7272
* @brief Size of an element in bytes.
7373
*/
74-
constexpr static const std::size_t kByteSize = 4 * sizeof(mp_limb_t);
74+
constexpr static const std::size_t BYTE_SIZE = 4 * sizeof(mp_limb_t);
7575

7676
/**
7777
* @brief Size of an element in bits.
7878
*/
79-
constexpr static const std::size_t kBitSize = 8 * kByteSize;
79+
constexpr static const std::size_t BIT_SIZE = 8 * BYTE_SIZE;
8080
};
8181

8282
/**
@@ -87,7 +87,7 @@ struct Secp256k1 {
8787
/**
8888
* @brief Name of the secp256k1 curve.
8989
*/
90-
constexpr static const char* kName = "secp256k1";
90+
constexpr static const char* NAME = "secp256k1";
9191
};
9292

9393
} // namespace scl::math

include/scl/math/ec.h

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,15 @@ class EC {
6767
* @brief A string indicating which curve this is.
6868
*/
6969
constexpr static const char* Name() {
70-
return Curve::kName;
70+
return Curve::NAME;
7171
};
7272

7373
/**
7474
* @brief Get the generator of this curve.
7575
*/
7676
constexpr static EC Generator() {
7777
EC g;
78-
CurveSetGenerator<Curve>(g.mValue);
78+
CurveSetGenerator<Curve>(g.m_value);
7979
return g;
8080
};
8181

@@ -86,7 +86,7 @@ class EC {
8686
*/
8787
static EC Read(const unsigned char* src) {
8888
EC e;
89-
CurveFromBytes<Curve>(e.mValue, src);
89+
CurveFromBytes<Curve>(e.m_value, src);
9090
return e;
9191
};
9292

@@ -95,15 +95,15 @@ class EC {
9595
*/
9696
static EC FromAffine(const Field& x, const Field& y) {
9797
EC e;
98-
CurveSetAffine<Curve>(e.mValue, x, y);
98+
CurveSetAffine<Curve>(e.m_value, x, y);
9999
return e;
100100
};
101101

102102
/**
103103
* @brief Create a new point equal to the point at infinity.
104104
*/
105105
explicit constexpr EC() {
106-
CurveSetPointAtInfinity<Curve>(mValue);
106+
CurveSetPointAtInfinity<Curve>(m_value);
107107
};
108108

109109
/**
@@ -112,7 +112,7 @@ class EC {
112112
* @return this
113113
*/
114114
EC& operator+=(const EC& other) {
115-
CurveAdd<Curve>(mValue, other.mValue);
115+
CurveAdd<Curve>(m_value, other.m_value);
116116
return *this;
117117
};
118118

@@ -132,7 +132,7 @@ class EC {
132132
* @return this after doubling.
133133
*/
134134
EC& DoubleInPlace() {
135-
CurveDouble<Curve>(mValue);
135+
CurveDouble<Curve>(m_value);
136136
return *this;
137137
};
138138

@@ -151,7 +151,7 @@ class EC {
151151
* @return this.
152152
*/
153153
EC& operator-=(const EC& other) {
154-
CurveSubtract<Curve>(mValue, other.mValue);
154+
CurveSubtract<Curve>(m_value, other.m_value);
155155
return *this;
156156
};
157157

@@ -172,7 +172,7 @@ class EC {
172172
* @return this.
173173
*/
174174
EC& operator*=(const Number& scalar) {
175-
CurveScalarMultiply<Curve>(mValue, scalar);
175+
CurveScalarMultiply<Curve>(m_value, scalar);
176176
return *this;
177177
};
178178

@@ -182,7 +182,7 @@ class EC {
182182
* @return this.
183183
*/
184184
EC& operator*=(const Order& scalar) {
185-
CurveScalarMultiply<Curve>(mValue, scalar);
185+
CurveScalarMultiply<Curve>(m_value, scalar);
186186
return *this;
187187
};
188188

@@ -234,7 +234,7 @@ class EC {
234234
* @return this.
235235
*/
236236
EC& Negate() {
237-
CurveNegate<Curve>(mValue);
237+
CurveNegate<Curve>(m_value);
238238
return *this;
239239
}
240240

@@ -253,7 +253,7 @@ class EC {
253253
* @return true if the two points are equal and false otherwise.
254254
*/
255255
bool Equal(const EC& other) const {
256-
return CurveEqual<Curve>(mValue, other.mValue);
256+
return CurveEqual<Curve>(m_value, other.m_value);
257257
};
258258

259259
/**
@@ -275,22 +275,22 @@ class EC {
275275
* @return true if this point is equal to the point at inifity.
276276
*/
277277
bool PointAtInfinity() const {
278-
return CurveIsPointAtInfinity<Curve>(mValue);
278+
return CurveIsPointAtInfinity<Curve>(m_value);
279279
};
280280

281281
/**
282282
* @brief Return this point as a pair of affine coordinates.
283283
* @return this point as a pair of affine coordinates.
284284
*/
285285
std::array<Field, 2> ToAffine() const {
286-
return CurveToAffine<Curve>(mValue);
286+
return CurveToAffine<Curve>(m_value);
287287
};
288288

289289
/**
290290
* @brief Output this point as a string.
291291
*/
292292
std::string ToString() const {
293-
return CurveToString<Curve>(mValue);
293+
return CurveToString<Curve>(m_value);
294294
};
295295

296296
/**
@@ -307,11 +307,11 @@ class EC {
307307
* @param compress whether to compress the point
308308
*/
309309
void Write(unsigned char* dest, bool compress = true) const {
310-
CurveToBytes<Curve>(dest, mValue, compress);
310+
CurveToBytes<Curve>(dest, m_value, compress);
311311
};
312312

313313
private:
314-
typename Curve::ValueType mValue;
314+
typename Curve::ValueType m_value;
315315
};
316316

317317
/**

include/scl/math/ff.h

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,21 @@ class FF final : Ring<FF<Field>> {
4141
* @brief Size in bytes of a field element.
4242
*/
4343
constexpr static std::size_t ByteSize() {
44-
return Field::kByteSize;
44+
return Field::BYTE_SIZE;
4545
};
4646

4747
/**
4848
* @brief Actual bit size of an element.
4949
*/
5050
constexpr static std::size_t BitSize() {
51-
return Field::kBitSize;
51+
return Field::BIT_SIZE;
5252
};
5353

5454
/**
5555
* @brief A short string representation of this field.
5656
*/
5757
constexpr static const char* Name() {
58-
return Field::kName;
58+
return Field::NAME;
5959
};
6060

6161
/**
@@ -66,7 +66,7 @@ class FF final : Ring<FF<Field>> {
6666
*/
6767
static FF Read(const unsigned char* src) {
6868
FF e;
69-
FieldFromBytes<Field>(e.mValue, src);
69+
FieldFromBytes<Field>(e.m_value, src);
7070
return e;
7171
}
7272

@@ -89,7 +89,7 @@ class FF final : Ring<FF<Field>> {
8989
*/
9090
static FF FromString(const std::string& str) {
9191
FF e;
92-
FieldFromString<Field>(e.mValue, str);
92+
FieldFromString<Field>(e.m_value, str);
9393
return e;
9494
};
9595

@@ -115,7 +115,7 @@ class FF final : Ring<FF<Field>> {
115115
* @see scl::FieldConvertIn
116116
*/
117117
explicit constexpr FF(int value) {
118-
FieldConvertIn<Field>(mValue, value);
118+
FieldConvertIn<Field>(m_value, value);
119119
};
120120

121121
/**
@@ -130,7 +130,7 @@ class FF final : Ring<FF<Field>> {
130130
* @see scl::FieldAdd
131131
*/
132132
FF& operator+=(const FF& other) {
133-
FieldAdd<Field>(mValue, other.mValue);
133+
FieldAdd<Field>(m_value, other.m_value);
134134
return *this;
135135
};
136136

@@ -141,7 +141,7 @@ class FF final : Ring<FF<Field>> {
141141
* @see scl::FieldSubtract
142142
*/
143143
FF& operator-=(const FF& other) {
144-
FieldSubtract<Field>(mValue, other.mValue);
144+
FieldSubtract<Field>(m_value, other.m_value);
145145
return *this;
146146
};
147147

@@ -152,7 +152,7 @@ class FF final : Ring<FF<Field>> {
152152
* @see scl::FieldMultiply
153153
*/
154154
FF& operator*=(const FF& other) {
155-
FieldMultiply<Field>(mValue, other.mValue);
155+
FieldMultiply<Field>(m_value, other.m_value);
156156
return *this;
157157
};
158158

@@ -175,7 +175,7 @@ class FF final : Ring<FF<Field>> {
175175
* @see scl::FieldNegate
176176
*/
177177
FF& Negate() {
178-
FieldNegate<Field>(mValue);
178+
FieldNegate<Field>(m_value);
179179
return *this;
180180
};
181181

@@ -185,10 +185,10 @@ class FF final : Ring<FF<Field>> {
185185
* @see FF::Negate
186186
*/
187187
FF Negated() const {
188-
auto copy = mValue;
188+
auto copy = m_value;
189189
FF r;
190190
FieldNegate<Field>(copy);
191-
r.mValue = copy;
191+
r.m_value = copy;
192192
return r;
193193
};
194194

@@ -198,7 +198,7 @@ class FF final : Ring<FF<Field>> {
198198
* @see scl::FieldInvert
199199
*/
200200
FF& Invert() {
201-
FieldInvert<Field>(mValue);
201+
FieldInvert<Field>(m_value);
202202
return *this;
203203
};
204204

@@ -219,7 +219,7 @@ class FF final : Ring<FF<Field>> {
219219
* @see scl::FieldEqual
220220
*/
221221
bool Equal(const FF& other) const {
222-
return FieldEqual<Field>(mValue, other.mValue);
222+
return FieldEqual<Field>(m_value, other.m_value);
223223
};
224224

225225
/**
@@ -228,7 +228,7 @@ class FF final : Ring<FF<Field>> {
228228
* @see scl::FieldToString
229229
*/
230230
std::string ToString() const {
231-
return FieldToString<Field>(mValue);
231+
return FieldToString<Field>(m_value);
232232
};
233233

234234
/**
@@ -237,11 +237,11 @@ class FF final : Ring<FF<Field>> {
237237
* @see scl::FieldToBytes
238238
*/
239239
void Write(unsigned char* dest) const {
240-
FieldToBytes<Field>(dest, mValue);
240+
FieldToBytes<Field>(dest, m_value);
241241
};
242242

243243
private:
244-
typename Field::ValueType mValue;
244+
typename Field::ValueType m_value;
245245

246246
template <typename T>
247247
friend class FFAccess;

include/scl/math/fields/mersenne127.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,17 @@ struct Mersenne127 {
3434
/**
3535
* @brief The name of this field.
3636
*/
37-
constexpr static const char* kName = "Mersenne127";
37+
constexpr static const char* NAME = "Mersenne127";
3838

3939
/**
4040
* @brief The size of field elements of this field in bytes.
4141
*/
42-
constexpr static const std::size_t kByteSize = sizeof(ValueType);
42+
constexpr static const std::size_t BYTE_SIZE = sizeof(ValueType);
4343

4444
/**
4545
* @brief The size of field elements of this field in bits.
4646
*/
47-
constexpr static const std::size_t kBitSize = 127;
47+
constexpr static const std::size_t BIT_SIZE = 127;
4848
};
4949

5050
} // namespace scl::math

include/scl/math/fields/mersenne61.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,17 @@ struct Mersenne61 {
3535
/**
3636
* @brief The name of this field.
3737
*/
38-
constexpr static const char* kName = "Mersenne61";
38+
constexpr static const char* NAME = "Mersenne61";
3939

4040
/**
4141
* @brief The size of field elements of this field in bytes.
4242
*/
43-
constexpr static const std::size_t kByteSize = sizeof(ValueType);
43+
constexpr static const std::size_t BYTE_SIZE = sizeof(ValueType);
4444

4545
/**
4646
* @brief The size of field elements of this field in bits.
4747
*/
48-
constexpr static const std::size_t kBitSize = 61;
48+
constexpr static const std::size_t BIT_SIZE = 61;
4949
};
5050

5151
} // namespace scl::math

0 commit comments

Comments
 (0)