Skip to content

Commit 37adf7d

Browse files
Squashed 'src/simplicity/' changes from 4858b89526..b549192109
b549192109 codespell: fix typos git-subtree-dir: src/simplicity git-subtree-split: b5491921095b28bc554c325a7d05274690483a6f
1 parent 9fc3797 commit 37adf7d

File tree

13 files changed

+37
-37
lines changed

13 files changed

+37
-37
lines changed

dag.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ void simplicity_computeAnnotatedMerkleRoot(analyses* analysis, const dag_node* d
367367
}
368368

369369
/* Verifies that the 'dag' is in canonical order, meaning that nodes under the left branches have lower indices than nodes under
370-
* right branches, with the exception that nodes under right braches may (cross-)reference identical nodes that already occur under
370+
* right branches, with the exception that nodes under right branches may (cross-)reference identical nodes that already occur under
371371
* left branches.
372372
*
373373
* Returns 'SIMPLICITY_NO_ERROR' if the 'dag' is in canonical order, and returns 'SIMPLICITY_ERR_DATA_OUT_OF_ORDER' if it is not.
@@ -389,7 +389,7 @@ simplicity_err simplicity_verifyCanonicalOrder(dag_node* dag, const uint_fast32_
389389
/* We use dag[i].aux as a "stack" to manage the traversal of the DAG. */
390390
dag[top].aux = len; /* We will set top to 'len' to indicate we are finished. */
391391

392-
/* Each time any particular 'top' value is revisted in this loop, bottom has increased to be strictly larger than the last 'child'
392+
/* Each time any particular 'top' value is revisited in this loop, bottom has increased to be strictly larger than the last 'child'
393393
value examined. Therefore we will make further progress in the loop the next time around.
394394
By this reasoning any given 'top' value will be visited no more than numChildren(dag[top].tag) + 1 <= 3 times.
395395
Thus this loop iterates at most O('len') times.

dag.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ void simplicity_computeCommitmentMerkleRoot(dag_node* dag, uint_fast32_t i);
350350
void simplicity_computeAnnotatedMerkleRoot(analyses* analysis, const dag_node* dag, const type* type_dag, uint_fast32_t len);
351351

352352
/* Verifies that the 'dag' is in canonical order, meaning that nodes under the left branches have lower indices than nodes under
353-
* right branches, with the exception that nodes under right braches may (cross-)reference identical nodes that already occur under
353+
* right branches, with the exception that nodes under right branches may (cross-)reference identical nodes that already occur under
354354
* left branches.
355355
*
356356
* Returns 'SIMPLICITY_NO_ERROR' if the 'dag' is in canonical order, and returns 'SIMPLICITY_ERR_DATA_OUT_OF_ORDER' if it is not.

jets-secp256k1.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ bool simplicity_hash_to_curve(frameItem* dst, frameItem src, const txEnv* env) {
714714
return true;
715715
}
716716

717-
/* THIS IS NOT A JET. It doesn't have the type signatue of a jet
717+
/* THIS IS NOT A JET. It doesn't have the type signature of a jet
718718
* This is a generic taptweak jet implementation parameterized by the tag used in the hash.
719719
* It is designed to be specialized to implement slightly different taptweak operations for Bitcoin and Elements.
720720
*

jets.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ RIGHT_EXTEND_(32,64)
591591

592592
#define LEFT_SHIFT_(log, bits) \
593593
static inline void left_shift_helper_##bits(bool with, frameItem* dst, frameItem *src) { \
594-
static_assert(log <= 8, "Only log parameter upto 8 is supported."); \
594+
static_assert(log <= 8, "Only log parameter up to 8 is supported."); \
595595
uint_fast8_t amt = simplicity_read##log(src); \
596596
uint_fast##bits##_t output = simplicity_read##bits(src); \
597597
if (with) output = UINT##bits##_MAX ^ output; \
@@ -625,7 +625,7 @@ LEFT_SHIFT_(8,64)
625625

626626
#define RIGHT_SHIFT_(log, bits) \
627627
static inline void right_shift_helper_##bits(bool with, frameItem* dst, frameItem *src) { \
628-
static_assert(log <= 8, "Only log parameter upto 8 is supported."); \
628+
static_assert(log <= 8, "Only log parameter up to 8 is supported."); \
629629
uint_fast8_t amt = simplicity_read##log(src); \
630630
uint_fast##bits##_t output = simplicity_read##bits(src); \
631631
if (with) output = UINT##bits##_MAX ^ output; \
@@ -1046,7 +1046,7 @@ DIVIDES_(64)
10461046
/* Implements the 3n/2n division algorithm for n=32 bits.
10471047
* For more details see "Fast Recursive Division" by Christoph Burnikel and Joachim Ziegler, MPI-I-98-1-022, Oct. 1998.
10481048
*
1049-
* Given a 96 bit (unsigned) value A and a 64 bit value B, set *q and *r to the quotent and remainder of A divided by B.
1049+
* Given a 96 bit (unsigned) value A and a 64 bit value B, set *q and *r to the quotient and remainder of A divided by B.
10501050
*
10511051
* ah is passed the high 64 bits of A, and al is passed the low 32 bits of A.
10521052
* We say that A = [ah;al] where [ah;al] denotes ah * 2^32 + al.
@@ -1067,7 +1067,7 @@ DIVIDES_(64)
10671067
*
10681068
* Preconditon 2 ensures that this estimate is close to the true value of Q. In fact Q <= estQ <= Q + 2 (see proof below)
10691069
*
1070-
* There is a corresponding estR value satifying the equation estR = A - estQ * B.
1070+
* There is a corresponding estR value satisfying the equation estR = A - estQ * B.
10711071
* This estR is one of {R, R - B, R - 2B}.
10721072
* Therefore if estR is non-negative, then estR is equal to the true R value, and hence estQ is equal to the true Q value.
10731073
*
@@ -1085,7 +1085,7 @@ DIVIDES_(64)
10851085
*
10861086
* Lemma 2: estQ < [1;2] (== 2^32 + 2).
10871087
* First note that ah - [bh;0] < [1;0] because
1088-
* ah < B (by precondtion 1)
1088+
* ah < B (by precondition 1)
10891089
* < [bh+1;0]
10901090
* == [bh;0] + [1;0]
10911091
*
@@ -1116,7 +1116,7 @@ static void div_mod_96_64(uint_fast32_t *q, uint_fast64_t *r,
11161116
/* B == b == [bh;bl] */
11171117
uint_fast64_t estQ = ah / bh;
11181118

