corda / net.corda.core.crypto / Crypto

# Crypto

`object Crypto`

This object controls and provides the available and supported signature schemes for Corda. Any implemented SignatureScheme should be strictly defined here. However, only the schemes returned by {@link #listSupportedSignatureSchemes()} are supported. Note that Corda currently supports the following signature schemes by their code names:

### Functions

decodePrivateKey | `fun decodePrivateKey(encodedKey: ByteArray): PrivateKey` Decode a PKCS8 encoded key to its PrivateKey object. `fun decodePrivateKey(encodedKey: ByteArray, schemeCodeName: String): PrivateKey` Decode a PKCS8 encoded key to its PrivateKey object based on the input scheme code name. This will be used by Kryo deserialisation.
decodePublicKey | `fun decodePublicKey(encodedKey: ByteArray): PublicKey` Decode an X509 encoded key to its PublicKey object. `fun decodePublicKey(encodedKey: ByteArray, schemeCodeName: String): PublicKey` Decode an X509 encoded key to its PrivateKey object based on the input scheme code name. This will be used by Kryo deserialisation.
doSign | `fun doSign(privateKey: PrivateKey, clearData: ByteArray): ByteArray` Generic way to sign ByteArray data with a PrivateKey. Strategy on on identifying the actual signing scheme is based on the PrivateKey type, but if the schemeCodeName is known, then better use doSign(signatureScheme: String, privateKey: PrivateKey, clearData: ByteArray). `fun doSign(schemeCodeName: String, privateKey: PrivateKey, clearData: ByteArray): ByteArray` Generic way to sign ByteArray data with a PrivateKey and a known schemeCodeName String. `fun doSign(privateKey: PrivateKey, metaData: MetaData): TransactionSignature` Generic way to sign MetaData objects with a PrivateKey. MetaData is a wrapper over the transaction's Merkle root in order to attach extra information, such as a timestamp or partial and blind signature indicators.
doVerify | `fun doVerify(schemeCodeName: String, publicKey: PublicKey, signatureData: ByteArray, clearData: ByteArray): Boolean` Utility to simplify the act of verifying a digital signature. It returns true if it succeeds, but it always throws an exception if verification fails. `fun doVerify(publicKey: PublicKey, signatureData: ByteArray, clearData: ByteArray): Boolean` Utility to simplify the act of verifying a digital signature by identifying the signature scheme used from the input public key's type. It returns true if it succeeds, but it always throws an exception if verification fails. Strategy on identifying the actual signing scheme is based on the PublicKey type, but if the schemeCodeName is known, then better use doVerify(schemeCodeName: String, publicKey: PublicKey, signatureData: ByteArray, clearData: ByteArray). `fun doVerify(publicKey: PublicKey, transactionSignature: TransactionSignature): Boolean` Utility to simplify the act of verifying a TransactionSignature. It returns true if it succeeds, but it always throws an exception if verification fails.
findSignatureSchemeCodeName | `fun findSignatureSchemeCodeName(key: Key): String` Retrieve the corresponding signature scheme code name based on the type of the input Key. See Crypto for the supported scheme code names.
generateKeyPair | `fun generateKeyPair(schemeCodeName: String): KeyPair` Utility to simplify the act of generating keys. Normally, we don't expect other errors here, assuming that key generation parameters for every supported signature scheme have been unit-tested. `fun generateKeyPair(): KeyPair` Generate a KeyPair using the default signature scheme.
getDefaultSignatureSchemeCodeName | `fun getDefaultSignatureSchemeCodeName(): String`
isSupportedSignatureScheme | `fun isSupportedSignatureScheme(schemeCodeName: String): Boolean` Check if the requested signature scheme is supported by the system.
listSupportedSignatureSchemes | `fun listSupportedSignatureSchemes(): List<String>`