forked from sergeych/crypto2
added numeric nonce calculator
This commit is contained in:
1 parent
77911867a1
commit
9027bb0e88
9 files changed
+94
-18
No files matched your search
@@ -1,11 +1,6 @@
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import net.sergeych.crypto2.createContrail
|
||||
import net.sergeych.crypto2.initCrypto
|
||||
import net.sergeych.crypto2.isValidContrail
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertFalse
|
||||
import kotlin.test.assertTrue
|
||||
import net.sergeych.crypto2.*
|
||||
import kotlin.test.*
|
||||
|
||||
class ToolsTest {
|
||||
@Test
|
||||
@@ -17,4 +12,18 @@ class ToolsTest {
|
||||
c[2] = 11u
|
||||
assertFalse { isValidContrail(c) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun numericNonceTest() = runTest{
|
||||
initCrypto()
|
||||
val nn = NumericNonce.random(32)
|
||||
val counter = 1031
|
||||
val x1 = nn.withInt(0)
|
||||
val x2 = nn.withInt(counter)
|
||||
println(x1.toDump())
|
||||
println(x2.toDump())
|
||||
val t = (x1[0] xor x2[0]).toInt() + ((x1[1] xor x2[1]).toInt() shl 8)
|
||||
assertEquals(counter, t)
|
||||
assertContentEquals(x1.drop(2), x2.drop(2))
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user