Skip to content

Commit

Permalink
fixup! Add Hash type for safe crypto fns and use it on Auth
Browse files Browse the repository at this point in the history
  • Loading branch information
jayz22 committed Apr 11, 2024
1 parent 159eae9 commit 4fe499d
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion soroban-sdk/src/crypto.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
//! Crypto contains functions for cryptographic functions.
use crate::{env::internal, unwrap::UnwrapInfallible, Bytes, BytesN, Env};
use crate::{env::internal, unwrap::UnwrapInfallible, Bytes, BytesN, Env, IntoVal, Val};

pub struct Hash<const N: usize>(BytesN<N>);

impl<const N: usize> IntoVal<Env, Val> for Hash<N> {
fn into_val(&self, e: &Env) -> Val {
self.0.into_val(e)
}
}

impl<const N: usize> IntoVal<Env, BytesN<N>> for Hash<N> {
fn into_val(&self, _e: &Env) -> BytesN<N> {
self.0.clone()
}
}

impl<const N: usize> Into<BytesN<N>> for Hash<N> {
fn into(self) -> BytesN<N> {
self.0
Expand Down

0 comments on commit 4fe499d

Please sign in to comment.