Last active
October 8, 2019 14:51
-
-
Save tsif/e6ec92c0f115cb0d23c1ce6ef022ce24 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let privateKey = Curve25519.Signing.PrivateKey() | |
let publicKey = privateKey.publicKey // publicize freely | |
let publicKeyData = publicKey.rawRepresentation | |
let signingPublicKey = try! Curve25519.Signing.PublicKey(rawRepresentation: publicKeyData) | |
// sign some data with your private key | |
let data = "All your base are belong to us".data(using: .utf8)! | |
let signature = try! privateKey.signature(for: data) | |
if signingPublicKey.isValidSignature(signature, for: data) { | |
print("The signature is valid.") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment