Skip to content

Commit aae8a44

Browse files
committed
BitKeeper beta release
1 parent 305ebc7 commit aae8a44

File tree

102 files changed

+1196
-956
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+1196
-956
lines changed

build.gradle

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ repositories {
2020
}
2121

2222
dependencies {
23-
implementation("io.quarkus:quarkus-picocli")
24-
implementation 'org.jline:jline:3.29.0'
2523
implementation 'io.quarkiverse.loggingsentry:quarkus-logging-sentry:2.1.3'
2624
implementation enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}")
2725
implementation 'io.quarkus:quarkus-rest'
@@ -38,10 +36,13 @@ dependencies {
3836

3937
implementation 'com.fasterxml.jackson.module:jackson-module-kotlin:2.18.3'
4038

41-
implementation 'org.exploit.threshield:gg20:0.0.6'
42-
implementation 'org.exploit.threshield:frost:0.0.6'
43-
implementation 'org.exploit.threshield:ed25519:0.0.6'
44-
implementation 'org.exploit.threshield:core:0.0.6'
39+
implementation 'org.exploit.tss:gg20:0.0.1-patch1'
40+
implementation 'org.exploit.tss:frost:0.0.1-patch1'
41+
42+
implementation 'org.exploit.tss:ed25519:0.0.1-patch1'
43+
implementation 'org.exploit.tss:secp256k1:0.0.1-patch1'
44+
45+
implementation 'org.exploit.tss:core:0.0.1-patch1'
4546

4647
implementation 'com.nimbusds:nimbus-jose-jwt:10.2'
4748

@@ -76,6 +77,16 @@ allOpen {
7677
annotation("io.quarkus.test.junit.QuarkusTest")
7778
}
7879

80+
configurations.configureEach {
81+
resolutionStrategy {
82+
force(
83+
"net.java.dev.jna:jna:5.17.0",
84+
"net.java.dev.jna:jna-platform:5.17.0",
85+
"org.exploit:crypto:0.0.9-patch1",
86+
)
87+
}
88+
}
89+
7990
compileKotlin {
8091
kotlinOptions.jvmTarget = JavaVersion.VERSION_17
8192
kotlinOptions.javaParameters = true

src/main/kotlin/org/exploit/keeper/api/CentralApi.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ package org.exploit.keeper.api
33
import org.eclipse.jetty.http.HttpMethod
44
import org.exploit.jettyx.annotation.HttpRequest
55
import org.exploit.jettyx.model.HttpResponse
6+
import org.exploit.keeper.model.health.ShortStatus
67
import java.util.concurrent.CompletableFuture
78

89
interface CentralApi {
910
@HttpRequest(path = "/v1/keeper/ping", method = HttpMethod.GET)
10-
fun health(): CompletableFuture<HttpResponse<Void>>
11+
fun health(): CompletableFuture<HttpResponse<ShortStatus>>
1112
}

src/main/kotlin/org/exploit/keeper/api/FrostApi.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,34 @@ import org.eclipse.jetty.http.HttpMethod
44
import org.exploit.jettyx.annotation.Body
55
import org.exploit.jettyx.annotation.HttpRequest
66
import org.exploit.jettyx.annotation.Query
7+
import org.exploit.jettyx.model.HttpResponse
78
import org.exploit.keeper.model.common.InitSession
89
import org.exploit.keeper.model.frost.ComputedZ
910
import org.exploit.keeper.model.frost.FrostOperationCommitment
1011
import java.util.concurrent.CompletableFuture
1112

1213
interface FrostApi {
1314
@HttpRequest(method = HttpMethod.POST, path = "/v1/frost/init")
14-
fun init(@Body body: InitSession): CompletableFuture<Void>
15+
fun init(@Body body: InitSession): CompletableFuture<HttpResponse<Void>>
1516

1617
@HttpRequest(method = HttpMethod.POST, path = "/v1/frost/commitment")
1718
fun storeCommitment(
1819
@Query("sessionId") sessionId: String,
1920
@Body body: FrostOperationCommitment
20-
): CompletableFuture<Void>
21+
): CompletableFuture<HttpResponse<Void>>
2122

2223
@HttpRequest(method = HttpMethod.POST, path = "/v1/frost/commitment/broadcast")
2324
fun broadcast(
2425
@Query("sessionId") sessionId: String
25-
): CompletableFuture<Void>
26+
): CompletableFuture<HttpResponse<Void>>
2627

2728
@HttpRequest(method = HttpMethod.GET, path = "/v1/frost/signature/z")
2829
fun computeZ(
2930
@Query("sessionId") sessionId: String
30-
): CompletableFuture<ComputedZ>
31+
): CompletableFuture<HttpResponse<ComputedZ>>
3132

