Skip to content

Commit

Permalink
fix ursa references
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Whitehead <[email protected]>
  • Loading branch information
andrewwhitehead committed Jul 11, 2023
1 parent 8abe4d3 commit 0bed50a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
1 change: 0 additions & 1 deletion indy-credx/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ impl From<serde_json::Error> for Error {

impl From<ClError> for Error {
fn from(err: ClError) -> Self {
// let message = format!("Ursa Crypto Error: {}", Fail::iter_causes(&err).map(|e| e.to_string()).collect::<String>());
let message = err.to_string();
let kind = match err.kind() {
ClErrorKind::InvalidState => ErrorKind::InvalidState,
Expand Down
16 changes: 8 additions & 8 deletions indy-data-types/src/anoncreds/nonce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ use std::hash::{Hash, Hasher};
use serde::{de::Visitor, Deserialize, Deserializer, Serialize, Serializer};

#[cfg(any(feature = "cl", feature = "cl_native"))]
use crate::anoncreds_clsignatures::{new_nonce, Nonce as UrsaNonce};
use crate::anoncreds_clsignatures::{new_nonce, Nonce as ClNonce};
use crate::ConversionError;

pub struct Nonce {
strval: String,
#[cfg(any(feature = "cl", feature = "cl_native"))]
native: UrsaNonce,
native: ClNonce,
}

impl Nonce {
Expand All @@ -26,20 +26,20 @@ impl Nonce {

#[cfg(any(feature = "cl", feature = "cl_native"))]
#[inline]
pub fn from_native(native: UrsaNonce) -> Result<Self, ConversionError> {
pub fn from_native(native: ClNonce) -> Result<Self, ConversionError> {
let strval = native.to_dec().map_err(|e| e.to_string())?;
Ok(Self { strval, native })
}

#[cfg(any(feature = "cl", feature = "cl_native"))]
#[inline]
pub fn as_native(&self) -> &UrsaNonce {
pub fn as_native(&self) -> &ClNonce {
&self.native
}

#[cfg(any(feature = "cl", feature = "cl_native"))]
#[inline]
pub fn into_native(self) -> UrsaNonce {
pub fn into_native(self) -> ClNonce {
self.native
}

Expand All @@ -55,7 +55,7 @@ impl Nonce {
}
#[cfg(any(feature = "cl", feature = "cl_native"))]
{
let native = UrsaNonce::from_dec(&strval).map_err(|e| e.to_string())?;
let native = ClNonce::from_dec(&strval).map_err(|e| e.to_string())?;
Ok(Self { strval, native })
}
#[cfg(not(any(feature = "cl", feature = "cl_native")))]
Expand Down Expand Up @@ -243,11 +243,11 @@ mod tests {
#[cfg(all(feature = "serde", any(feature = "cl", feature = "cl_native")))]
#[test]
fn nonce_convert() {
let nonce = UrsaNonce::new().expect("Error creating nonce");
let nonce = ClNonce::new().expect("Error creating nonce");
let ser = serde_json::to_string(&nonce).unwrap();
let des = serde_json::from_str::<Nonce>(&ser).unwrap();
let ser2 = serde_json::to_string(&des).unwrap();
let nonce_des = serde_json::from_str::<UrsaNonce>(&ser2).unwrap();
let nonce_des = serde_json::from_str::<ClNonce>(&ser2).unwrap();
assert_eq!(nonce, nonce_des);

let nonce = Nonce::new().unwrap();
Expand Down

0 comments on commit 0bed50a

Please sign in to comment.