projects
/
shamirs_secret_web_implementation.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
816693d
)
kleine Code-Minimierungen. Irgendwie kommen immernoch 10% falsche Werte raus...
author
Stephan Richter
<github@keawe.de>
Fri, 22 Sep 2017 02:24:05 +0000
(
04:24
+0200)
committer
Stephan Richter
<github@keawe.de>
Fri, 22 Sep 2017 02:24:05 +0000
(
04:24
+0200)
src/ShamirsSecret.java
patch
|
blob
|
history
diff --git
a/src/ShamirsSecret.java
b/src/ShamirsSecret.java
index 3873d30a0c710749c645683a6938068247f6a7b8..eeb23c8cb6330c18e0b2528590760b877b43dc6b 100644
(file)
--- a/
src/ShamirsSecret.java
+++ b/
src/ShamirsSecret.java
@@
-33,11
+33,11
@@
public class ShamirsSecret {
}
public Quotient times(Quotient q) throws InvalidParameterException{
}
public Quotient times(Quotient q) throws InvalidParameterException{
- return new Quotient(
this.divident * q.divident,this.
divisor * q.divisor);
+ return new Quotient(
divident * q.divident,
divisor * q.divisor);
}
}
- public Quotient times(int
m
) throws InvalidParameterException{
- return new Quotient(
this.divident * m,this.
divisor);
+ public Quotient times(int
f
) throws InvalidParameterException{
+ return new Quotient(
f*divident,
divisor);
}
@Override
}
@Override
@@
-59,7
+59,7
@@
public class ShamirsSecret {
}
public int mod(int q) throws InvalidParameterException {
}
public int mod(int q) throws InvalidParameterException {
- int inv =
0
;
+ int inv =
1
;
while ((divisor*inv)%q !=1)inv++; // search the inverse of the divisor
return (divident*inv)%q;
}
while ((divisor*inv)%q !=1)inv++; // search the inverse of the divisor
return (divident*inv)%q;
}
@@
-109,14
+109,13
@@
public class ShamirsSecret {
}
public static void main(String[] args) throws InvalidParameterException {
}
public static void main(String[] args) throws InvalidParameterException {
- int secret = rand.nextInt(25
6
);
+ int secret = rand.nextInt(25
5
);
System.out.println(secret);
System.out.println(secret);
- Vector<Share> shares = createSecrets(secret,
6
,3);
+ Vector<Share> shares = createSecrets(secret,
5
,3);
System.out.println(shares);
System.out.println(shares);
- shares.remove(1);
- shares.remove(2);
- shares.remove(3);
+ shares.remove(0);
+ shares.remove(0);
System.out.println(shares);
secret=reconstruct(shares);
System.out.println(shares);
secret=reconstruct(shares);