mirror of
https://github.com/corda/corda.git
synced 2025-02-20 17:33:15 +00:00
Added API doc for SecureHash. Removed signatureAlgorithmName val as it's not being used
This commit is contained in:
parent
8d84ece9c2
commit
f1a2bed497
@ -4,13 +4,16 @@ import com.google.common.io.BaseEncoding
|
||||
import com.r3corda.core.serialization.OpaqueBytes
|
||||
import java.security.MessageDigest
|
||||
|
||||
/**
|
||||
* Container for a cryptographically secure hash value.
|
||||
* Provides utilities for generating a cryptographic hash using different algorithms (currently only SHA-256 supported).
|
||||
*/
|
||||
sealed class SecureHash(bits: ByteArray) : OpaqueBytes(bits) {
|
||||
/** SHA-256 is part of the SHA-2 hash function family. Generated hash is fixed size, 256-bits (32-bytes) */
|
||||
class SHA256(bits: ByteArray) : SecureHash(bits) {
|
||||
init {
|
||||
require(bits.size == 32)
|
||||
}
|
||||
|
||||
override val signatureAlgorithmName: String get() = "SHA256withECDSA"
|
||||
}
|
||||
|
||||
override fun toString() = BaseEncoding.base16().encode(bits)
|
||||
@ -34,8 +37,6 @@ sealed class SecureHash(bits: ByteArray) : OpaqueBytes(bits) {
|
||||
@JvmStatic fun randomSHA256() = sha256(newSecureRandom().generateSeed(32))
|
||||
}
|
||||
|
||||
abstract val signatureAlgorithmName: String
|
||||
|
||||
// In future, maybe SHA3, truncated hashes etc.
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user