Classes

The following classes are available globally.

  • Represents an elliptic curve private key.
    Supported curves are:

    Usage Example:

    let pemKey = """
    -----BEGIN EC PRIVATE KEY-----
    MHcCAQEEIJX+87WJ7Gh19sohyZnhxZeXYNOcuGv4Q+8MLge4UkaZoAoGCCqGSM49
    AwEHoUQDQgAEikc5m6C2xtDWeeAeT18WElO37zvFOz8p4kAlhvgIHN23XIClNESg
    KVmLgSSq2asqiwdrU5YHbcHFkgdABM1SPA==
    -----END EC PRIVATE KEY-----
    """
    let privateKey = try ECPrivateKey(key: pemKey)
    let signature = "Hello world".sign(with: privateKey)
    
    See more

    Declaration

    Swift

    public class ECPrivateKey
  • Represents an elliptic curve public key. Supported curves are:

    Usage Example:

    let pemKey = """
    -----BEGIN PUBLIC KEY-----
    MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEikc5m6C2xtDWeeAeT18WElO37zvF
    Oz8p4kAlhvgIHN23XIClNESgKVmLgSSq2asqiwdrU5YHbcHFkgdABM1SPA==
    -----END PUBLIC KEY-----
    """
    let publicKey = try ECPublicKey(key: pemKey)
    
    let base64Sig = "MEYCIQCvgBLn+tQoBDBR3D2G3485GloYGNxuk6PqR4qjr5GDqAIhAKNvsqvesVBD/MLub/KAyzLLNGtUZyQDxYZj/4vmHwWF"
    let signature = try ECSignature(asn1: Data(base64Encoded: base64Sig)) 
    
    let verified = signature.verify(plaintext: "Hello world", using: publicKey)
    
    See more

    Declaration

    Swift

    public class ECPublicKey