Skip to content

Commit

Permalink
pub use the raw vk type
Browse files Browse the repository at this point in the history
  • Loading branch information
ktmlm committed Jun 18, 2023
1 parent 106f25a commit e833ce4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ruc"
version = "5.0.5"
version = "5.0.6"
authors = ["rust-util-collections", "hui.fan@mail.ru"]
edition = "2021"
description = "Rust Util Collections"
Expand Down
11 changes: 6 additions & 5 deletions src/crypto/sig/ed25519/readable/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ use super::origin;
use crate::{crypto::codec::base64, *};
use std::fmt;

pub use ed25519_zebra::VerificationKey as RawVerifyKey;

#[cfg_attr(feature = "SerDe", derive(serde::Deserialize, serde::Serialize))]
pub struct SignKey(String);

Expand Down Expand Up @@ -60,8 +62,7 @@ impl TryFrom<&str> for SignKey {
impl VerifyKey {
pub fn verify(&self, sig: &Sig, msg: &[u8]) -> Result<()> {
let vk = base64::decode(&self.0).c(d!())?;
let vk =
ed25519_zebra::VerificationKey::try_from(vk.as_slice()).c(d!())?;
let vk = RawVerifyKey::try_from(vk.as_slice()).c(d!())?;
verify_by_raw_vk(&vk, sig, msg).c(d!())
}

Expand All @@ -80,7 +81,7 @@ impl TryFrom<String> for VerifyKey {
type Error = Box<dyn RucError>;
fn try_from(s: String) -> Result<Self> {
let vk = base64::decode(&s).c(d!())?;
ed25519_zebra::VerificationKey::try_from(vk.as_slice()).c(d!())?;
RawVerifyKey::try_from(vk.as_slice()).c(d!())?;
Ok(Self(s))
}
}
Expand All @@ -89,13 +90,13 @@ impl TryFrom<&str> for VerifyKey {
type Error = Box<dyn RucError>;
fn try_from(s: &str) -> Result<Self> {
let vk = base64::decode(s).c(d!())?;
ed25519_zebra::VerificationKey::try_from(vk.as_slice()).c(d!())?;
RawVerifyKey::try_from(vk.as_slice()).c(d!())?;
Ok(Self(s.to_owned()))
}
}

pub fn verify_by_raw_vk(
vk: &ed25519_zebra::VerificationKey,
vk: &RawVerifyKey,
sig: &Sig,
msg: &[u8],
) -> Result<()> {
Expand Down

0 comments on commit e833ce4

Please sign in to comment.