File tree Expand file tree Collapse file tree 5 files changed +16
-38
lines changed
Expand file tree Collapse file tree 5 files changed +16
-38
lines changed Original file line number Diff line number Diff line change 1313 */
1414public class EdDSAPrivateKey implements EdDSAKey , PrivateKey {
1515 private static final long serialVersionUID = 23495873459878957L ;
16- private transient final byte [] seed ;
17- private transient final byte [] h ;
18- private transient final byte [] a ;
19- private transient final GroupElement A ;
20- private transient final byte [] Abyte ;
21- private transient final EdDSAParameterSpec edDsaSpec ;
16+ private final byte [] seed ;
17+ private final byte [] h ;
18+ private final byte [] a ;
19+ private final GroupElement A ;
20+ private final byte [] Abyte ;
21+ private final EdDSAParameterSpec edDsaSpec ;
2222
2323 public EdDSAPrivateKey (EdDSAPrivateKeySpec spec ) {
2424 this .seed = spec .getSeed ();
Original file line number Diff line number Diff line change 11package net .i2p .crypto .eddsa .math ;
22
3- public abstract class FieldElement {
3+ import java .io .Serializable ;
4+
5+ public abstract class FieldElement implements Serializable {
6+ private static final long serialVersionUID = 1239527465875676L ;
7+
48 protected final Field f ;
59
610 public FieldElement (Field f ) {
Original file line number Diff line number Diff line change @@ -720,7 +720,7 @@ public boolean equals(Object obj) {
720720 if (!this .repr .equals (ge .repr )) {
721721 try {
722722 ge = ge .toRep (this .repr );
723- } catch (Exception e ) {
723+ } catch (RuntimeException e ) {
724724 return false ;
725725 }
726726 }
Original file line number Diff line number Diff line change @@ -705,18 +705,11 @@ public FieldElement invert() {
705705 // 2 == 2 * 1
706706 t0 = square ();
707707
708- // TODO -CR BR: What is this? Is the author superstitious?
709- for (int i = 1 ; i < 1 ; ++i ) { // Don't remove this
710- t0 = t0 .square ();
711- }
712-
713708 // 4 == 2 * 2
714709 t1 = t0 .square ();
715710
716711 // 8 == 2 * 4
717- for (int i = 1 ; i < 2 ; ++i ) {
718- t1 = t1 .square ();
719- }
712+ t1 = t1 .square ();
720713
721714 // 9 == 8 + 1
722715 t1 = multiply (t1 );
@@ -727,11 +720,6 @@ public FieldElement invert() {
727720 // 22 == 2 * 11
728721 t2 = t0 .square ();
729722
730- // TODO -CR BR: see above
731- for (int i = 1 ; i < 1 ; ++i ) { // Don't remove this
732- t2 = t2 .square ();
733- }
734-
735723 // 31 == 22 + 9
736724 t1 = t1 .multiply (t2 );
737725
@@ -838,18 +826,11 @@ public FieldElement pow22523() {
838826 // 2 == 2 * 1
839827 t0 = square ();
840828
841- // TODO -CR BR: see invert
842- for (int i = 1 ; i < 1 ; ++i ) { // Don't remove this
843- t0 = t0 .square ();
844- }
845-
846829 // 4 == 2 * 2
847830 t1 = t0 .square ();
848831
849832 // 8 == 2 * 4
850- for (int i = 1 ; i < 2 ; ++i ) {
851- t1 = t1 .square ();
852- }
833+ t1 = t1 .square ();
853834
854835 // z9 = z1*z8
855836 t1 = multiply (t1 );
@@ -860,11 +841,6 @@ public FieldElement pow22523() {
860841 // 22 == 2 * 11
861842 t0 = t0 .square ();
862843
863- // TODO -CR BR: see above
864- for (int i = 1 ; i < 1 ; ++i ) { // Don't remove this
865- t0 = t0 .square ();
866- }
867-
868844 // 31 == 22 + 9
869845 t0 = t1 .multiply (t0 );
870846
@@ -949,9 +925,7 @@ public FieldElement pow22523() {
949925 t0 = t0 .square ();
950926
951927 // 2^252 - 2^2
952- for (int i = 1 ; i < 2 ; ++i ) {
953- t0 = t0 .square ();
954- }
928+ t0 = t0 .square ();
955929
956930 // 2^252 - 3
957931 return multiply (t0 );
Original file line number Diff line number Diff line change @@ -70,7 +70,7 @@ public byte[] encode(FieldElement x) {
7070
7171 // Step 1:
7272 // Calculate q
73- q = (19 * h9 + ((( int ) 1 ) << 24 )) >> 25 ;
73+ q = (19 * h9 + (1 << 24 )) >> 25 ;
7474 q = (h0 + q ) >> 26 ;
7575 q = (h1 + q ) >> 25 ;
7676 q = (h2 + q ) >> 26 ;
You can’t perform that action at this time.
0 commit comments