Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: bls public key validation #183

Draft
wants to merge 149 commits into
base: feat/mainsail
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
149 commits
Select commit Hold shift + click to select a range
18861ec
add java major versions
alfonsobries Jul 31, 2024
7ba8c2d
remove deprecated signer/verifier
alfonsobries Jul 31, 2024
a2556d8
add secp256k1 library for schnorr
alfonsobries Aug 1, 2024
ba35322
upgrade gradle
alfonsobries Aug 1, 2024
4421cec
add schnorr signature library
alfonsobries Aug 1, 2024
916b499
upgrade dependencies
alfonsobries Aug 2, 2024
a8a4764
update to java 22
alfonsobries Aug 2, 2024
759fe53
remove java 8 compatibility
alfonsobries Aug 2, 2024
531f002
Merge branch 'feat/upgrade-dependencies' of github.com:ArkEcosystem/j…
alfonsobries Aug 2, 2024
f698dbe
include secp api
alfonsobries Aug 2, 2024
093dad1
compatibility issues
alfonsobries Aug 2, 2024
6d25cbd
Merge branch 'feat/upgrade-dependencies' into feat/add-schnorr-signature
alfonsobries Aug 2, 2024
e680c03
influde foreign library
alfonsobries Aug 2, 2024
acc2f4d
add schnorr signature
alfonsobries Aug 2, 2024
d910160
generate keccak address
alfonsobries Aug 2, 2024
5c05d58
Update VoteBuilder.java
alfonsobries Aug 2, 2024
f504c03
remplace old address
alfonsobries Aug 2, 2024
8ed2e89
Merge branch 'feat/keccak-address-support' into feat/add-schnorr-sign…
alfonsobries Aug 2, 2024
cc97465
wip
alfonsobries Aug 2, 2024
4c1302c
transfer serialize test
alfonsobries Aug 2, 2024
997aca8
style: resolve style guide violations
alfonsobries Aug 2, 2024
281aae5
feat: keccak address support (#179)
alfonsobries Aug 5, 2024
f128191
Merge branch 'feat/mainsail' of github.com:ArkEcosystem/java-crypto i…
alfonsobries Aug 5, 2024
3185b77
Merge branch 'feat/add-schnorr-signature' of github.com:ArkEcosystem/…
alfonsobries Aug 5, 2024
b190ef7
Merge branch 'feat/mainsail' into feat/upgrade-dependencies
alfonsobries Aug 5, 2024
14d3324
Merge branch 'feat/upgrade-dependencies' of github.com:ArkEcosystem/j…
alfonsobries Aug 5, 2024
1c8fc0b
wip
alfonsobries Aug 5, 2024
29657fb
fix tests
alfonsobries Aug 5, 2024
07a6a5d
replace deprecated fixtures with new ones
alfonsobries Aug 5, 2024
a415380
use keccak addresses
alfonsobries Aug 5, 2024
2ec53a6
votes tests
alfonsobries Aug 5, 2024
649babf
vote builder tests & adjustments
alfonsobries Aug 5, 2024
91c5e14
remove deprecated
alfonsobries Aug 5, 2024
4418f28
style: resolve style guide violations
alfonsobries Aug 5, 2024
cb24eb9
wip
alfonsobries Aug 5, 2024
5fb2de6
deserialize multipayment
alfonsobries Aug 5, 2024
802171c
rename delegate to validator
alfonsobries Aug 5, 2024
6def586
validator registration tests
alfonsobries Aug 5, 2024
38050a1
adjust validator resignation tests
alfonsobries Aug 5, 2024
7bc19ee
Merge branch 'feat/add-schnorr-signature' of github.com:ArkEcosystem/…
alfonsobries Aug 5, 2024
59ed9f6
Update MultiSignatureRegistrationBuilderTest.java
alfonsobries Aug 5, 2024
6d1b968
Merge branch 'feat/mainsail' of github.com:ArkEcosystem/java-crypto i…
alfonsobries Aug 5, 2024
a7a3ece
style: resolve style guide violations
alfonsobries Aug 5, 2024
3c2ea6d
fixture sign verification adjustments
alfonsobries Aug 5, 2024
08e83a7
schnorr tests
alfonsobries Aug 5, 2024
7b6ec80
style: resolve style guide violations
alfonsobries Aug 5, 2024
78459f6
wip
alfonsobries Aug 5, 2024
772dc85
Update SchnorrVerifierTest.java
alfonsobries Aug 5, 2024
a7354b4
Merge branch 'feat/add-schnorr-signature' of github.com:ArkEcosystem/…
alfonsobries Aug 5, 2024
2bfd410
install libsecp256k1
alfonsobries Aug 5, 2024
333be43
add nix
alfonsobries Aug 5, 2024
c083f07
Update test.yml
alfonsobries Aug 5, 2024
39b825e
Update test.yml
alfonsobries Aug 5, 2024
249f8c7
Update test.yml
alfonsobries Aug 5, 2024
3c65e8c
test with java 22 only
alfonsobries Aug 5, 2024
d81bc09
add java 21
alfonsobries Aug 5, 2024
f0d60f6
Update test.yml
alfonsobries Aug 5, 2024
3f705ab
Update test.yml
alfonsobries Aug 5, 2024
58ca8d7
Update test.yml
alfonsobries Aug 5, 2024
6278a7a
Update test.yml
alfonsobries Aug 5, 2024
14a806b
Update test.yml
alfonsobries Aug 5, 2024
a5b3b78
java 21
alfonsobries Aug 5, 2024
9066761
Update test.yml
alfonsobries Aug 5, 2024
a9eb999
Update test.yml
alfonsobries Aug 5, 2024
49a33cb
cache dowload
alfonsobries Aug 5, 2024
b1ea6a4
add 21
alfonsobries Aug 5, 2024
1c405f5
test
alfonsobries Aug 5, 2024
fc9906a
Update test.yml
alfonsobries Aug 5, 2024
a281c33
Update test.yml
alfonsobries Aug 5, 2024
4398b7f
wip
alfonsobries Aug 5, 2024
58ed071
Update test.yml
alfonsobries Aug 5, 2024
829d1d2
add java 21
alfonsobries Aug 5, 2024
be561c3
add default 22 libs again
alfonsobries Aug 5, 2024
4c716e9
gradle java version issue
alfonsobries Aug 5, 2024
0a42b1e
worth a try
alfonsobries Aug 6, 2024
e9629c5
last try
alfonsobries Aug 6, 2024
e39b8bf
drop compatibility with old versions of java
alfonsobries Aug 6, 2024
32b047a
add username transactions wip
alfonsobries Aug 6, 2024
ad9191e
wip
alfonsobries Aug 6, 2024
b64d5d5
style: resolve style guide violations
alfonsobries Aug 6, 2024
7fc228c
add fixtures for usernames
alfonsobries Aug 6, 2024
d163a4b
cleanup
alfonsobries Aug 6, 2024
33bc748
remove multisign verification
alfonsobries Aug 6, 2024
a01eefb
wip
alfonsobries Aug 6, 2024
16c7878
wip
alfonsobries Aug 6, 2024
51262b5
add test for multisignature
alfonsobries Aug 6, 2024
27870b5
style: resolve style guide violations
alfonsobries Aug 6, 2024
b590d2a
basic public key validation
alfonsobries Aug 7, 2024
b78f6f3
add herumi java library
alfonsobries Aug 8, 2024
4061c50
style: resolve style guide violations
alfonsobries Aug 8, 2024
ed607e0
remove unnecessary libraries
alfonsobries Aug 8, 2024
88636de
wip
alfonsobries Aug 8, 2024
8c84ca8
Update test.yml
alfonsobries Aug 8, 2024
019a7db
wip
alfonsobries Aug 8, 2024
905b470
Update test.yml
alfonsobries Aug 8, 2024
18f56d6
wip
alfonsobries Aug 8, 2024
db33397
Update test.yml
alfonsobries Aug 8, 2024
e03b4d3
Update test.yml
alfonsobries Aug 8, 2024
2be712e
Update test.yml
alfonsobries Aug 8, 2024
ac0ad52
wip
alfonsobries Aug 8, 2024
9a9aa53
Update test.yml
alfonsobries Aug 8, 2024
90cc190
Update test.yml
alfonsobries Aug 8, 2024
1a21da0
Update test.yml
alfonsobries Aug 8, 2024
399d756
Update test.yml
alfonsobries Aug 8, 2024
6efe6ed
wip
alfonsobries Aug 8, 2024
4165642
wip
alfonsobries Aug 8, 2024
18506a2
wip
alfonsobries Aug 8, 2024
5a855e3
Update test.yml
alfonsobries Aug 8, 2024
d1489e4
Update test.yml
alfonsobries Aug 8, 2024
19d85f3
Update test.yml
alfonsobries Aug 8, 2024
4127630
Update test.yml
alfonsobries Aug 8, 2024
43450a9
alternative build
alfonsobries Aug 8, 2024
ee3584e
Update test.yml
alfonsobries Aug 8, 2024
e6840d5
Update test.yml
alfonsobries Aug 8, 2024
0b785e5
Update test.yml
alfonsobries Aug 8, 2024
827dc4a
Update test.yml
alfonsobries Aug 8, 2024
846aaaf
Update test.yml
alfonsobries Aug 8, 2024
f892938
Update test.yml
alfonsobries Aug 8, 2024
d785315
Update test.yml
alfonsobries Aug 8, 2024
33a9d3d
test
alfonsobries Aug 8, 2024
a611897
Update test.yml
alfonsobries Aug 8, 2024
d0b7725
Update test.yml
alfonsobries Aug 8, 2024
048ed79
fix path
alfonsobries Aug 8, 2024
1c084cc
Update test.yml
alfonsobries Aug 8, 2024
1ae959f
Update test.yml
alfonsobries Aug 8, 2024
e9cf1fc
wip
alfonsobries Aug 8, 2024
99c65db
Update test.yml
alfonsobries Aug 8, 2024
1788e98
Update test.yml
alfonsobries Aug 8, 2024
cba822c
Update test.yml
alfonsobries Aug 8, 2024
30a95ae
Update test.yml
alfonsobries Aug 8, 2024
a789606
Update test.yml
alfonsobries Aug 8, 2024
f0941a5
Update test.yml
alfonsobries Aug 8, 2024
4164da8
Update test.yml
alfonsobries Aug 8, 2024
972ab8e
wip
alfonsobries Aug 8, 2024
f3693ac
style: resolve style guide violations
alfonsobries Aug 8, 2024
fd0c1c6
Update test.yml
alfonsobries Aug 8, 2024
25b29ee
Merge branch 'feat/bls-public-key-validation' of github.com:ArkEcosys…
alfonsobries Aug 8, 2024
272b307
remove unsused classes
alfonsobries Aug 8, 2024
17629c6
Revert "remove unsused classes"
alfonsobries Aug 8, 2024
3838ca9
wip
alfonsobries Aug 8, 2024
7eeda67
cleanup
alfonsobries Aug 8, 2024
c789248
Update build.gradle
alfonsobries Aug 8, 2024
3b89def
Update build.gradle
alfonsobries Aug 8, 2024
e101fe6
Merge branch 'feat/mainsail' of github.com:ArkEcosystem/java-crypto i…
alfonsobries Aug 12, 2024
42400b0
merge conflicts
alfonsobries Aug 12, 2024
912dad4
style: resolve style guide violations
alfonsobries Aug 12, 2024
df7a391
Merge branch 'feat/add-username-transactions' of github.com:ArkEcosys…
alfonsobries Aug 12, 2024
3e8ed3e
Merge branch 'feat/multisignature-tests' of github.com:ArkEcosystem/j…
alfonsobries Aug 12, 2024
9bae22c
style: resolve style guide violations
alfonsobries Aug 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,31 @@ jobs:
- name: Merge Conflict finder
uses: olivernybroe/[email protected]

- name: Install & build herumi/mcl
run: |
git clone https://github.com/herumi/mcl
cd mcl
mkdir build
cd build
cmake ..
make

- name: Copy mcl library to /usr/local/lib
run: |
sudo cp $HOME/work/java-crypto/java-crypto/mcl/build/lib/libmcl.a /usr/local/lib/

- name: Build Java FFI
run: |
cd $HOME/work/java-crypto/java-crypto/mcl/ffi/java
mkdir build
cd build
cmake ..
cmake --build . --config Release

- name: Copy libmcljava.so to /usr/local/lib
run: |
sudo cp $HOME/work/java-crypto/java-crypto/mcl/ffi/java/build/libmcljava.so /usr/local/lib/

- name: Install Nix
uses: cachix/install-nix-action@v27

Expand All @@ -57,7 +82,7 @@ jobs:
NIX_PATH: $HOME/.nix-profile/bin

- name: Set LD_LIBRARY_PATH
run: echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/.nix-profile/lib" >> $GITHUB_ENV
run: echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib:$HOME/.nix-profile/lib" >> $GITHUB_ENV

- name: Use Java Version 22
uses: actions/setup-java@v2
Expand Down
1 change: 0 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ test {
useJUnitPlatform()
testLogging {
events 'PASSED', 'FAILED', 'SKIPPED'
showStandardStreams = true
}
}

Expand Down
Binary file added libmcljava.dylib
Binary file not shown.
66 changes: 66 additions & 0 deletions src/main/java/com/herumi/mcl/CipherText.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 4.0.2
*
* Do not make changes to this file unless you know what you are doing--modify
* the SWIG interface file instead.
* ----------------------------------------------------------------------------- */

package com.herumi.mcl;

public class CipherText {
private transient long swigCPtr;
protected transient boolean swigCMemOwn;

protected CipherText(long cPtr, boolean cMemoryOwn) {
swigCMemOwn = cMemoryOwn;
swigCPtr = cPtr;
}

protected static long getCPtr(CipherText obj) {
return (obj == null) ? 0 : obj.swigCPtr;
}

@SuppressWarnings("deprecation")
protected void finalize() {
delete();
}

public synchronized void delete() {
if (swigCPtr != 0) {
if (swigCMemOwn) {
swigCMemOwn = false;
ElgamalJNI.delete_CipherText(swigCPtr);
}
swigCPtr = 0;
}
}

public String toStr() {
return ElgamalJNI.CipherText_toStr(swigCPtr, this);
}

public String toString() {
return ElgamalJNI.CipherText_toString(swigCPtr, this);
}

public void fromStr(String str) {
ElgamalJNI.CipherText_fromStr(swigCPtr, this, str);
}

public void add(CipherText c) {
ElgamalJNI.CipherText_add(swigCPtr, this, CipherText.getCPtr(c), c);
}

public void mul(int m) {
ElgamalJNI.CipherText_mul__SWIG_0(swigCPtr, this, m);
}

public void mul(String str) {
ElgamalJNI.CipherText_mul__SWIG_1(swigCPtr, this, str);
}

public CipherText() {
this(ElgamalJNI.new_CipherText(), true);
}
}
37 changes: 37 additions & 0 deletions src/main/java/com/herumi/mcl/Elgamal.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 4.0.2
*
* Do not make changes to this file unless you know what you are doing--modify
* the SWIG interface file instead.
* ----------------------------------------------------------------------------- */

package com.herumi.mcl;

public class Elgamal {
public static SWIGTYPE_p_bool new_p_bool() {
long cPtr = ElgamalJNI.new_p_bool();
return (cPtr == 0) ? null : new SWIGTYPE_p_bool(cPtr, false);
}

public static SWIGTYPE_p_bool copy_p_bool(boolean value) {
long cPtr = ElgamalJNI.copy_p_bool(value);
return (cPtr == 0) ? null : new SWIGTYPE_p_bool(cPtr, false);
}

public static void delete_p_bool(SWIGTYPE_p_bool obj) {
ElgamalJNI.delete_p_bool(SWIGTYPE_p_bool.getCPtr(obj));
}

public static void p_bool_assign(SWIGTYPE_p_bool obj, boolean value) {
ElgamalJNI.p_bool_assign(SWIGTYPE_p_bool.getCPtr(obj), value);
}

public static boolean p_bool_value(SWIGTYPE_p_bool obj) {
return ElgamalJNI.p_bool_value(SWIGTYPE_p_bool.getCPtr(obj));
}

public static void SystemInit(String param) {
ElgamalJNI.SystemInit(param);
}
}
100 changes: 100 additions & 0 deletions src/main/java/com/herumi/mcl/ElgamalJNI.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 4.0.2
*
* Do not make changes to this file unless you know what you are doing--modify
* the SWIG interface file instead.
* ----------------------------------------------------------------------------- */

package com.herumi.mcl;

public class ElgamalJNI {
public static final native long new_p_bool();

public static final native long copy_p_bool(boolean jarg1);

public static final native void delete_p_bool(long jarg1);

public static final native void p_bool_assign(long jarg1, boolean jarg2);

public static final native boolean p_bool_value(long jarg1);

public static final native void SystemInit(String jarg1);

public static final native String CipherText_toStr(long jarg1, CipherText jarg1_);

public static final native String CipherText_toString(long jarg1, CipherText jarg1_);

public static final native void CipherText_fromStr(long jarg1, CipherText jarg1_, String jarg2);

public static final native void CipherText_add(
long jarg1, CipherText jarg1_, long jarg2, CipherText jarg2_);

public static final native void CipherText_mul__SWIG_0(
long jarg1, CipherText jarg1_, int jarg2);

public static final native void CipherText_mul__SWIG_1(
long jarg1, CipherText jarg1_, String jarg2);

public static final native long new_CipherText();

public static final native void delete_CipherText(long jarg1);

public static final native String PublicKey_toStr(long jarg1, PublicKey jarg1_);

public static final native String PublicKey_toString(long jarg1, PublicKey jarg1_);

public static final native void PublicKey_fromStr(long jarg1, PublicKey jarg1_, String jarg2);

public static final native void PublicKey_save(long jarg1, PublicKey jarg1_, String jarg2);

public static final native void PublicKey_load(long jarg1, PublicKey jarg1_, String jarg2);

public static final native void PublicKey_enc__SWIG_0(
long jarg1, PublicKey jarg1_, long jarg2, CipherText jarg2_, int jarg3);

public static final native void PublicKey_enc__SWIG_1(
long jarg1, PublicKey jarg1_, long jarg2, CipherText jarg2_, String jarg3);

public static final native void PublicKey_rerandomize(
long jarg1, PublicKey jarg1_, long jarg2, CipherText jarg2_);

public static final native void PublicKey_add__SWIG_0(
long jarg1, PublicKey jarg1_, long jarg2, CipherText jarg2_, int jarg3);

public static final native void PublicKey_add__SWIG_1(
long jarg1, PublicKey jarg1_, long jarg2, CipherText jarg2_, String jarg3);

public static final native long new_PublicKey();

public static final native void delete_PublicKey(long jarg1);

public static final native String PrivateKey_toStr(long jarg1, PrivateKey jarg1_);

public static final native String PrivateKey_toString(long jarg1, PrivateKey jarg1_);

public static final native void PrivateKey_fromStr(long jarg1, PrivateKey jarg1_, String jarg2);

public static final native void PrivateKey_save(long jarg1, PrivateKey jarg1_, String jarg2);

public static final native void PrivateKey_load(long jarg1, PrivateKey jarg1_, String jarg2);

public static final native void PrivateKey_init(long jarg1, PrivateKey jarg1_);

public static final native long PrivateKey_getPublicKey(long jarg1, PrivateKey jarg1_);

public static final native int PrivateKey_dec__SWIG_0(
long jarg1, PrivateKey jarg1_, long jarg2, CipherText jarg2_, long jarg3);

public static final native int PrivateKey_dec__SWIG_1(
long jarg1, PrivateKey jarg1_, long jarg2, CipherText jarg2_);

public static final native void PrivateKey_setCache(
long jarg1, PrivateKey jarg1_, int jarg2, int jarg3);

public static final native void PrivateKey_clearCache(long jarg1, PrivateKey jarg1_);

public static final native long new_PrivateKey();

public static final native void delete_PrivateKey(long jarg1);
}
106 changes: 106 additions & 0 deletions src/main/java/com/herumi/mcl/Fp.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 4.0.2
*
* Do not make changes to this file unless you know what you are doing--modify
* the SWIG interface file instead.
* ----------------------------------------------------------------------------- */

package com.herumi.mcl;

public class Fp {
private transient long swigCPtr;
protected transient boolean swigCMemOwn;

protected Fp(long cPtr, boolean cMemoryOwn) {
swigCMemOwn = cMemoryOwn;
swigCPtr = cPtr;
}

protected static long getCPtr(Fp obj) {
return (obj == null) ? 0 : obj.swigCPtr;
}

@SuppressWarnings("deprecation")
protected void finalize() {
delete();
}

public synchronized void delete() {
if (swigCPtr != 0) {
if (swigCMemOwn) {
swigCMemOwn = false;
MclJNI.delete_Fp(swigCPtr);
}
swigCPtr = 0;
}
}

public Fp() {
this(MclJNI.new_Fp__SWIG_0(), true);
}

public Fp(Fp rhs) {
this(MclJNI.new_Fp__SWIG_1(Fp.getCPtr(rhs), rhs), true);
}

public Fp(int x) {
this(MclJNI.new_Fp__SWIG_2(x), true);
}

public Fp(String str, int base) {
this(MclJNI.new_Fp__SWIG_3(str, base), true);
}

public Fp(String str) {
this(MclJNI.new_Fp__SWIG_4(str), true);
}

public boolean equals(Fp rhs) {
return MclJNI.Fp_equals(swigCPtr, this, Fp.getCPtr(rhs), rhs);
}

public boolean isZero() {
return MclJNI.Fp_isZero(swigCPtr, this);
}

public boolean isOne() {
return MclJNI.Fp_isOne(swigCPtr, this);
}

public void setStr(String str, int base) {
MclJNI.Fp_setStr__SWIG_0(swigCPtr, this, str, base);
}

public void setStr(String str) {
MclJNI.Fp_setStr__SWIG_1(swigCPtr, this, str);
}

public void setInt(int x) {
MclJNI.Fp_setInt(swigCPtr, this, x);
}

public void clear() {
MclJNI.Fp_clear(swigCPtr, this);
}

public void setByCSPRNG() {
MclJNI.Fp_setByCSPRNG(swigCPtr, this);
}

public String toString(int base) {
return MclJNI.Fp_toString__SWIG_0(swigCPtr, this, base);
}

public String toString() {
return MclJNI.Fp_toString__SWIG_1(swigCPtr, this);
}

public void deserialize(byte[] cbuf) {
MclJNI.Fp_deserialize(swigCPtr, this, cbuf);
}

public byte[] serialize() {
return MclJNI.Fp_serialize(swigCPtr, this);
}
}
Loading