CryptoApi
‘CryptoApi’ is a class representing Endpoint’s API for cryptographic operations. This class wraps the underlying C++ implementation for use in Swift.
Static Methods
create()
Creates instance of ‘CryptoApi’.
Returns
CryptoApi ·
CryptoApi object
Methods
signData(data:privateKey:)
Creates a signature of data using given key.
Params
data
privmx.endpoint.core.Buffer
buffer to sign
privateKey
std.string
key used to sign data
Returns
privmx.endpoint.core.Buffer ·
signature of data
verifySignature(data:signature:publicKey:)
Validate a signature of data using given key.
Params
data
privmx.endpoint.core.Buffer
buffer
signature
privmx.endpoint.core.Buffer
signature of data to verify
publicKey
std.string
public ECC key in BASE58DER format used to validate data
Returns
Bool ·
data validation result
generateKeySymmetric()
Generates a new symmetric key.
Returns
privmx.endpoint.core.Buffer ·
generated key
generatePrivateKey(randomSeed:)
Generates a new private ECC key.
Params
randomSeed
std.string?
optional string used as the base to generate the new key
Returns
std.string ·
generated ECC key in WIF format
derivePrivateKey(password:salt:)
Generates a new private ECC key from a password using pbkdf2.
Params
password
std.string
the password used to generate the new key
salt
std.string
random string (additional input for the hashing function)
Returns
std.string ·
generated ECC key in WIF format
derivePrivateKey2(password:salt:)
Generates a new private ECC key from a password using pbkdf2. This version of the derive function has a rounds count increased to 200k. This makes using this function a safer choice, but it makes the received key different than in the original version.
Params
password
std.string
the password used to generate the new key
salt
std.string
random string (additional input for the hashing function)
Returns
std.string ·
generated ECC key in WIF format
derivePublicKey(privKey:)
Generates a new public ECC key as a pair for an existing private key.
Params
privKey
std.string
private ECC key in WIF format
Returns
std.string ·
generated ECC key in BASE58DER format
encryptDataSymmetric(data:symmetricKey:)
Encrypts buffer with a given key using AES.
Params
data
privmx.endpoint.core.Buffer
buffer to encrypt
symmetricKey
privmx.endpoint.core.Buffer
key used to encrypt data
Returns
privmx.endpoint.core.Buffer ·
encrypted data buffer
decryptDataSymmetric(data:symmetricKey:)
Decrypts buffer with a given key using AES.
Params
data
privmx.endpoint.core.Buffer
buffer to decrypt
symmetricKey
privmx.endpoint.core.Buffer
key used to decrypt data
Returns
privmx.endpoint.core.Buffer ·
plain (decrypted) data buffer
convertPEMKeyToWIFKey(pemKey:)
Converts given private key in PEM format to its WIF format.
Params
pemKey
std.string
private key to convert
Returns
std.string ·
private key in WIF format
convertPGPAsn1KeyToBase58DERKey(pgpKey:)
Converts given public key in PGP format to its base58DER format.
Params
pgpKey
std.string
public key to convert
Returns
std.string ·
public key in base58DER format
generateBip39(strength:password:)
Generates ECC key and BIP-39 mnemonic from a password using BIP-39.
Params
strength
size_t
size of BIP-39 entropy, must be a multiple of 32 between 128 and 256.
password
std.string
the password used to generate the Key
Returns
BIP39 ·
BIP39 object containing ECC Key and associated with it BIP-39 mnemonic and entropy
fromMnemonic(mnemonic:password:)
Generates ECC key using BIP-39 mnemonic.
Params
mnemonic
std.string
the BIP-39 entropy used to generate the Key
password
std.string
the password used to generate the Key
Returns
BIP39 ·
BIP39 object containing ECC Key and associated with it BIP-39 mnemonic and entropy
fromEntropy(entropy:password:)
Generates ECC key using BIP-39 entropy.
Params
entropy
privmx.endpoint.core.Buffer
the BIP-39 entropy used to generate the Key
password
std.string
the password used to generate the Key
Returns
BIP39 ·
BIP39 object containing ECC Key and associated with it BIP-39 mnemonic and entropy
entropyToMnemonic(entropy:)
Converts BIP-39 mnemonic to entropy.
Params
entropy
privmx.endpoint.core.Buffer
BIP-39 entropy
Returns
std.string ·
BIP-39 mnemonic
mnemonicToEntropy(mnemonic:)
Converts BIP-39 mnemonic to entropy.
Params
mnemonic
std.string
BIP-39 mnemonic
Returns
privmx.endpoint.core.Buffer ·
BIP-39 entropy
mnemonicToSeed(mnemonic:password:)
Generates a seed used to generate a key using BIP-39 mnemonic with PBKDF2.
Params
mnemonic
std.string
password
std.string
Returns
privmx.endpoint.core.Buffer ·
generated seed
We use cookies on our website. We use them to ensure the proper functioning of the site and, if you agree, for purposes we set, such as analytics or marketing.