Posts

Post not yet marked as solved
1 Replies
1.3k Views
Hello,I am reading articles about the new library CryptoKit which sounds interesting but would like to implement a basic functionality and don't know what is the best path to follow.The idea is simple, using CryptoKit I would like to encrypt some text using a secret text only shared with receiver. For example I would like to make secure the text: "My encrypted message" using the secret: "$)WERWERsdff?55345"After the app encrypts the message I would get an encoded string to be passed to receiver (server). Then on server, using c# and given secret I could decrypt the message.The approach I can get is using following code:import CryptoKitfunc encrypt(_ data: Data, to theirEncryptionKey: Curve25519.KeyAgreement.PublicKey, signedBy ourSigningKey: Curve25519.Signing.PrivateKey) throws -> (ephmeralPublicKeyData: Data, ciphertext: Data, signature: Data) { // Create a salt for key derivation.let protocolSalt = secretKey.data(using: .utf8)!let ephemeralKey = Curve25519.KeyAgreement.PrivateKey()let ephemeralPublicKey = ephemeralKey.publicKey.rawRepresentationlet sharedSecret = try ephemeralKey.sharedSecretFromKeyAgreement(with: theirEncryptionKey)let symmetricKey = sharedSecret.hkdfDerivedSymmetricKey(using: SHA256.self,salt: protocolSalt,sharedInfo: ephemeralPublicKey +theirEncryptionKey.rawRepresentation +ourSigningKey.publicKey.rawRepresentation,outputByteCount: 32)let ciphertext = try ChaChaPoly.seal(data, using: symmetricKey).combinedlet signature = try ourSigningKey.signature(for: ciphertext + ephemeralPublicKey + theirEncryptionKey.rawRepresentation)return (ephemeralPublicKey, ciphertext, signature)}var secretKey = "abcdef0123456xyz"let message = "Hello, Here I want to Present CryptoKit Example.".data(using: .utf8)!let senderSigningKey = Curve25519.Signing.PrivateKey()let senderSigningPublicKey = senderSigningKey.publicKeylet receiverEncryptionKey = Curve25519.KeyAgreement.PrivateKey()let receiverEncryptionPublicKey = receiverEncryptionKey.publicKeylet sealedMessage = try! encrypt(message, to: receiverEncryptionPublicKey, signedBy: senderSigningKey)print(sealedMessage.ciphertext.base64EncodedString())But I get all time decrypt error on server, do you know a full compatible method so c# could process the encrypted text?
Posted Last updated
.
Post not yet marked as solved
1 Replies
1.2k Views
Hello,When I load a .dae model into my AR app if the object is moved far away (around a meter) then some of the model sufaces start to flicker and mix the color of layers behind. This annoying effect does not happen when the model is close to the camera but persists when you move the device from it.I have tried .writesToDepthBuffer, .readsFromDepthBuffer, .renderingOrder properties, SCNLevelOfDetail, etc to try to fix the thing but no luck. The best approach was with readsFromDepthBuffer which reduced flickering but some parts of the model dissapear when camera angle changes so it's not valid solution.Some 3D designers say that layers that are very close make this layer fighting but we tried with models with more gap between layers and problem persist. I belive this issue is a AR engine or SceneKit engine bug that does not processes well far objects.Any ideas about causes of this problem and possible solutions?Best regards
Posted Last updated
.