corda / net.corda.core.crypto / Crypto / doSign

# 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).

### Parameters

`privateKey` - the signer's PrivateKey.

`clearData` - the data/message to be signed in ByteArray form (usually the Merkle root).

### Exceptions

`IllegalArgumentException` - if the signature scheme is not supported for this private key.

`InvalidKeyException` - if the private key is invalid.

`SignatureException` - if signing is not possible due to malformed data or private key.

Return
the digital signature (in ByteArray) on the input message.

`fun doSign(schemeCodeName: String, privateKey: PrivateKey, clearData: ByteArray): ByteArray`

Generic way to sign ByteArray data with a PrivateKey and a known schemeCodeName String.

### Parameters

`schemeCodeName` - a signature scheme's code name (e.g. ECDSA_SECP256K1_SHA256).

`privateKey` - the signer's PrivateKey.

`clearData` - the data/message to be signed in ByteArray form (usually the Merkle root).

### Exceptions

`IllegalArgumentException` - if the signature scheme is not supported.

`InvalidKeyException` - if the private key is invalid.

`SignatureException` - if signing is not possible due to malformed data or private key.

Return
the digital signature (in ByteArray) on the input message.

`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.

### Parameters

`privateKey` - the signer's PrivateKey.

`metaData` - a MetaData object that adds extra information to a transaction.

### Exceptions

`IllegalArgumentException` - if the signature scheme is not supported for this private key or if metaData.schemeCodeName is not aligned with key type.

`InvalidKeyException` - if the private key is invalid.

`SignatureException` - if signing is not possible due to malformed data or private key.

Return
a TransactionSignature object than contains the output of a successful signing and the metaData.