Skip to content

Commit b5ed948

Browse files
Merge pull request #8 from adwise-fiu/fix-api
2 parents 4353265 + a101654 commit b5ed948

File tree

3 files changed

+11
-18
lines changed

3 files changed

+11
-18
lines changed

.github/workflows/test_library.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
distribution: 'oracle'
2525
java-version: '17'
2626
cache: 'gradle'
27-
- run: sh gradlew test --continue
27+
- run: sh gradlew test
2828

2929
- name: Upload coverage reports to Codecov
3030
uses: codecov/codecov-action@v4

build.gradle

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,15 @@ java {
2222
}
2323

2424
dependencies {
25-
implementation 'junit:junit:4.13.2'
25+
// Only use full log4j API in testing, but in deployment use API for others to use the library
26+
// https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core
27+
testImplementation 'org.apache.logging.log4j:log4j-core:2.24.3'
28+
testImplementation 'junit:junit:4.13.2'
2629
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.11.0-M1'
27-
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.2'
30+
// https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-api
31+
implementation 'org.apache.logging.log4j:log4j-api:2.24.3'
2832
// https://mvnrepository.com/artifact/commons-io/commons-io
2933
implementation 'commons-io:commons-io:2.16.1'
30-
// or the latest version available
31-
implementation 'org.apache.logging.log4j:log4j-core:3.0.0-beta1'
32-
3334
implementation fileTree(dir: 'libs', include: ['*.jar'])
3435
}
3536

src/main/java/edu/fiu/adwise/homomorphic_encryption/misc/NTL.java

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -131,19 +131,11 @@ public static BigInteger quadratic_non_residue(BigInteger p, BigInteger q) {
131131
* @return The bit value (0 or 1) at position {@code k}, or 0 if {@code k} is out of range.
132132
*/
133133
public static int bit(BigInteger a, long k) {
134-
//If the value k (location of bit is bigger than a
135-
if (k >= a.bitLength()) {
134+
int len = a.bitLength();
135+
if (k < 0 || k >= len) {
136136
return 0;
137137
}
138-
if (k < 0) {
139-
return 0;
140-
}
141-
String bit = a.toString(2); // get it in Binary
142-
if (bit.charAt((int) k)== '0') {
143-
return 0;
144-
}
145-
else {
146-
return 1;
147-
}
138+
int bitIndex = len - 1 - (int) k;
139+
return a.abs().testBit(bitIndex) ? 1 : 0;
148140
}
149141
}

0 commit comments

Comments
 (0)