Module utils

Source
Expand description

Contains small utility functions used in the other hopr-crypto-... crates

Structs§

SecretValue
Represents a secret value of a fixed length that is zeroized on drop. Secret values are always compared in constant time. The default value is all zeroes.

Functions§

k256_scalar_from_bytes
Creates secp256k1 secret scalar from the given bytes. Note that this function allows zero scalars.
sample_secp256k1_field_element
Sample a random secp256k1 field element that can represent a valid secp256k1 point. The implementation uses the hash_to_field function as defined in <https://www.ietf.org/archive/id/draft-irtf-cfrg-hash-to-curve-13.html#name-hashing-to-a-finite-field> The secret must be at least SecretKey::LENGTH long. The tag parameter will be used as an additional Domain Separation Tag.
x25519_scalar_from_bytes
Creates X25519 secret scalar (also compatible with Ed25519 scalar) from the given bytes. This function ensures the value is pre-multiplied by the curve’s co-factor and already reduced mod 2^255-19.