BSV.Crypto (bsv_sdk v1.1.0)

Copy Markdown View Source

Cryptographic hash functions using OTP :crypto.

Summary

Functions

Hash160: RIPEMD160(SHA256(data)).

RIPEMD-160 hash.

Constant-time binary comparison.

SHA-256 hash.

HMAC-SHA256.

Double SHA-256 hash.

SHA-512 hash.

Functions

hash160(data)

@spec hash160(binary()) :: <<_::160>>

Hash160: RIPEMD160(SHA256(data)).

ripemd160(data)

@spec ripemd160(binary()) :: <<_::160>>

RIPEMD-160 hash.

secure_compare(a, b)

@spec secure_compare(binary(), binary()) :: boolean()

Constant-time binary comparison.

Prevents timing side-channel attacks when comparing secrets (HMACs, keys, etc.). Returns true if both binaries are equal, false otherwise. Always examines every byte regardless of where the first difference occurs.

sha256(data)

@spec sha256(binary()) :: <<_::256>>

SHA-256 hash.

sha256_hmac(data, key)

@spec sha256_hmac(binary(), binary()) :: <<_::256>>

HMAC-SHA256.

sha256d(data)

@spec sha256d(binary()) :: <<_::256>>

Double SHA-256 hash.

sha512(data)

@spec sha512(binary()) :: <<_::512>>

SHA-512 hash.