refactored keys, unversal keys and ring
This commit is contained in:
1 parent
7eeb780bdb
commit
ede55650f4
16 files changed
+274
-241
No files matched your search
@@ -13,11 +13,11 @@ class KeysTest {
|
||||
@Test
|
||||
fun testSigningCreationAndMap() = runTest {
|
||||
initCrypto()
|
||||
val (stk,pbk) = Signing.pair()
|
||||
val (stk,pbk) = SigningSecretKey.generatePair()
|
||||
|
||||
val x = mapOf( stk to "STK!", pbk to "PBK!")
|
||||
assertEquals("STK!", x[stk])
|
||||
val s1 = Signing.SecretKey(stk.packed)
|
||||
val s1 = SigningSecretKey(stk.keyBytes)
|
||||
assertEquals(stk, s1)
|
||||
assertEquals("STK!", x[s1])
|
||||
assertEquals("PBK!", x[pbk])
|
||||
@@ -29,8 +29,8 @@ class KeysTest {
|
||||
|
||||
data1[0] = 0x01u
|
||||
assertFalse(s.isValid(data1))
|
||||
val p2 = Signing.pair()
|
||||
val p3 = Signing.pair()
|
||||
val p2 = SigningSecretKey.generatePair()
|
||||
val p3 = SigningSecretKey.generatePair()
|
||||
|
||||
val ms = SealedBox.create(data, s1) + p2.secretKey
|
||||
|
||||
@@ -49,8 +49,8 @@ class KeysTest {
|
||||
@Test
|
||||
fun testNonDeterministicSeals() = runTest {
|
||||
initCrypto()
|
||||
val data = "Welcome to the Miami, bitch!".encodeToUByteArray()
|
||||
val (sk,_) = Signing.pair()
|
||||
val data = "Welcome to the crazy new world!".encodeToUByteArray()
|
||||
val (sk,_) = SigningSecretKey.generatePair()
|
||||
val t = now()
|
||||
val s1 = Seal.create(sk, data, createdAt = t)
|
||||
val s2 = Seal.create(sk, data, createdAt = t)
|
||||
@@ -72,8 +72,8 @@ class KeysTest {
|
||||
@Test
|
||||
fun secretEncryptTest() = runTest {
|
||||
initCrypto()
|
||||
val key = SymmetricKey.random()
|
||||
val key1 = SymmetricKey.random()
|
||||
val key = SymmetricKey.new()
|
||||
val key1 = SymmetricKey.new()
|
||||
assertEquals("hello", key.decrypt(key.encrypt("hello".encodeToUByteArray())).decodeFromUByteArray())
|
||||
assertEquals("hello", key.decryptString(key.encrypt("hello")))
|
||||
assertEquals("hello", key.decryptObject(key.encryptObject("hello")))
|
||||
@@ -88,7 +88,7 @@ class KeysTest {
|
||||
@Test
|
||||
fun symmetricKeyTest() = runTest {
|
||||
initCrypto()
|
||||
val k1 = SymmetricKey.random()
|
||||
val k1 = SymmetricKey.new()
|
||||
val src = "Buena Vista".encodeToUByteArray()
|
||||
val nonce = k1.randomNonce()
|
||||
|
||||
@@ -176,9 +176,9 @@ class KeysTest {
|
||||
@Test
|
||||
fun testUniKeys() = runTest {
|
||||
initCrypto()
|
||||
val sy1 = SymmetricKey.random()
|
||||
val sy1 = SymmetricKey.new()
|
||||
val sy2 = SymmetricKey(sy1.keyBytes)
|
||||
val sy3 = SymmetricKey.random()
|
||||
val sy3 = SymmetricKey.new()
|
||||
|
||||
assertEquals(sy1, sy2)
|
||||
assertEquals(sy2, sy1)
|
||||
@@ -195,9 +195,9 @@ class KeysTest {
|
||||
assertEquals(usy2, usy1)
|
||||
assertFalse { usy1 == usy3 }
|
||||
|
||||
val sk1 = Asymmetric.randomSecretKey()
|
||||
val sk1 = Asymmetric.new()
|
||||
val sk2 = Asymmetric.SecretKey(sk1.keyBytes)
|
||||
val sk3 = Asymmetric.randomSecretKey()
|
||||
val sk3 = Asymmetric.new()
|
||||
|
||||
assertEquals(sk1, sk2)
|
||||
assertEquals(sk2, sk1)
|
||||
|
||||
Reference in new issue
Block a user