Skip to content

Commit

Permalink
Make Hash not construct-able
Browse files Browse the repository at this point in the history
  • Loading branch information
jayz22 committed Apr 16, 2024
1 parent a31d848 commit ca71756
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion soroban-sdk/src/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,17 @@ use crate::{
/// A wrapper type for a cryptographic hash.
///
/// This struct is designed to be used in contexts where a hash value generated
/// by a secure cryptographic function is required.
/// 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 host (e.g. via `CustomAccountInterface`)
pub struct Hash<const N: usize>(BytesN<N>);

impl<const N: usize> Hash<N> {
/// Constructs a new `Hash` from a fixed-length bytes array.
///
/// This is intended for test-only, since `Hash` type is only meant to be
/// constructed via secure manners.
#[cfg(test)]
pub fn from_bytes(bytes: BytesN<N>) -> Self {
Self(bytes)
}
Expand Down

0 comments on commit ca71756

Please sign in to comment.