115 lines
2.9 KiB
Kotlin
115 lines
2.9 KiB
Kotlin
|
package fr.acinq.secp256k1
|
||
|
|
||
|
import kotlinx.serialization.json.*
|
||
|
|
||
|
import kotlin.test.*
|
||
|
|
||
|
class FrostTest: BaseTest() {
|
||
|
|
||
|
// Frost Share Generation
|
||
|
@Test
|
||
|
fun `frost share generation`() {
|
||
|
val tests = readData("frost/share_gen_vectors.json")
|
||
|
val pubkeys = tests.jsonObject["pubkeys"]!!.jsonArray.map { Hex.decode(it.jsonPrimitive.content) }
|
||
|
|
||
|
tests.jsonObject["valid_test_cases"]!!.jsonArray.forEach { validTestCases ->
|
||
|
val keyIndices = validTestCases.jsonObject["key_indices"]!!.jsonArray.map { it.jsonPrimitive.int }
|
||
|
|
||
|
val seed32 = ByteArray(32)
|
||
|
val nParticipants = keyIndices.size
|
||
|
val threshold = validTestCases.jsonObject["threshold"]!!.jsonPrimitive.int
|
||
|
val ids33 = keyIndices.map { pubkeys[it] }.toTypedArray()
|
||
|
|
||
|
val result = Secp256k1.frostSharesGen(
|
||
|
seed32,
|
||
|
threshold,
|
||
|
nParticipants,
|
||
|
ids33
|
||
|
)
|
||
|
|
||
|
val expected = validTestCases.jsonObject["expected"]!!;
|
||
|
|
||
|
val expectedShare = expected.jsonObject["frost_share"]!!.jsonArray.map { Hex.decode(it.jsonPrimitive.content) }
|
||
|
val expectedVSSCommitment = expected.jsonObject["vss_commitment"]!!.jsonArray.map { Hex.decode(it.jsonPrimitive.content) }
|
||
|
val expectedPoK64 = Hex.decode(expected.jsonObject["pok64"]!!.jsonPrimitive.content)
|
||
|
|
||
|
result.first.forEachIndexed { index, share ->
|
||
|
assertEquals(
|
||
|
expected = Hex.encode(expectedShare[index]),
|
||
|
actual = Hex.encode(share),
|
||
|
"Unexpected $index:share for $keyIndices test case"
|
||
|
)
|
||
|
}
|
||
|
result.second.forEachIndexed { index, vssCommitment ->
|
||
|
assertEquals(
|
||
|
expected = Hex.encode(expectedVSSCommitment[index]),
|
||
|
actual = Hex.encode(vssCommitment),
|
||
|
"Unexpected $index:vss_commitment for the $keyIndices test case"
|
||
|
)
|
||
|
}
|
||
|
assertEquals(
|
||
|
expected = Hex.encode(expectedPoK64),
|
||
|
actual = Hex.encode(result.third),
|
||
|
message = "Unexpected pok64 for $keyIndices test case"
|
||
|
)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Test
|
||
|
fun `frost share aggregation`() {
|
||
|
|
||
|
}
|
||
|
|
||
|
@Test
|
||
|
fun `frost share verify`() {
|
||
|
|
||
|
}
|
||
|
|
||
|
@Test
|
||
|
fun `frost compute pubshare`() {
|
||
|
|
||
|
}
|
||
|
|
||
|
// Frost Tweak
|
||
|
|
||
|
@Test
|
||
|
fun `frost pubkey tweak`() {
|
||
|
|
||
|
}
|
||
|
|
||
|
@Test
|
||
|
fun `frost pubkey ec tweak add`() {
|
||
|
|
||
|
}
|
||
|
|
||
|
@Test
|
||
|
fun `frost pubkey xonly tweak add`() {
|
||
|
|
||
|
}
|
||
|
|
||
|
// Frost Sign functionality
|
||
|
@Test
|
||
|
fun `frost nonce gen`() {
|
||
|
|
||
|
}
|
||
|
|
||
|
@Test
|
||
|
fun `frost nonce process`() {
|
||
|
|
||
|
}
|
||
|
|
||
|
@Test
|
||
|
fun `frost partial sign `() {
|
||
|
|
||
|
}
|
||
|
|
||
|
@Test
|
||
|
fun `frost partial signature verify`() {
|
||
|
|
||
|
}
|
||
|
|
||
|
@Test
|
||
|
fun `frost partial signature aggregation`() {
|
||
|
|
||
|
}
|
||
|
}
|