V0.7.0 Arroyo Toad

Added Factory to help the creation of EdgeDevices
This commit is contained in:
Christian Risi
2024-12-10 17:58:01 +01:00
parent 92875ecb12
commit 569b29c815
9 changed files with 106 additions and 176 deletions

View File

@@ -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)

View File

@@ -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)
}