3233
@HttpRequest(method = HttpMethod.GET, path = "/v1/frost/abort")
3334
fun abort(
3435
@Query("sessionId") sessionId: String
35-
): CompletableFuture<Void>
36+
): CompletableFuture<HttpResponse<Void>>
3637
}
Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,67 @@
11
package org.exploit.keeper.api
22

33
import org.eclipse.jetty.http.HttpMethod
4+
import org.exploit.gmp.BigInt
45
import org.exploit.jettyx.annotation.Body
56
import org.exploit.jettyx.annotation.ContentType
67
import org.exploit.jettyx.annotation.HttpRequest
78
import org.exploit.jettyx.annotation.Query
9+
import org.exploit.jettyx.model.HttpResponse
810
import org.exploit.keeper.model.common.InitSession
911
import org.exploit.keeper.model.common.Value
1012
import org.exploit.keeper.model.gg20.commitment.GG20GammaCommitmentDto
1113
import org.exploit.keeper.model.gg20.commitment.GG20OfflinePhaseData
1214
import org.exploit.keeper.model.gg20.mta.GG20MtAComputeRequest
1315
import org.exploit.keeper.model.gg20.mta.GG20MtAResult
14-
import java.math.BigInteger
1516
import java.util.concurrent.CompletableFuture
1617

1718
interface GG20Api {
1819
@ContentType("application/json")
1920
@HttpRequest(method = HttpMethod.POST, path = "/v1/gg20/init")
20-
fun init(@Body session: InitSession): CompletableFuture<Void>
21+
fun init(@Body session: InitSession): CompletableFuture<HttpResponse<Void>>
2122

2223
@ContentType("application/json")
2324
@HttpRequest(method = HttpMethod.POST, path = "/v1/gg20/commitment")
2425
fun storeCommitment(
2526
@Query("sessionId") sessionId: String,
2627
@Body body: GG20GammaCommitmentDto
27-
): CompletableFuture<Void>
28+
): CompletableFuture<HttpResponse<Void>>
2829

2930
@HttpRequest(method = HttpMethod.POST, path = "/v1/gg20/commitment/broadcast")
3031
fun broadcastCommitment(
3132
@Query("sessionId") sessionId: String
32-
): CompletableFuture<Void>
33+
): CompletableFuture<HttpResponse<Void>>
3334

3435
@HttpRequest(method = HttpMethod.POST, path = "/v1/gg20/mta/exchange")
3536
fun exchangeMta(
3637
@Query("sessionId") sessionId: String
37-
): CompletableFuture<Void>
38+
): CompletableFuture<HttpResponse<Void>>
3839

3940
@ContentType("application/json")
4041
@HttpRequest(method = HttpMethod.POST, path = "/v1/gg20/mta/compute")
4142
fun computeMta(
4243
@Body request: GG20MtAComputeRequest
43-
): CompletableFuture<GG20MtAResult>
44+
): CompletableFuture<HttpResponse<GG20MtAResult>>
4445

4546
@ContentType("application/json")
4647
@HttpRequest(method = HttpMethod.POST, path = "/v1/gg20/prephase")
4748
fun storeOfflinePhase(
4849
@Query("sessionId") sessionId: String,
4950
@Body data: GG20OfflinePhaseData
50-
): CompletableFuture<Void>
51+
): CompletableFuture<HttpResponse<Void>>
5152

