sign - corda

corda / net.corda.core.crypto / java.security.KeyPair / sign

# sign

`fun KeyPair.sign(bytesToSign: ByteArray): WithKey`

Helper function to sign with a key pair.

### Parameters

`bytesToSign` - 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 KeyPair.sign(bytesToSign: OpaqueBytes): WithKey`

Helper function to sign the bytes of bytesToSign with a key pair.

`fun KeyPair.sign(signableData: SignableData): TransactionSignature`

Helper function for signing a SignableData object.

### Parameters

`signableData` - the object to be signed.

### 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
a TransactionSignature object.