Improves the name of the NIP01 Crypto object
This commit is contained in:
+3
-3
@@ -23,7 +23,7 @@ package com.vitorpamplona.quartz.benchmark
|
||||
import androidx.benchmark.junit4.BenchmarkRule
|
||||
import androidx.benchmark.junit4.measureRepeated
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import com.vitorpamplona.quartz.nip01Core.crypto.Nip01
|
||||
import com.vitorpamplona.quartz.nip01Core.crypto.Nip01Crypto
|
||||
import com.vitorpamplona.quartz.nip44Encryption.Nip44v2
|
||||
import com.vitorpamplona.quartz.nip44Encryption.crypto.ChaCha20
|
||||
import com.vitorpamplona.quartz.utils.RandomInstance
|
||||
@@ -39,8 +39,8 @@ class ChaCha20Benchmark {
|
||||
val nip44v2 = Nip44v2()
|
||||
val msg = "Hi, how are you? this is supposed to be representative of an average message on Nostr"
|
||||
|
||||
val privateKey = Nip01.privKeyCreate()
|
||||
val publicKey = Nip01.pubKeyCreate(privateKey)
|
||||
val privateKey = Nip01Crypto.privKeyCreate()
|
||||
val publicKey = Nip01Crypto.pubKeyCreate(privateKey)
|
||||
|
||||
val sharedKey = nip44v2.getConversationKey(privateKey, publicKey)
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ package com.vitorpamplona.quartz.benchmark
|
||||
import androidx.benchmark.junit4.BenchmarkRule
|
||||
import androidx.benchmark.junit4.measureRepeated
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import com.vitorpamplona.quartz.nip01Core.crypto.Nip01
|
||||
import com.vitorpamplona.quartz.nip01Core.crypto.Nip01Crypto
|
||||
import com.vitorpamplona.quartz.nip44Encryption.Nip44v2
|
||||
import com.vitorpamplona.quartz.nip44Encryption.crypto.Hkdf
|
||||
import org.junit.Rule
|
||||
@@ -38,8 +38,8 @@ class HkdfBenchmark {
|
||||
val nip44v2 = Nip44v2()
|
||||
val msg = "Hi, how are you? this is supposed to be representative of an average message on Nostr"
|
||||
|
||||
val privateKey = Nip01.privKeyCreate()
|
||||
val publicKey = Nip01.pubKeyCreate(privateKey)
|
||||
val privateKey = Nip01Crypto.privKeyCreate()
|
||||
val publicKey = Nip01Crypto.pubKeyCreate(privateKey)
|
||||
|
||||
val sharedKey = nip44v2.getConversationKey(privateKey, publicKey)
|
||||
val encrypted = nip44v2.encrypt(msg, sharedKey)
|
||||
|
||||
+3
-3
@@ -23,7 +23,7 @@ package com.vitorpamplona.quartz.benchmark
|
||||
import androidx.benchmark.junit4.BenchmarkRule
|
||||
import androidx.benchmark.junit4.measureRepeated
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import com.vitorpamplona.quartz.nip01Core.crypto.Nip01
|
||||
import com.vitorpamplona.quartz.nip01Core.crypto.Nip01Crypto
|
||||
import com.vitorpamplona.quartz.nip44Encryption.Nip44v2
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
@@ -37,8 +37,8 @@ class Nip44EncryptDecryptBenchmark {
|
||||
val nip44v2 = Nip44v2()
|
||||
val msg = "Hi, how are you? this is supposed to be representative of an average message on Nostr"
|
||||
|
||||
val privateKey = Nip01.privKeyCreate()
|
||||
val publicKey = Nip01.pubKeyCreate(privateKey)
|
||||
val privateKey = Nip01Crypto.privKeyCreate()
|
||||
val publicKey = Nip01Crypto.pubKeyCreate(privateKey)
|
||||
|
||||
val sharedKey = nip44v2.getConversationKey(privateKey, publicKey)
|
||||
val encrypted = nip44v2.encrypt(msg, sharedKey)
|
||||
|
||||
+4
-4
@@ -24,7 +24,7 @@ import androidx.benchmark.junit4.BenchmarkRule
|
||||
import androidx.benchmark.junit4.measureRepeated
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import com.vitorpamplona.quartz.nip01Core.crypto.KeyPair
|
||||
import com.vitorpamplona.quartz.nip01Core.crypto.Nip01
|
||||
import com.vitorpamplona.quartz.nip01Core.crypto.Nip01Crypto
|
||||
import com.vitorpamplona.quartz.utils.RandomInstance
|
||||
import com.vitorpamplona.quartz.utils.sha256.sha256
|
||||
import junit.framework.TestCase.assertNotNull
|
||||
@@ -42,17 +42,17 @@ class SignVerifyBenchmark {
|
||||
val keyPair = KeyPair()
|
||||
val msg = sha256(RandomInstance.bytes(1000))
|
||||
|
||||
benchmarkRule.measureRepeated { assertNotNull(Nip01.sign(msg, keyPair.privKey!!)) }
|
||||
benchmarkRule.measureRepeated { assertNotNull(Nip01Crypto.sign(msg, keyPair.privKey!!)) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun verify() {
|
||||
val keyPair = KeyPair()
|
||||
val msg = sha256(RandomInstance.bytes(1000))
|
||||
val signature = Nip01.sign(msg, keyPair.privKey!!)
|
||||
val signature = Nip01Crypto.sign(msg, keyPair.privKey!!)
|
||||
|
||||
benchmarkRule.measureRepeated {
|
||||
assertTrue(Nip01.verify(signature, msg, keyPair.pubKey))
|
||||
assertTrue(Nip01Crypto.verify(signature, msg, keyPair.pubKey))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user