5253
@HttpRequest(method = HttpMethod.POST, path = "/v1/gg20/prephase/broadcast")
5354
fun broadcastOfflinePhase(
5455
@Query("sessionId") sessionId: String
55-
): CompletableFuture<Void>
56+
): CompletableFuture<HttpResponse<Void>>
5657

5758
@HttpRequest(method = HttpMethod.GET, path = "/v1/gg20/signature/s")
5859
fun computeS(
5960
@Query("sessionId") sessionId: String
60-
): CompletableFuture<Value<BigInteger>>
61+
): CompletableFuture<HttpResponse<Value<BigInt>>>
6162

6263
@HttpRequest(method = HttpMethod.POST, path = "/v1/gg20/abort")
6364
fun abort(
6465
@Query("sessionId") sessionId: String
65-
): CompletableFuture<Void>
66+
): CompletableFuture<HttpResponse<Void>>
6667
}

src/main/kotlin/org/exploit/keeper/api/KeyGenApi.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,24 @@ package org.exploit.keeper.api
33
import org.eclipse.jetty.http.HttpMethod
44
import org.exploit.jettyx.annotation.HttpRequest
55
import org.exploit.jettyx.annotation.Query
6+
import org.exploit.jettyx.model.HttpResponse
67
import org.exploit.keeper.constant.CurveName
78
import org.exploit.keeper.model.keygen.ShamirShareDto
89
import java.util.concurrent.CompletableFuture
910

1011
interface KeyGenApi {
1112
@HttpRequest(path = "/v1/keygen/init", method = HttpMethod.POST)
12-
fun init(@Query("keyId") keyId: String, @Query("curve") curve: CurveName, @Query("overwrite") overwrite: Boolean): CompletableFuture<Void>
13+
fun init(@Query("keyId") keyId: String, @Query("curve") curve: CurveName, @Query("overwrite") overwrite: Boolean): CompletableFuture<HttpResponse<Void>>
1314

1415
@HttpRequest(path = "/v1/keygen/share", method = HttpMethod.GET)
15-
fun share(@Query("keyId") keyId: String): CompletableFuture<ShamirShareDto>
16+
fun share(@Query("keyId") keyId: String): CompletableFuture<HttpResponse<ShamirShareDto>>
1617

1718
@HttpRequest(path = "/v1/keygen/collect", method = HttpMethod.POST)
18-
fun collect(@Query("keyId") keyId: String): CompletableFuture<Void>
19+
fun collect(@Query("keyId") keyId: String): CompletableFuture<HttpResponse<Void>>
1920

2021
@HttpRequest(path = "/v1/keygen/compute", method = HttpMethod.POST)
21-
fun compute(@Query("keyId") keyId: String): CompletableFuture<Void>
22+
fun compute(@Query("keyId") keyId: String): CompletableFuture<HttpResponse<Void>>
2223

2324
@HttpRequest(path = "/v1/keygen/abort", method = HttpMethod.POST)
24-
fun abort(@Query("keyId") keyId: String): CompletableFuture<Void>
25+
fun abort(@Query("keyId") keyId: String): CompletableFuture<HttpResponse<Void>>
2526
}

src/main/kotlin/org/exploit/keeper/api/PublicKeyApi.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ package org.exploit.keeper.api
33
import org.eclipse.jetty.http.HttpMethod
44
import org.exploit.jettyx.annotation.HttpRequest
55
import org.exploit.jettyx.annotation.Path
6+
import org.exploit.jettyx.model.HttpResponse
67
import org.exploit.keeper.model.PublicKeyDto
78
import java.util.concurrent.CompletableFuture
89

910
interface PublicKeyApi {
1011
@HttpRequest(method = HttpMethod.GET, path = "/v1/publicKey/{keyId}")
11-
fun getPublicKeyShare(@Path("keyId") keyId: String): CompletableFuture<PublicKeyDto>
12+
fun getPublicKeyShare(@Path("keyId") keyId: String): CompletableFuture<HttpResponse<PublicKeyDto>>
1213
}

