Initializer
init(rawValue:)
Constructs a digest by adopting a caller-supplied 32-byte value.
init(rawValue: Data) throws
Parameters
-
rawValue
-
The digest bytes. Must be exactly 32 bytes; any other length throws.
Discussion
Use this when materializing a previously computed digest back into a typed value — for example, after reading the raw bytes from persistent storage or decoding a Nostr NIP-01 event id from hex. The bytes are copied in by value (Data is a Swift value type), so the initializer has no ongoing aliasing with the caller’s buffer.
No cryptographic work is performed here — this initializer is purely a typed wrapper around an existing digest. Compute new digests through hash(data:) or hash(string:).
Throws
OpenSSLError.invalidInput(_:) with a message describing the length mismatch when rawValue.count != 32.