V0.7.0 Arroyo Toad
Added Factory to help the creation of EdgeDevices
This commit is contained in:
@@ -81,7 +81,7 @@ import MessageUtils
|
||||
|
||||
@Test func stressLoop1() async throws {
|
||||
|
||||
let devices: UInt128 = 600
|
||||
let devices: UInt128 = 500
|
||||
|
||||
let env = PhysicalEnvironment("Delta")
|
||||
let truth = PhysicalData(.Temperature, 22)
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
import Testing
|
||||
import RandomCpp
|
||||
import Foundation
|
||||
import Crypto
|
||||
|
||||
@testable import IoT_Simulator_Core
|
||||
|
||||
@Test func workingGeneratorTest() async throws {
|
||||
// Write your test here and use APIs like `#expect(...)` to check expected conditions.
|
||||
var a = GaussianRNG(10, 0.5)
|
||||
|
||||
for _ in 0...10 {
|
||||
print(a.generate())
|
||||
}
|
||||
}
|
||||
|
||||
@Test func pemDecoded() async throws {
|
||||
/*
|
||||
Even though here you would expect both texts to be equal,
|
||||
the openssl generated one (the raw string) is ANSI x9.62
|
||||
while ours (the one made with the library) is ASN.1
|
||||
|
||||
When inspected with openssl, both curves where identical,
|
||||
so no need to be worried
|
||||
*/
|
||||
let keyPath = "./Private/privateKey.pem"
|
||||
|
||||
let url = URL(filePath: keyPath)
|
||||
let pemString = try String(contentsOf: url, encoding: String.Encoding.utf8)
|
||||
|
||||
|
||||
let key = try pem2key(filePath: keyPath)
|
||||
print(pemString)
|
||||
print(key.pemRepresentation)
|
||||
}
|
||||
|
||||
@Test func sign() async throws {
|
||||
let keyPath = "./Private/privateKey.pem"
|
||||
let key = try pem2key(filePath: keyPath)
|
||||
|
||||
let obj = "[1, 2, 3] "
|
||||
|
||||
let signature = try sign(string: obj, key: key)
|
||||
print(signature)
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Test func verifySignature() async throws {
|
||||
let keyPath = "./Private/privateKey.pem"
|
||||
let key = try pem2key(filePath: keyPath)
|
||||
|
||||
let obj = "[1, 2, 3] "
|
||||
|
||||
let signature = try sign(string: obj, key: key)
|
||||
let puKey = key.publicKey
|
||||
|
||||
let _verify = try verifySignature(signature: signature, string: obj, key: puKey)
|
||||
print(_verify)
|
||||
assert(_verify)
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user