Skip to content

Commit eab5cf1

Browse files
authored
Merge pull request #39 from str4d/37-javadoc-errors
Fix errors and warnings in JavaDocs Part of #37.
2 parents 5422eb9 + 24a9320 commit eab5cf1

14 files changed

+89
-33
lines changed

pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@
9898
<artifactId>maven-javadoc-plugin</artifactId>
9999
<version>2.9.1</version>
100100
<configuration>
101+
<charset>UTF-8</charset>
102+
<docencoding>UTF-8</docencoding>
103+
<encoding>UTF-8</encoding>
101104
<header>&lt;script type='text/x-mathjax-config'&gt;
102105
MathJax.Hub.Config({
103106
tex2jax: {
@@ -107,6 +110,8 @@
107110
});
108111
&lt;/script&gt;
109112
&lt;script type='text/javascript' src='https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'&gt;&lt;/script&gt;</header>
113+
<!-- Required for Java 8u121 or later. See https://github.com/neo4j/neo4j-java-driver/pull/318 -->
114+
<!--<additionalparam>&#45;&#45;allow-script-in-comments</additionalparam>-->
110115
</configuration>
111116
<executions>
112117
<execution>

src/net/i2p/crypto/eddsa/EdDSAEngine.java

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,8 @@ private boolean x_engineVerify(byte[] sigBytes) throws SignatureException {
318318
* sig = sign()
319319
*</pre>
320320
*
321+
* @param data the message to be signed
322+
* @return the signature
321323
* @throws SignatureException if update() already called
322324
* @see #ONE_SHOT_MODE
323325
*/
@@ -336,6 +338,10 @@ public byte[] signOneShot(byte[] data) throws SignatureException {
336338
* sig = sign()
337339
*</pre>
338340
*
341+
* @param data byte array containing the message to be signed
342+
* @param off the start of the message inside data
343+
* @param len the length of the message
344+
* @return the signature
339345
* @throws SignatureException if update() already called
340346
* @see #ONE_SHOT_MODE
341347
*/
@@ -356,6 +362,9 @@ public byte[] signOneShot(byte[] data, int off, int len) throws SignatureExcepti
356362
* ok = verify(signature)
357363
*</pre>
358364
*
365+
* @param data the message that was signed
366+
* @param signature of the message
367+
* @return true if the signature is valid, false otherwise
359368
* @throws SignatureException if update() already called
360369
* @see #ONE_SHOT_MODE
361370
*/
@@ -374,6 +383,11 @@ public boolean verifyOneShot(byte[] data, byte[] signature) throws SignatureExce
374383
* ok = verify(signature)
375384
*</pre>
376385
*
386+
* @param data byte array containing the message that was signed
387+
* @param off the start of the message inside data
388+
* @param len the length of the message
389+
* @param signature of the message
390+
* @return true if the signature is valid, false otherwise
377391
* @throws SignatureException if update() already called
378392
* @see #ONE_SHOT_MODE
379393
*/
@@ -392,6 +406,11 @@ public boolean verifyOneShot(byte[] data, int off, int len, byte[] signature) th
392406
* ok = verify(signature, sigoff, siglen)
393407
*</pre>
394408
*
409+
* @param data the message that was signed
410+
* @param signature byte array containing the signature
411+
* @param sigoff the start of the signature
412+
* @param siglen the length of the signature
413+
* @return true if the signature is valid, false otherwise
395414
* @throws SignatureException if update() already called
396415
* @see #ONE_SHOT_MODE
397416
*/
@@ -410,6 +429,13 @@ public boolean verifyOneShot(byte[] data, byte[] signature, int sigoff, int sigl
410429
* ok = verify(signature, sigoff, siglen)
411430
*</pre>
412431
*
432+
* @param data byte array containing the message that was signed
433+
* @param off the start of the message inside data
434+
* @param len the length of the message
435+
* @param signature byte array containing the signature
436+
* @param sigoff the start of the signature
437+
* @param siglen the length of the signature
438+
* @return true if the signature is valid, false otherwise
413439
* @throws SignatureException if update() already called
414440
* @see #ONE_SHOT_MODE
415441
*/
@@ -435,7 +461,7 @@ protected void engineSetParameter(AlgorithmParameterSpec spec) throws InvalidAlg
435461
}
436462

437463
/**
438-
* @deprecated replaced with <a href="#engineSetParameter(java.security.spec.AlgorithmParameterSpec)">
464+
* @deprecated
439465
*/
440466
@Override
441467
protected void engineSetParameter(String param, Object value) {

src/net/i2p/crypto/eddsa/EdDSAKey.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ public interface EdDSAKey {
2424
String KEY_ALGORITHM = "EdDSA";
2525

2626
/**
27-
* return a parameter specification representing the EdDSA domain
28-
* parameters for the key.
27+
* @return a parameter specification representing the EdDSA domain
28+
* parameters for the key.
2929
*/
3030
EdDSAParameterSpec getParams();
3131
}

src/net/i2p/crypto/eddsa/Utils.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
public class Utils {
2222
/**
2323
* Constant-time byte comparison.
24+
* @param b a byte
25+
* @param c a byte
2426
* @return 1 if b and c are equal, 0 otherwise.
2527
*/
2628
public static int equal(int b, int c) {
@@ -34,6 +36,8 @@ public static int equal(int b, int c) {
3436

3537
/**
3638
* Constant-time byte[] comparison.
39+
* @param b a byte[]
40+
* @param c a byte[]
3741
* @return 1 if b and c are equal, 0 otherwise.
3842
*/
3943
public static int equal(byte[] b, byte[] c) {

src/net/i2p/crypto/eddsa/math/Encoding.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public synchronized void setField(Field f) {
2828

2929
/**
3030
* Encode a FieldElement in its $(b-1)$-bit encoding.
31+
* @param x the FieldElement to encode
3132
* @return the $(b-1)$-bit encoding of this FieldElement.
3233
*/
3334
public abstract byte[] encode(FieldElement x);
@@ -46,6 +47,7 @@ public synchronized void setField(Field f) {
4647
* than the $(b-1)$-bit encoding of -x. If $q$ is an odd prime and the encoding
4748
* is the little-endian representation of $\{0, 1,\dots, q-1\}$ then the negative
4849
* elements of $F_q$ are $\{1, 3, 5,\dots, q-2\}$.
50+
* @param x the FieldElement to check
4951
* @return true if negative
5052
*/
5153
public abstract boolean isNegative(FieldElement x);

src/net/i2p/crypto/eddsa/math/GroupElement.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,13 @@ public class GroupElement implements Serializable {
3636

3737
/**
3838
* Available representations for a group element.
39-
* <p><ul>
39+
* <ul>
4040
* <li>P2: Projective representation $(X:Y:Z)$ satisfying $x=X/Z, y=Y/Z$.
4141
* <li>P3: Extended projective representation $(X:Y:Z:T)$ satisfying $x=X/Z, y=Y/Z, XY=ZT$.
4242
* <li>P1P1: Completed representation $((X:Z), (Y:T))$ satisfying $x=X/Z, y=Y/T$.
4343
* <li>PRECOMP: Precomputed representation $(y+x, y-x, 2dxy)$.
4444
* <li>CACHED: Cached representation $(Y+X, Y-X, Z, 2dT)$
45+
* </ul>
4546
*/
4647
public enum Representation {
4748
/** Projective ($P^2$): $(X:Y:Z)$ satisfying $x=X/Z, y=Y/Z$ */
@@ -223,12 +224,13 @@ public GroupElement(
223224
* <p>
224225
* A point $(x,y)$ is encoded by storing $y$ in bit 0 to bit 254 and the sign of $x$ in bit 255.
225226
* $x$ is recovered in the following way:
226-
* <p><ul>
227+
* </p><ul>
227228
* <li>$x = sign(x) * \sqrt{(y^2 - 1) / (d * y^2 + 1)} = sign(x) * \sqrt{u / v}$ with $u = y^2 - 1$ and $v = d * y^2 + 1$.
228229
* <li>Setting $β = (u * v^3) * (u * v^7)^{((q - 5) / 8)}$ one has $β^2 = \pm(u / v)$.
229230
* <li>If $v * β = -u$ multiply $β$ with $i=\sqrt{-1}$.
230231
* <li>Set $x := β$.
231232
* <li>If $sign(x) \ne$ bit 255 of $s$ then negate $x$.
233+
* </ul>
232234
*
233235
* @param curve The curve.
234236
* @param s The encoded point.
@@ -503,7 +505,7 @@ public synchronized void precompute(final boolean precomputeSingle) {
503505
* $r$ in $P \times P$ representation:
504506
* <p>
505507
* $r = ((X' : Z'), (Y' : T'))$ where
506-
* <p><ul>
508+
* </p><ul>
507509
* <li>$X' = (X + Y)^2 - (Y^2 + X^2)$
508510
* <li>$Y' = Y^2 + X^2$
509511
* <li>$Z' = y^2 - X^2$
@@ -512,7 +514,7 @@ public synchronized void precompute(final boolean precomputeSingle) {
512514
* $r$ converted from $P \times P$ to $P^2$ representation:
513515
* <p>
514516
* $r = (X'' : Y'' : Z'')$ where
515-
* <p><ul>
517+
* </p><ul>
516518
* <li>$X'' = X' * Z' = ((X + Y)^2 - Y^2 - X^2) * (2 * Z^2 - (y^2 - X^2))$
517519
* <li>$Y'' = Y' * T' = (Y^2 + X^2) * (2 * Z^2 - (y^2 - X^2))$
518520
* <li>$Z'' = Z' * T' = (y^2 - X^2) * (2 * Z^2 - (y^2 - X^2))$
@@ -645,14 +647,14 @@ private GroupElement msub(GroupElement q) {
645647
* $r = p + q$ where $p = this = (X1 : Y1 : Z1 : T1), q = (q.X, q.Y, q.Z, q.T) = (Y2 + X2, Y2 - X2, Z2, 2 * d * T2)$
646648
* <p>
647649
* $r$ in $P \times P$ representation:
648-
* <p><ul>
650+
* </p><ul>
649651
* <li>$X' = (Y1 + X1) * (Y2 + X2) - (Y1 - X1) * (Y2 - X2)$
650652
* <li>$Y' = (Y1 + X1) * (Y2 + X2) + (Y1 - X1) * (Y2 - X2)$
651653
* <li>$Z' = 2 * Z1 * Z2 + 2 * d * T1 * T2$
652654
* <li>$T' = 2 * Z1 * T2 - 2 * d * T1 * T2$
653655
* </ul><p>
654656
* Setting $A = (Y1 - X1) * (Y2 - X2), B = (Y1 + X1) * (Y2 + X2), C = 2 * d * T1 * T2, D = 2 * Z1 * Z2$ we get
655-
* <p><ul>
657+
* </p><ul>
656658
* <li>$X' = (B - A)$
657659
* <li>$Y' = (B + A)$
658660
* <li>$Z' = (D + C)$
@@ -864,7 +866,7 @@ GroupElement select(final int pos, final int b) {
864866
* Constant time.
865867
* <p>
866868
* Preconditions: (TODO: Check this applies here)
867-
* $a[31] <= 127$
869+
* $a[31] \le 127$
868870
* @param a $= a[0]+256*a[1]+\dots+256^{31} a[31]$
869871
* @return the GroupElement
870872
*/

src/net/i2p/crypto/eddsa/math/ScalarOps.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@ public interface ScalarOps {
1818
* From the Ed25519 paper:<br>
1919
* Here we interpret $2b$-bit strings in little-endian form as integers in
2020
* $\{0, 1,..., 2^{(2b)}-1\}$.
21-
* @param s
21+
* @param s the scalar to reduce
2222
* @return $s \bmod l$
2323
*/
2424
public byte[] reduce(byte[] s);
2525

2626
/**
2727
* $r = (a * b + c) \bmod l$
28-
* @param a
29-
* @param b
30-
* @param c
28+
* @param a a scalar
29+
* @param b a scalar
30+
* @param c a scalar
3131
* @return $(a*b + c) \bmod l$
3232
*/
3333
public byte[] multiplyAndAdd(byte[] a, byte[] b, byte[] c);

src/net/i2p/crypto/eddsa/math/bigint/BigIntegerLittleEndianEncoding.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public byte[] encode(FieldElement x) {
3939
* Convert $x$ to little endian.
4040
* Constant time.
4141
*
42+
* @param x the BigInteger value to encode
4243
* @return array of length $b/8$
4344
* @throws IllegalStateException if field not set
4445
*/
@@ -75,6 +76,9 @@ public FieldElement decode(byte[] in) {
7576

7677
/**
7778
* Convert in to big endian
79+
*
80+
* @param in the $(b-1)$-bit encoding of a FieldElement.
81+
* @return the decoded value as a BigInteger
7882
*/
7983
public BigInteger toBigInteger(byte[] in) {
8084
byte[] out = new byte[in.length];

src/net/i2p/crypto/eddsa/math/ed25519/Ed25519FieldElement.java

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,14 @@ public boolean isNonZero() {
6262
* TODO-CR BR: $h$ is allocated via new, probably not a good idea. Do we need the copying into temp variables if we do that?
6363
* <p>
6464
* Preconditions:
65-
* <p><ul>
65+
* </p><ul>
6666
* <li>$|f|$ bounded by $1.1*2^{25},1.1*2^{24},1.1*2^{25},1.1*2^{24},$ etc.
6767
* <li>$|g|$ bounded by $1.1*2^{25},1.1*2^{24},1.1*2^{25},1.1*2^{24},$ etc.
6868
* </ul><p>
6969
* Postconditions:
70-
* <p><ul>
70+
* </p><ul>
7171
* <li>$|h|$ bounded by $1.1*2^{26},1.1*2^{25},1.1*2^{26},1.1*2^{25},$ etc.
72+
* </ul>
7273
*
7374
* @param val The field element to add.
7475
* @return The field element this + val.
@@ -90,13 +91,14 @@ public FieldElement add(FieldElement val) {
9091
* TODO-CR BR: See above.
9192
* <p>
9293
* Preconditions:
93-
* <p><ul>
94+
* </p><ul>
9495
* <li>$|f|$ bounded by $1.1*2^{25},1.1*2^{24},1.1*2^{25},1.1*2^{24},$ etc.
9596
* <li>$|g|$ bounded by $1.1*2^{25},1.1*2^{24},1.1*2^{25},1.1*2^{24},$ etc.
9697
* </ul><p>
9798
* Postconditions:
98-
* <p><ul>
99+
* </p><ul>
99100
* <li>$|h|$ bounded by $1.1*2^{26},1.1*2^{25},1.1*2^{26},1.1*2^{25},$ etc.
101+
* </ul>
100102
*
101103
* @param val The field element to subtract.
102104
* @return The field element this - val.
@@ -116,12 +118,13 @@ public FieldElement subtract(FieldElement val) {
116118
* TODO-CR BR: see above.
117119
* <p>
118120
* Preconditions:
119-
* <p><ul>
121+
* </p><ul>
120122
* <li>$|f|$ bounded by $1.1*2^{25},1.1*2^{24},1.1*2^{25},1.1*2^{24},$ etc.
121123
* </ul><p>
122124
* Postconditions:
123-
* <p><ul>
125+
* </p><ul>
124126
* <li>$|h|$ bounded by $1.1*2^{25},1.1*2^{24},1.1*2^{25},1.1*2^{24},$ etc.
127+
* </ul>
125128
*
126129
* @return The field element (-1) * this.
127130
*/
@@ -139,14 +142,14 @@ public FieldElement negate() {
139142
* Can overlap $h$ with $f$ or $g$.
140143
* <p>
141144
* Preconditions:
142-
* <p><ul>
145+
* </p><ul>
143146
* <li>$|f|$ bounded by
144147
* $1.65*2^{26},1.65*2^{25},1.65*2^{26},1.65*2^{25},$ etc.
145148
* <li>$|g|$ bounded by
146149
* $1.65*2^{26},1.65*2^{25},1.65*2^{26},1.65*2^{25},$ etc.
147150
* </ul><p>
148151
* Postconditions:
149-
* <p><ul>
152+
* </p><ul>
150153
* <li>$|h|$ bounded by
151154
* $1.01*2^{25},1.01*2^{24},1.01*2^{25},1.01*2^{24},$ etc.
152155
* </ul><p>
@@ -390,11 +393,11 @@ public FieldElement multiply(FieldElement val) {
390393
* Can overlap $h$ with $f$.
391394
* <p>
392395
* Preconditions:
393-
* <p><ul>
396+
* </p><ul>
394397
* <li>$|f|$ bounded by $1.65*2^{26},1.65*2^{25},1.65*2^{26},1.65*2^{25},$ etc.
395398
* </ul><p>
396399
* Postconditions:
397-
* <p><ul>
400+
* </p><ul>
398401
* <li>$|h|$ bounded by $1.01*2^{25},1.01*2^{24},1.01*2^{25},1.01*2^{24},$ etc.
399402
* </ul><p>
400403
* See {@link #multiply(FieldElement)} for discussion
@@ -546,11 +549,11 @@ public FieldElement square() {
546549
* Can overlap $h$ with $f$.
547550
* <p>
548551
* Preconditions:
549-
* <p><ul>
552+
* </p><ul>
550553
* <li>$|f|$ bounded by $1.65*2^{26},1.65*2^{25},1.65*2^{26},1.65*2^{25},$ etc.
551554
* </ul><p>
552555
* Postconditions:
553-
* <p><ul>
556+
* </p><ul>
554557
* <li>$|h|$ bounded by $1.01*2^{25},1.01*2^{24},1.01*2^{25},1.01*2^{24},$ etc.
555558
* </ul><p>
556559
* See {@link #multiply(FieldElement)} for discussion

src/net/i2p/crypto/eddsa/math/ed25519/Ed25519LittleEndianEncoding.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ public class Ed25519LittleEndianEncoding extends Encoding {
2626
* <li>Convert the field element to the 32 byte representation.
2727
* </ol><p>
2828
* The idea for the modulo $p$ reduction algorithm is as follows:
29-
* <p>
29+
* </p>
3030
* <h2>Assumption:</h2>
31-
* <p><ul>
31+
* <ul>
3232
* <li>$p = 2^{255} - 19$
3333
* <li>$h = h_0 + 2^{25} * h_1 + 2^{(26+25)} * h_2 + \dots + 2^{230} * h_9$ where $0 \le |h_i| \lt 2^{27}$ for all $i=0,\dots,9$.
3434
* <li>$h \cong r \mod p$, i.e. $h = r + q * p$ for some suitable $0 \le r \lt p$ and an integer $q$.
3535
* </ul><p>
3636
* Then $q = [2^{-255} * (h + 19 * 2^{-25} * h_9 + 1/2)]$ where $[x] = floor(x)$.
37-
* <p>
37+
* </p>
3838
* <h2>Proof:</h2>
3939
* <p>
4040
* We begin with some very raw estimation for the bounds of some expressions:
@@ -242,8 +242,9 @@ public FieldElement decode(byte[] in) {
242242
* Return false if $x$ is in $\{0,2,4,\dots,q-1\}$
243243
* <p>
244244
* Preconditions:
245-
* <p><ul>
245+
* </p><ul>
246246
* <li>$|x|$ bounded by $1.1*2^{26},1.1*2^{25},1.1*2^{26},1.1*2^{25}$, etc.
247+
* </ul>
247248
*
248249
* @return true if $x$ is in $\{1,3,5,\dots,q-2\}$, false otherwise.
249250
*/

0 commit comments

Comments
 (0)