1119-
/* Precondition 1 guarentees Q is 32-bits, if estQ is greater than UINT32_MAX, then reduce our initial estimated quotient to UINT32_MAX. */
1119+
/* Precondition 1 guarantees Q is 32-bits, if estQ is greater than UINT32_MAX, then reduce our initial estimated quotient to UINT32_MAX. */
11201120
*q = estQ <= UINT32_MAX ? (uint_fast32_t)estQ : UINT32_MAX;
11211121

11221122
/* *q * bh <= estQ * bh <= ah */
@@ -1131,7 +1131,7 @@ static void div_mod_96_64(uint_fast32_t *q, uint_fast64_t *r,
11311131
* This value is negative when [rh;al] < d.
11321132
* Note that d is 64 bit and thus if rh is greater than UINT32_MAX, then this value cannot be negative.
11331133
*/
1134-
/* This loop is exectued at most twice. */
1134+
/* This loop is executed at most twice. */
11351135
while (rh <= UINT32_MAX && 0x100000000u*rh + al < d) {
11361136
/* Our estimated remainder, A - *q * B is negative. */
11371137
/* 0 < d == *q * bl and hence 0 < *q, so this decrement does not underflow. */
@@ -1173,7 +1173,7 @@ bool simplicity_div_mod_128_64(frameItem* dst, frameItem src, const txEnv* env)
11731173
* RR
11741174
*
11751175
* First divide the high 3 "digit"s (96-bits) of A by the two "digit"s (64-bits) of B,
1176-
* returning the first "digit" (high 32-bits) of the quotient, and an intermediate remainer consisiting of 2 "digit"s (64-bits).
1176+
* returning the first "digit" (high 32-bits) of the quotient, and an intermediate remainder consisiting of 2 "digit"s (64-bits).
11771177
*/
11781178
div_mod_96_64(&qh, &r, ah, am, b);
11791179
simplicity_debug_assert(r < b);
@@ -1187,8 +1187,8 @@ bool simplicity_div_mod_128_64(frameItem* dst, frameItem src, const txEnv* env)
11871187
* ---
11881188
* RR
11891189
*
1190-
* Then append the last "digit" of A to the intermidiate remainder and divide that value (96_bits) by the two "digit"s (64-bits) of B,
1191-
* returning the second "digit" (low 32-bits) of the quotient, and the final remainer consisiting of 2 "digit"s (64-bits).
1190+
* Then append the last "digit" of A to the intermediate remainder and divide that value (96_bits) by the two "digit"s (64-bits) of B,
1191+
* returning the second "digit" (low 32-bits) of the quotient, and the final remainder consisiting of 2 "digit"s (64-bits).
11921192
*/
11931193
div_mod_96_64(&ql, &r, r, al, b);
11941194
simplicity_write32(dst, qh);

primitive/elements/env.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -260,11 +260,11 @@ static void copyOutput(sigOutput* result, opcode** allocation, size_t* allocatio
260260

261261
/* Tally a sorted list of feeOutputs
262262
*
263-
* Given a sorted array of feeOutput pointers, tally all the (explict) amounts of the entries with the same asset id,
263+
* Given a sorted array of feeOutput pointers, tally all the (explicit) amounts of the entries with the same asset id,
264264
* which are all necessarily next to each other, into the assetFee field of the first entry of the bunch.
265265
*
266266
* Discard all entries other than the first one of each bunch.
267-
* Return 'ret_value', the number of remaning entries in the array after these discards.
267+
* Return 'ret_value', the number of remaining entries in the array after these discards.
268268
*
269269
* Note: the array is not re-allocated, so there will be "junk" values in the array past the end of 'ret_value'.
270270
*
@@ -497,7 +497,7 @@ extern transaction* simplicity_elements_mallocTransaction(const rawTransaction*
497497
uint_fast32_t ix_fee = 0;
498498

499499
/* perm is a temporary array the same length (numFees) and size as feeOutputs.
500-
* perm is used to initalize feeOutputs and is not used afterward.
500+
* perm is used to initialize feeOutputs and is not used afterward.
501501
* This makes it safe for perm to use the same memory allocation as feeOutputs.
502502
*/
503503
static_assert(sizeof(const sha256_midstate*) == sizeof(sigOutput*), "Pointers (to structures) ought to have the same size.");
@@ -528,8 +528,8 @@ extern transaction* simplicity_elements_mallocTransaction(const rawTransaction*
528528
/* Initialize the feeOutputs array from the perm array.
529529
* Because the perm array entries are the same size as the feeOutputs array entries, it is safe to initialize one by one.
530530
*
531-
* In practical C implementations, the feeOutputs array entires are initalized to the same value as the perm array entries.
532-
* In practical C implementations, this is a no-op, and generally compiliers are able to see this fact and eliminate this loop.
531+
* In practical C implementations, the feeOutputs array entries are initialized to the same value as the perm array entries.
532+
* In practical C implementations, this is a no-op, and generally compilers are able to see this fact and eliminate this loop.
533533
*
534534
* We keep the loop in the code just to be pedantic.
535535
*/
@@ -652,7 +652,7 @@ extern void simplicity_elements_freeTapEnv(tapEnv* env) {
652652
simplicity_free(env);
653653
}
654654

655-
/* Contstruct a txEnv structure from its components.
655+
/* Construct a txEnv structure from its components.
656656
* This function will precompute any cached values.
657657
*
658658
* Precondition: NULL != tx

primitive/elements/primitive.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ typedef struct tapEnv {
248248
unsigned char leafVersion;
249249
} tapEnv;
250250

251-
/* The 'txEnv' structure used by the Elements application of Simplcity.
251+
/* The 'txEnv' structure used by the Elements application of Simplicity.
252252
*
253253
* It includes
254254
* + the transaction data, which may be shared when Simplicity expressions are used for multiple inputs in the same transaction),
@@ -263,7 +263,7 @@ typedef struct txEnv {
263263
uint_fast32_t ix;
264264
} txEnv;
265265

266-
/* Contstruct a txEnv structure from its components.
266+
/* Construct a txEnv structure from its components.
267267
* This function will precompute any cached values.
268268
*
269269
* Precondition: NULL != tx

rsort.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ static_assert(UCHAR_MAX < SIZE_MAX, "UCHAR_MAX >= SIZE_MAX");
1111
/* Return the 'i'th char of the object representation of the midstate pointed to by a.
1212
*
1313
* In C, values are represented as 'unsigned char [sizeof(v)]' array. However the exact
14-
* specification of how this represenation works is implementation defined.
14+
* specification of how this representation works is implementation defined.
1515
*
1616
* For the 'uint32_t' values of 'sha256_midstate', the object representation of these values will differ
17-
* between big endian and little endian archtectures.
17+
* between big endian and little endian architectures.
1818
*
1919
* Precondition: NULL != a
2020
* i < sizeof(a->s);
@@ -138,7 +138,7 @@ static void rsort_ex(const sha256_midstate** a, uint_fast32_t len, const sha256_
138138
We will decrease len as we go as we find out that items at the end of the array are in their proper, sorted position.
139139
140140
The 'i'th bucket is the subarray a[stack[i]:stack[i+1]),
141-
excecpt for the last bucket which is the subarray a[stack[totalBucketCount-1]:len).
141+
except for the last bucket which is the subarray a[stack[totalBucketCount-1]:len).
142142
143143
The depth to which various buckets are sorted increases the further down the stack you go.
144144
The 'bucketCount' stores how many buckets are sorted to various depths.
@@ -169,7 +169,7 @@ static void rsort_ex(const sha256_midstate** a, uint_fast32_t len, const sha256_
169169
Note: there is an added optimization where by if there is only one non-empty bucket found when attempting to sort,
170170
i.e. it happens that every bucket item already has identical 'depth' characters,
171171
we skip the subdivision and move onto the next depth immediately.
172-
(This is equivalent to pushing the one non-empty bucket onto the stack and immediately poping it back off.)
172+
(This is equivalent to pushing the one non-empty bucket onto the stack and immediately popping it back off.)
173173
174174
If the last bucket is of size 0 or 1, it must be already be sorted.
175175
Since this bucket is at the end of the array we decrease 'len'.

secp256k1/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,4 @@ Lastly, all active uses of normalize are replaced with the variable-time impleme
4949

5050
[^1]: More specifically, the when a point has a very low and odd order, the `ai` values in the `secp256k1_ecmult_odd_multiples_table` can reach infinity, violating libsecp256k1's assumption that `secp256k1_gej_add_ge_var`'s `a` parameter is never infinity.
5151
The value we set to the `rzr` in this case does not matter since it ends up only being multiplied with zero in `secp256k1_ge_table_set_globalz`.
52-
It just needs to be set to some value to avoid reading uninitalized memory.
52+
It just needs to be set to some value to avoid reading uninitialized memory.

secp256k1/scalar_impl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ static void secp256k1_scalar_split_lambda_verify(const secp256k1_scalar *r1, con
4444
#endif
4545

4646
/*
47-
* Both lambda and beta are primitive cube roots of unity. That is lamba^3 == 1 mod n and
47+
* Both lambda and beta are primitive cube roots of unity. That is lambda^3 == 1 mod n and
4848
* beta^3 == 1 mod p, where n is the curve order and p is the field order.
4949
*
5050
* Furthermore, because (X^3 - 1) = (X - 1)(X^2 + X + 1), the primitive cube roots of unity are
51-
* roots of X^2 + X + 1. Therefore lambda^2 + lamba == -1 mod n and beta^2 + beta == -1 mod p.
51+
* roots of X^2 + X + 1. Therefore lambda^2 + lambda == -1 mod n and beta^2 + beta == -1 mod p.
5252
* (The other primitive cube roots of unity are lambda^2 and beta^2 respectively.)
5353
*
5454
* Let l = -1/2 + i*sqrt(3)/2, the complex root of X^2 + X + 1. We can define a ring

secp256k1/util.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ static SECP256K1_INLINE int secp256k1_memcmp_var(const void *s1, const void *s2,
9696
# define SECP256K1_INT128_NATIVE 1
9797
#elif defined(USE_FORCE_WIDEMUL_INT64)
9898
/* If USE_FORCE_WIDEMUL_INT64 is set, use int64. */
99-
# error WIDEMUL_INT64 not suported in Simplicity.
99+
# error WIDEMUL_INT64 not supported in Simplicity.
100100
#elif defined(UINT128_MAX) || defined(__SIZEOF_INT128__)
101101
/* If a native 128-bit integer type exists, use int128. */
102102
# define SECP256K1_WIDEMUL_INT128 1

0 commit comments

Comments
 (0)