Package-level declarations

Types

Link copied to clipboard

A tree data structure that enables the representation of composite public keys, which are used to represent the signing requirements for multi-signature scenarios such as RAFT notary services. A composite key is a list of leaf keys and their contributing weight, and each leaf can be a conventional single key or a composite key. Keys contribute their weight to the total if they are matched by the signature.

Link copied to clipboard

Factory for generating composite keys from ASN.1 format key specifications. This is used by CordaSecurityProvider.

Link copied to clipboard

Dedicated class for storing a set of signatures that comprise CompositeKey.

Link copied to clipboard

Custom class for holding signature data. This exists for later extension work to provide a standardised cross-platform serialization format.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
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:

Link copied to clipboard
interface DigestAlgorithm

Interface for injecting custom digest implementation bypassing JCA.

Link copied to clipboard
data class DigestService(val hashAlgorithm: String)

The DigestService class is a service that offers the main crypto methods for calculating transaction hashes and building Merkle trees. The default instance is passed by default to instances of classes like TransactionBuilder and as a parameter to MerkleTree.getMerkleTree(...) method. In future the default instance can be parametrized to initialize with the network default hash algorithm or just a more secure algorithm (e.g. SHA3_256). While the SHA2_256 is vulnerable to pre-image attacks, the computeNonce and componentHash methods behaviour is defined by the hashTwiceNonce and hashTwiceComponent; with SHA2_256 they both must be set to true to ensure pre-image attack won't work (and for backward compatibility), but for other algorithms like SHA3_256 that are not affected, they can and should be set to false as hashing twice would not improve security but affect performance.

Link copied to clipboard

A wrapper around a digital signature.

Link copied to clipboard
Link copied to clipboard
sealed class MerkleTree

Creation and verification of a Merkle tree for a WireTransaction.

Link copied to clipboard
Link copied to clipboard
object NullKeys
Link copied to clipboard

Building and verification of Partial Merkle Tree. Partial Merkle Tree is a minimal tree needed to check that a given set of leaves belongs to a full Merkle Tree.

Link copied to clipboard
sealed class SecureHash : OpaqueBytes

Container for a cryptographically secure hash value. Provides utilities for generating a cryptographic hash using different algorithms (currently only SHA-256 supported).

Link copied to clipboard
data class SignableData(val txId: SecureHash, val signatureMetadata: SignatureMetadata)

A SignableData object is the packet actually signed. It works as a wrapper over transaction id and signature metadata. Note that when multi-transaction signing (signing a block of transactions) is used, the root of the Merkle tree (having transaction IDs as leaves) is actually signed and thus txId refers to this root and not a specific transaction.

Link copied to clipboard
data class SignatureMetadata(val platformVersion: Int, val schemeNumberID: Int)

SignatureMeta is required to add extra meta-data to a transaction's signature. It currently supports platformVersion only, but it can be extended to support a universal digital signature model enabling partial signatures and attaching extra information, such as a user's timestamp or other application-specific fields.

Link copied to clipboard
data class SignatureScheme(val schemeNumberID: Int, val schemeCodeName: String, val signatureOID: <Error class: unknown class>, val alternativeOIDs: List<<Error class: unknown class>>, val providerName: String, val algorithmName: String, val signatureName: String, val algSpec: AlgorithmParameterSpec?, val keySize: Int?, val desc: String)

This class is used to define a digital signature scheme.

Link copied to clipboard
open class SignedData<T : Any>(val raw: SerializedBytes<T>, val sig: DigitalSignature.WithKey)

A serialized piece of data and its signature. Enforces signature validity in order to deserialize the data contained within.

Link copied to clipboard
class TransactionSignature(bytes: ByteArray, val by: PublicKey, val signatureMetadata: SignatureMetadata, val partialMerkleTree: PartialMerkleTree?) : DigitalSignature

A wrapper over the signature output accompanied by signer's public key and signature metadata. This is similar to DigitalSignature.WithKey, but targeted to DLT transaction (or block of transactions) signatures.

Properties

Link copied to clipboard

Hash algorithm.