src/main/kotlin/org/exploit/keeper/api/client/BitKeeperClient.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import org.exploit.keeper.api.*
88
import org.exploit.keeper.api.auth.KeeperAuthenticator
99
import org.exploit.keeper.extension.decodeBase64
1010
import org.exploit.keeper.extension.toSchnorrSignature
11-
import org.exploit.threshield.exception.IdentifiableAbortException
11+
import org.exploit.tss.exception.IdentifiableAbortException
1212

1313
class BitKeeperClient(val peerId: Int, private val publicKey: Ed25519PublicKey, auth: KeeperAuthenticator, url: String, jettyx: Jettyx) {
1414
val frost: FrostApi by lazy {

src/main/kotlin/org/exploit/keeper/component/BouncyCastleInit.kt

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/main/kotlin/org/exploit/keeper/component/JacksonCustomizer.kt

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
package org.exploit.keeper.component
22

3+
import com.fasterxml.jackson.core.JsonGenerator
4+
import com.fasterxml.jackson.core.JsonParser
5+
import com.fasterxml.jackson.core.JsonToken
36
import com.fasterxml.jackson.core.StreamReadConstraints
4-
import com.fasterxml.jackson.databind.ObjectMapper
7+
import com.fasterxml.jackson.databind.*
8+
import com.fasterxml.jackson.databind.module.SimpleModule
59
import com.fasterxml.jackson.module.kotlin.registerKotlinModule
610
import io.quarkus.jackson.ObjectMapperCustomizer
711
import jakarta.inject.Singleton
12+
import org.exploit.gmp.BigInt
13+
814

915
@Singleton
1016
class JacksonCustomizer: ObjectMapperCustomizer {
@@ -16,6 +22,65 @@ class JacksonCustomizer: ObjectMapperCustomizer {
1622
.build()
1723
)
1824

25+
objectMapper.registerModule(
26+
SimpleModule()
27+
.addSerializer(BigInt::class.java, BigIntHexSerializer())
28+
.addDeserializer(BigInt::class.java, BigIntHexDeserializer())
29+
)
30+
1931
objectMapper.registerKotlinModule()
2032
}
33+
34+
class BigIntHexSerializer : JsonSerializer<BigInt>() {
35+
override fun serialize(value: BigInt?, gen: JsonGenerator, serializers: SerializerProvider?) {
36+
if (value == null) {
37+
gen.writeNull()
38+
return
39+
}
40+
41+
var hex = value.toJavaInt().abs().toString(16)
42+
if (value.signum() < 0) {
43+
hex = "-$hex"
44+
}
45+
gen.writeString(hex)
46+
}
47+
48+
override fun handledType(): Class<BigInt> {
49+
return BigInt::class.java
50+
}
51+
}
52+
53+
class BigIntHexDeserializer : JsonDeserializer<BigInt>() {
54+
override fun deserialize(p: JsonParser, ctxt: DeserializationContext): BigInt? {
55+
if (p.currentToken() === JsonToken.VALUE_NULL) {
56+
return null
57+
}
58+
59+
var text: String
60+
if (p.currentToken().isNumeric) {
61+
text = p.numberValue.toString()
62+
return BigInt(text, 10)
63+
} else {
64+
text = p.valueAsString.trim()
65+
}
66+
67+
val negative = text.startsWith("-")
68+
if (negative) {
69+
text = text.substring(1)
70+
}
71+
if (text.startsWith("0x") || text.startsWith("0X")) {
72+
text = text.substring(2)
73+
}
74+
if (text.isEmpty()) {
75+
throw ctxt.weirdStringException(text, BigInt::class.java, "empty hexadecimal value")
76+
}
77+
78+
val result = BigInt(text, 16)
79+
return if (negative) result.negate() else result
80+
}
81+
82+
override fun handledType(): Class<*> {
83+
return BigInt::class.java
84+
}
85+
}
2186
}

0 commit comments

Comments
 (0)