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

sign

fun PrivateKey.sign(bytesToSign: ByteArray): DigitalSignature

Utility to simplify the act of signing a byte array.

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 DigitalSignature object on the input message.

fun PrivateKey.sign(bytesToSign: ByteArray, publicKey: PublicKey): WithKey

Utility to simplify the act of signing a byte array and return a DigitalSignature.WithKey object. Note that there is no check if the public key matches with the signing private key.

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 DigitalSignature.WithKey object on the input message bytesToSign and publicKey.