Link copied to clipboard
Link copied to clipboard

Return a Set of the contained leaf keys if this is a CompositeKey. Otherwise, return a Set with a single element (this PublicKey). Note that leaf keys cannot be of type CompositeKey.

Functions

Link copied to clipboard
fun Iterable<TransactionSignature>.byKeys(): <Error class: unknown class>

Returns the set of all PublicKeys of the signatures.

Link copied to clipboard
operator fun KeyPair.component1(): PrivateKey
Link copied to clipboard
operator fun KeyPair.component2(): PublicKey
Link copied to clipboard
fun componentHash(nonce: SecureHash, opaqueBytes: OpaqueBytes): SecureHash

Return the SHA256(SHA256(nonce || serializedComponent)).

fun componentHash(opaqueBytes: OpaqueBytes, privacySalt: PrivacySalt, componentGroupIndex: Int, internalIndex: Int): SecureHash

Compute the hash of each serialised component so as to be used as Merkle tree leaf. The resultant output (leaf) is calculated using the SHA256d algorithm, thus SHA256(SHA256(nonce || serializedComponent)), where nonce is computed from computeNonce.

Link copied to clipboard
fun computeNonce(privacySalt: PrivacySalt, groupIndex: Int, internalIndex: Int): SecureHash.SHA256

Method to compute a nonce based on privacySalt, component group index and component internal index. SHA256d (double SHA256) is used to prevent length extension attacks.

Link copied to clipboard

Checks whether any of the given keys matches a leaf on the CompositeKey tree or a single PublicKey.

Link copied to clipboard

Returns a key pair derived from the given private key entropy. This is useful for unit tests and other cases where you want hard-coded private keys.

Link copied to clipboard

A simple wrapper that will make it easier to swap out the signature algorithm we use in future.

Link copied to clipboard

Compute the algorithm hash for the contents of the ByteArray.

Compute the algorithm hash for the contents of the OpaqueBytes.

Link copied to clipboard

Return true if otherKey fulfils the requirements of this PublicKey.

Return true if otherKeys fulfil the requirements of this PublicKey.

Link copied to clipboard

Utility to simplify the act of verifying a signature. In comparison to verify if the key and signature do not match it returns false rather than throwing an exception. Normally you should use the function which throws, as it avoids the risk of failing to test the result, but this is for uses such as java.security.Signature.verify implementations.

Link copied to clipboard

Get an instance of SecureRandom to avoid blocking, due to waiting for additional entropy, when possible. In this version, the NativePRNGNonBlocking is exclusively used on Linux OS to utilize dev/urandom because in high traffic /dev/random may wait for a certain amount of "noise" to be generated on the host machine before returning a result.

Link copied to clipboard

Returns a random positive non-zero long generated using a secure RNG. This function sacrifies a bit of entropy in order to avoid potential bugs where the value is used in a context where negative numbers or zero are not expected.

Link copied to clipboard
Link copied to clipboard
fun secureRandomBytes(numOfBytes: Int): ByteArray

Generate a securely random ByteArray of requested number of bytes. Usually used for seeds, nonces and keys.

Link copied to clipboard

Serialise the object and return the hash of the serialized bytes. Note that the resulting hash may not be deterministic across platform versions: serialization can produce different values if any of the types being serialized have changed, or if the version of serialization specified by the context changes.

Link copied to clipboard

Compute the SHA-256 hash for the contents of the ByteArray.

Compute the SHA-256 hash for the contents of the OpaqueBytes.

Link copied to clipboard

Helper function to sign with a key pair.

Helper function for signing a SignableData object.

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

Utility to simplify the act of signing a byte array.

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.

Link copied to clipboard

Render a public key to its hash (in Base58) of its serialised form using the DL prefix.

Link copied to clipboard
fun KeyPair.verify(signatureData: ByteArray, clearData: ByteArray): Boolean

Helper function for the signers to verify their own signature.

fun PublicKey.verify(signatureData: ByteArray, clearData: ByteArray): Boolean

Helper function to verify a signature.

Utility to simplify the act of verifying a signature.