Skip to content

Commit

Permalink
First Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
chrizchow committed Jan 14, 2020
0 parents commit 1ae28cb
Show file tree
Hide file tree
Showing 36 changed files with 712 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/description.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .idea/project-template.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

124 changes: 124 additions & 0 deletions .idea/uiDesigner.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions JPBC-FAME.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="file://$MODULE_DIR$/lib" />
</CLASSES>
<JAVADOC />
<SOURCES />
<jarDirectory url="file://$MODULE_DIR$/lib" recursive="false" />
</library>
</orderEntry>
</component>
</module>
14 changes: 14 additions & 0 deletions a.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
type d
q 625852803282871856053922297323874661378036491717
n 625852803282871856053923088432465995634661283063
h 3
r 208617601094290618684641029477488665211553761021
a 581595782028432961150765424293919699975513269268
b 517921465817243828776542439081147840953753552322
k 6
nk 60094290356408407130984161127310078516360031868417968262992864809623507269833854678414046779817844853757026858774966331434198257512457993293271849043664655146443229029069463392046837830267994222789160047337432075266619082657640364986415435746294498140589844832666082434658532589211525696
hk 1380801711862212484403205699005242141541629761433899149236405232528956996854655261075303661691995273080620762287276051361446528504633283152278831183711301329765591450680250000592437612973269056
coeff0 472731500571015189154958232321864199355792223347
coeff1 352243926696145937581894994871017455453604730246
coeff2 289113341693870057212775990719504267185772707305
nqr 431211441436589568382088865288592347194866189652
Binary file added lib/bcprov-jdk16-1.46.jar
Binary file not shown.
Binary file added lib/jna-3.2.5.jar
Binary file not shown.
Binary file added lib/jpbc-api-2.0.0.jar
Binary file not shown.
Binary file added lib/jpbc-benchmark-2.0.0.jar
Binary file not shown.
Binary file added lib/jpbc-crypto-2.0.0.jar
Binary file not shown.
Binary file added lib/jpbc-mm-2.0.0.jar
Binary file not shown.
Binary file added lib/jpbc-pbc-2.0.0.jar
Binary file not shown.
Binary file added lib/jpbc-plaf-2.0.0.jar
Binary file not shown.
Binary file added lib/test/jpbc-test-2.0.0-tests.jar
Binary file not shown.
Binary file not shown.
Binary file added out/production/JPBC-FAME/hk/chriz/AESCoder.class
Binary file not shown.
Binary file added out/production/JPBC-FAME/hk/chriz/FAME.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added out/production/JPBC-FAME/hk/chriz/FAMEPubKey.class
Binary file not shown.
Binary file not shown.
Binary file added out/production/JPBC-FAME/hk/chriz/MSP.class
Binary file not shown.
Binary file added out/production/JPBC-FAME/hk/chriz/Main.class
Binary file not shown.
42 changes: 42 additions & 0 deletions src/hk/chriz/AESCoder.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package hk.chriz;

import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
import java.security.SecureRandom;

public class AESCoder {

private static byte[] getRawKey(byte[] seed) throws Exception {
KeyGenerator kgen = KeyGenerator.getInstance("AES");
SecureRandom sr = SecureRandom.getInstance("SHA1PRNG");
sr.setSeed(seed);
kgen.init(128, sr); // 192 and 256 bits may not be available
SecretKey skey = kgen.generateKey();
byte[] raw = skey.getEncoded();
return raw;
}

public static byte[] encrypt(byte[] seed, byte[] plaintext)
throws Exception {
byte[] raw = getRawKey(seed);
SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
cipher.init(Cipher.ENCRYPT_MODE, skeySpec);
byte[] encrypted = cipher.doFinal(plaintext);
return encrypted;
}

public static byte[] decrypt(byte[] seed, byte[] ciphertext)
throws Exception {
byte[] raw = getRawKey(seed);
SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
cipher.init(Cipher.DECRYPT_MODE, skeySpec);
byte[] decrypted = cipher.doFinal(ciphertext);

return decrypted;
}

}
Loading

0 comments on commit 1ae28cb

Please sign in to comment.