Rename SignatureType to ProofType

This commit is contained in:
silverpill 2023-03-12 23:37:40 +00:00
parent d4f701332f
commit c87c5da17c
3 changed files with 13 additions and 13 deletions

View file

@ -10,7 +10,7 @@ use crate::http_signatures::verify::{
verify_http_signature,
HttpSignatureVerificationError as HttpSignatureError,
};
use crate::identity::{did::Did, signatures::SignatureType};
use crate::identity::{did::Did, signatures::ProofType};
use crate::json_signatures::verify::{
get_json_signature,
verify_ed25519_json_signature,
@ -151,7 +151,7 @@ pub async fn verify_signed_activity(
match signature_data.signer {
JsonSigner::ActorKeyId(ref key_id) => {
if signature_data.signature_type != SignatureType::JcsRsaSignature {
if signature_data.signature_type != ProofType::JcsRsaSignature {
return Err(AuthenticationError::InvalidJsonSignatureType);
};
let signer_id = key_id_to_actor_id(key_id)?;
@ -169,7 +169,7 @@ pub async fn verify_signed_activity(
return Err(AuthenticationError::UnexpectedSigner);
};
match signature_data.signature_type {
SignatureType::JcsEd25519Signature => {
ProofType::JcsEd25519Signature => {
let did_key = match did {
Did::Key(did_key) => did_key,
_ => return Err(AuthenticationError::InvalidJsonSignatureType),
@ -180,7 +180,7 @@ pub async fn verify_signed_activity(
&signature_data.signature,
)?;
},
SignatureType::JcsEip191Signature => {
ProofType::JcsEip191Signature => {
let did_pkh = match did {
Did::Pkh(did_pkh) => did_pkh,
_ => return Err(AuthenticationError::InvalidJsonSignatureType),

View file

@ -1,4 +1,4 @@
/// Signature types
/// Proof types
use std::str::FromStr;
use crate::errors::ConversionError;
@ -28,17 +28,17 @@ pub const PROOF_TYPE_JCS_EIP191_LEGACY: &str ="JcsEip191Signature2022";
pub const PROOF_TYPE_JCS_ED25519: &str = "MitraJcsEd25519Signature2022";
#[derive(Debug, PartialEq)]
pub enum SignatureType {
pub enum ProofType {
JcsEip191Signature,
JcsEd25519Signature,
JcsRsaSignature,
}
impl FromStr for SignatureType {
impl FromStr for ProofType {
type Err = ConversionError;
fn from_str(value: &str) -> Result<Self, Self::Err> {
let signature_type = match value {
let proof_type = match value {
PROOF_TYPE_JCS_EIP191 => Self::JcsEip191Signature,
PROOF_TYPE_JCS_EIP191_LEGACY => Self::JcsEip191Signature,
PROOF_TYPE_JCS_ED25519 => Self::JcsEd25519Signature,
@ -46,6 +46,6 @@ impl FromStr for SignatureType {
PROOF_TYPE_JCS_RSA_LEGACY => Self::JcsRsaSignature,
_ => return Err(ConversionError),
};
Ok(signature_type)
Ok(proof_type)
}
}

View file

@ -19,7 +19,7 @@ use crate::identity::{
did_key::DidKey,
did_pkh::DidPkh,
minisign::verify_ed25519_signature,
signatures::SignatureType,
signatures::ProofType,
};
use super::create::{
IntegrityProof,
@ -34,7 +34,7 @@ pub enum JsonSigner {
}
pub struct SignatureData {
pub signature_type: SignatureType,
pub signature_type: ProofType,
pub signer: JsonSigner,
pub message: String,
pub signature: Vec<u8>,
@ -156,7 +156,7 @@ mod tests {
let signature_data = get_json_signature(&signed_object).unwrap();
assert_eq!(
signature_data.signature_type,
SignatureType::JcsEip191Signature,
ProofType::JcsEip191Signature,
);
let expected_signer = JsonSigner::Did(Did::Pkh(DidPkh::from_address(
&Currency::Ethereum,
@ -192,7 +192,7 @@ mod tests {
let signature_data = get_json_signature(&signed_object).unwrap();
assert_eq!(
signature_data.signature_type,
SignatureType::JcsRsaSignature,
ProofType::JcsRsaSignature,
);
let expected_signer = JsonSigner::ActorKeyId(signer_key_id.to_string());
assert_eq!(signature_data.signer, expected_signer);