Full tests on native
This commit is contained in:
@@ -329,12 +329,12 @@ public interface Secp256k1 {
|
||||
|
||||
public const val FROST_PARTIAL_SIGNATURE_SIZE: Int = 36
|
||||
|
||||
public const val FROST_SHARE_SIZE: Int = 32
|
||||
public const val FROST_TWEAK_CACHE_SIZE: Int = 102
|
||||
public const val FROST_SESSION_SIZE: Int = 134
|
||||
public const val FROST_SECNONCE_SIZE: Int = 69
|
||||
public const val FROST_PUBNONCE_SIZE: Int = 133
|
||||
public const val FROST_SERIALIZED_PARTIAL_SIGNATURE_SIZE: Int = 33
|
||||
public const val FROST_SHARE_SIZE: Int = 36
|
||||
public const val FROST_TWEAK_CACHE_SIZE: Int = 101
|
||||
public const val FROST_SESSION_SIZE: Int = 133
|
||||
public const val FROST_SECNONCE_SIZE: Int = 68
|
||||
public const val FROST_PUBNONCE_SIZE: Int = 132
|
||||
public const val FROST_SERIALIZED_PARTIAL_SIGNATURE_SIZE: Int = 32
|
||||
public const val FROST_SERIALIZED_SHARE_SIZE: Int = 32
|
||||
public const val FROST_SERIALIZED_PUBNONCE_SIZE: Int = 66
|
||||
// @formatter:on
|
||||
|
||||
@@ -522,7 +522,7 @@ public object Secp256k1Native : Secp256k1 {
|
||||
}
|
||||
|
||||
private fun MemScope.serializeFrostShare(nFrostShare: secp256k1_frost_share): ByteArray {
|
||||
val natOutput = allocArray<UByteVar>(Secp256k1.FROST_SHARE_SIZE)
|
||||
val natOutput = allocArray<UByteVar>(Secp256k1.FROST_SERIALIZED_SHARE_SIZE)
|
||||
secp256k1_frost_share_serialize(ctx, natOutput, nFrostShare.ptr).requireSuccess("secp256k1_frost_share_serialize() failed")
|
||||
return natOutput.readBytes(Secp256k1.FROST_SERIALIZED_SHARE_SIZE)
|
||||
}
|
||||
@@ -589,10 +589,10 @@ public object Secp256k1Native : Secp256k1 {
|
||||
vssCommitment: Array<ByteArray>
|
||||
): Int {
|
||||
require(threshold > 1) { "threshold should be greater then 1" }
|
||||
require(id33.size == 33) { "id size should be 33" }
|
||||
require(share.size == Secp256k1.FROST_SHARE_SIZE) { "all shares should be of size 32" }
|
||||
require(id33.size == 33) { "id size (${id33.size}) should be 33" }
|
||||
require(share.size == Secp256k1.FROST_SERIALIZED_SHARE_SIZE) { "share size (${share.size}) should be of size ${Secp256k1.FROST_SERIALIZED_SHARE_SIZE}" }
|
||||
|
||||
require(vssCommitment.size == threshold) { "all vss commitment array size (${vssCommitment.size}) should be the same as the threshold size ($threshold)" }
|
||||
require(vssCommitment.size == threshold) { "vss commitment array size (${vssCommitment.size}) should be the same as the threshold size ($threshold)" }
|
||||
vssCommitment.forEach { publicKey ->
|
||||
require(publicKey.size == 33 || publicKey.size == 65) { "vss commitment data size should be 33 or 65" }
|
||||
}
|
||||
@@ -656,7 +656,7 @@ public object Secp256k1Native : Secp256k1 {
|
||||
}
|
||||
|
||||
override fun frostPublicKeyTweak(xOnlyPublicKey: ByteArray): ByteArray {
|
||||
require(xOnlyPublicKey.size == Secp256k1.X_ONLY_PUBKEY_SIZE)
|
||||
require(xOnlyPublicKey.size == Secp256k1.SERIALIZED_X_ONLY_PUBKEY_SIZE) { "pubkey size (${xOnlyPublicKey.size}) should be ${Secp256k1.SERIALIZED_X_ONLY_PUBKEY_SIZE}" }
|
||||
|
||||
memScoped {
|
||||
val nTweakCache = alloc<secp256k1_frost_tweak_cache>()
|
||||
@@ -738,18 +738,18 @@ public object Secp256k1Native : Secp256k1 {
|
||||
publicKey: ByteArray?,
|
||||
extraInput32: ByteArray?
|
||||
): Pair<ByteArray, ByteArray> {
|
||||
require(sessionId32.size == 32)
|
||||
require(sessionId32.size == 32) { "session id (${sessionId32.size}) size should be 32" }
|
||||
share?.let {
|
||||
require(share.size == Secp256k1.FROST_SHARE_SIZE)
|
||||
require(share.size == Secp256k1.FROST_SERIALIZED_SHARE_SIZE) { "share size (${share.size}) should be ${Secp256k1.FROST_SERIALIZED_SHARE_SIZE}" }
|
||||
}
|
||||
msg32?.let {
|
||||
require(msg32.size == 33)
|
||||
require(msg32.size == 32) { "msg32 (${sessionId32.size}) size should be 32" }
|
||||
}
|
||||
publicKey?.let {
|
||||
require(publicKey.size == 33 || publicKey.size == 65)
|
||||
require(publicKey.size == 32) { "public key (${publicKey.size}) should be 32" }
|
||||
}
|
||||
extraInput32?.let {
|
||||
require(it.size == 33)
|
||||
require(it.size == 32) { "extraInput32 (${extraInput32.size}) size should be 32" }
|
||||
}
|
||||
|
||||
memScoped {
|
||||
@@ -796,18 +796,18 @@ public object Secp256k1Native : Secp256k1 {
|
||||
adaptor: ByteArray?
|
||||
): ByteArray {
|
||||
publicNonces.forEach { publicNonce ->
|
||||
require(publicNonce.size == Secp256k1.FROST_PUBNONCE_SIZE)
|
||||
require(publicNonce.size == Secp256k1.FROST_SERIALIZED_PUBNONCE_SIZE) { "pubnonce size (${publicNonce.size}) size should be ${Secp256k1.FROST_SERIALIZED_PUBNONCE_SIZE}" }
|
||||
}
|
||||
require(msg32.size == 32)
|
||||
require(publicKey.size == 33 || publicKey.size == 65)
|
||||
require(msg32.size == 32) { "msg32 (${msg32.size}) size should be 32" }
|
||||
require(publicKey.size == Secp256k1.SERIALIZED_X_ONLY_PUBKEY_SIZE) { "publicKey size (${publicKey.size}) size should be ${Secp256k1.SERIALIZED_X_ONLY_PUBKEY_SIZE}" }
|
||||
ids33.forEach {
|
||||
require(it.size == 33)
|
||||
require(it.size == 33) { "id33 (${it.size}) size should be 33" }
|
||||
}
|
||||
tweakCache?.let {
|
||||
require(tweakCache.size == Secp256k1.FROST_TWEAK_CACHE_SIZE)
|
||||
require(tweakCache.size == Secp256k1.FROST_TWEAK_CACHE_SIZE) { "tweak cache size (${tweakCache.size}) size should be ${Secp256k1.FROST_TWEAK_CACHE_SIZE}" }
|
||||
}
|
||||
adaptor?.let {
|
||||
require(it.size == 33 || it.size == 65)
|
||||
require(it.size == 33 || it.size == 65) { "adaptor public key size (${it.size}) should be 33 or 65" }
|
||||
}
|
||||
|
||||
memScoped {
|
||||
@@ -861,11 +861,11 @@ public object Secp256k1Native : Secp256k1 {
|
||||
session: ByteArray,
|
||||
tweakCache: ByteArray?
|
||||
): ByteArray {
|
||||
require(secnonce.size == Secp256k1.FROST_SECNONCE_SIZE)
|
||||
require(share.size == Secp256k1.FROST_SHARE_SIZE)
|
||||
require(session.size == Secp256k1.FROST_SESSION_SIZE)
|
||||
require(secnonce.size == Secp256k1.FROST_SECNONCE_SIZE) { "secnonce size (${secnonce.size}) should be of size ${Secp256k1.FROST_SECNONCE_SIZE}" }
|
||||
require(share.size == Secp256k1.FROST_SERIALIZED_SHARE_SIZE) { "share size (${share.size}) should be of size ${Secp256k1.FROST_SERIALIZED_SHARE_SIZE}" }
|
||||
require(session.size == Secp256k1.FROST_SESSION_SIZE) { "session size (${share.size}) should be of size ${Secp256k1.FROST_SESSION_SIZE}" }
|
||||
tweakCache?.let {
|
||||
require(tweakCache.size == Secp256k1.FROST_TWEAK_CACHE_SIZE)
|
||||
require(tweakCache.size == Secp256k1.FROST_TWEAK_CACHE_SIZE) { "tweak cache size (${tweakCache.size}) size should be ${Secp256k1.FROST_TWEAK_CACHE_SIZE}" }
|
||||
}
|
||||
|
||||
|
||||
@@ -907,12 +907,12 @@ public object Secp256k1Native : Secp256k1 {
|
||||
session: ByteArray,
|
||||
tweakCache: ByteArray?
|
||||
): Int {
|
||||
require(partialSig.size == 32)
|
||||
require(publicNonce.size == Secp256k1.MUSIG2_PUBLIC_NONCE_SIZE)
|
||||
require(publicShare.size == 33 || publicShare.size == 65)
|
||||
require(session.size == Secp256k1.FROST_SESSION_SIZE)
|
||||
require(partialSig.size == 32) { "partialSig (${partialSig.size}) size should be 32" }
|
||||
require(publicNonce.size == Secp256k1.FROST_SERIALIZED_PUBNONCE_SIZE) { "public nonce (${publicNonce.size}) size should be ${Secp256k1.FROST_SERIALIZED_PUBNONCE_SIZE}" }
|
||||
require(publicShare.size == 33 || publicShare.size == 65) { "public share size (${partialSig.size}) should be 33 or 65" }
|
||||
require(session.size == Secp256k1.FROST_SESSION_SIZE) { "session size (${session.size}) size should be ${Secp256k1.FROST_SESSION_SIZE}" }
|
||||
tweakCache?.let {
|
||||
require(tweakCache.size == Secp256k1.FROST_TWEAK_CACHE_SIZE)
|
||||
require(tweakCache.size == Secp256k1.FROST_TWEAK_CACHE_SIZE) { "tweak cache size (${tweakCache.size}) size should be ${Secp256k1.FROST_TWEAK_CACHE_SIZE}" }
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user