Skip to content

Commit

Permalink
Add more comments to the Hash type
Browse files Browse the repository at this point in the history
  • Loading branch information
jayz22 committed Apr 22, 2024
1 parent b51e75a commit 6c11738
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions soroban-sdk/src/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,18 @@ use crate::{
TryFromVal, Val,
};

/// A Bytes generated by a cryptographic hash function.
///
/// This struct is designed to be used in contexts where a hash value generated
/// by a secure cryptographic function is required. It can only be constructed
/// via secure manners, i.e. output from a secure hash function, or received
/// from the Soroban Env (e.g. via [`CustomAccountInterface`][crate::auth::CustomAccountInterface])
/// A Bytes generated by a cryptographic hash function. This struct is designed
/// to be used in contexts where a hash value generated by a secure
/// cryptographic function is required.
///
/// **__Note:_** this struct is used as a special annotation of `Bytes` in
/// certain internally-defined interfaces: output of hash functions, input hash
/// to ECDSA, `__check_auth`. In these scenarios, it is guaranteed the enclosed
/// bytes is the output of a secure hash function. It cannot be used as a
/// contract type (either stored as user data, or as an argument or return type
/// of a contract function). If your contract interface requires to work with a
/// hash, you need to use `Bytes`/`BytesN` and make sure it comes from a secure
/// hash function.
pub struct Hash<const N: usize>(BytesN<N>);

impl<const N: usize> Hash<N> {
Expand Down

0 comments on commit 6c11738

Please sign in to comment.