Skip to content

Commit

Permalink
Rename eddsa-2022 into eddsa-rdfc-2022. (#581)
Browse files Browse the repository at this point in the history
* Bring `eddsa-2022` back for back-compatibility.
  • Loading branch information
timothee-haudebourg authored Jul 15, 2024
1 parent 3f2b1d3 commit 5c47f16
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 12 deletions.
13 changes: 10 additions & 3 deletions crates/claims/crates/data-integrity/src/any/suite/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,18 @@ macros::crypto_suites! {
#[cfg(all(feature = "w3c", feature = "ed25519"))]
ed25519_signature_2020: Ed25519Signature2020,

/// W3C EdDSA Cryptosuite v2022.
/// W3C `eddsa-2022` cryptosuite, a draft version of the `eddsa-rdfc-2022`
/// cryptosuite.
///
/// See: <https://w3c.github.io/vc-di-eddsa/>
/// See: <https://www.w3.org/TR/2023/WD-vc-di-eddsa-20230714/#eddsa-2022>
#[cfg(all(feature = "w3c", feature = "ed25519"))]
ed_dsa_2022: EdDsa2022,
eddsa_2022: EdDsa2022,

/// W3C `eddsa-rdfc-2022` cryptosuite.
///
/// See: <https://w3c.github.io/vc-di-eddsa/#eddsa-rdfc-2022>
#[cfg(all(feature = "w3c", feature = "ed25519"))]
eddsa_rdfc_2022: EdDsaRdfc2022,

/// W3C Ecdsa Secp256k1 Signature 2019.
///
Expand Down
5 changes: 5 additions & 0 deletions crates/claims/crates/data-integrity/suites/src/suites/w3c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ pub mod eddsa_2022;
#[cfg(feature = "ed25519")]
pub use eddsa_2022::EdDsa2022;

#[cfg(feature = "ed25519")]
pub mod eddsa_rdfc_2022;
#[cfg(feature = "ed25519")]
pub use eddsa_rdfc_2022::EdDsaRdfc2022;

#[cfg(feature = "secp256k1")]
pub mod ecdsa_secp256k1_signature_2019;
#[cfg(feature = "secp256k1")]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
//! EdDSA Cryptosuite v2022 implementation.
//!
//! This is the successor of the EdDSA Cryptosuite v2020.
//!
//! See: <https://w3c.github.io/vc-di-eddsa/>
use k256::sha2::Sha256;
use ssi_data_integrity_core::{
canonicalization::{CanonicalizeClaimsAndConfiguration, HashCanonicalClaimsAndConfiguration},
Expand All @@ -13,12 +8,13 @@ use ssi_data_integrity_core::{
use ssi_verification_methods::Multikey;
use static_iref::iri;

/// EdDSA Cryptosuite v2020.
/// The `eddsa-2022` cryptosuite, a draft version of the `eddsa-rdfc-2022`
/// cryptosuite.
///
/// This is a legacy cryptographic suite for the usage of the EdDSA algorithm
/// and Curve25519. It is recommended to use `edssa-2022` instead.
/// This is only provided for compatibility with applications based on the
/// EDDSA cryptosuite draft.
///
/// See: <https://w3c.github.io/vc-di-eddsa/#the-ed25519signature2020-suite>
/// See: <https://www.w3.org/TR/2023/WD-vc-di-eddsa-20230714/#eddsa-2022>
#[derive(Debug, Default, Clone, Copy)]
pub struct EdDsa2022;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
use k256::sha2::Sha256;
use ssi_data_integrity_core::{
canonicalization::{CanonicalizeClaimsAndConfiguration, HashCanonicalClaimsAndConfiguration},
signing::{Base58Btc, MultibaseSigning},
suite::NoConfiguration,
CryptosuiteStr, StandardCryptographicSuite, TypeRef,
};
use ssi_verification_methods::Multikey;
use static_iref::iri;

/// The `eddsa-rdfc-2022` cryptosuite.
///
/// See: <https://w3c.github.io/vc-di-eddsa/#eddsa-rdfc-2022>
#[derive(Debug, Default, Clone, Copy)]
pub struct EdDsaRdfc2022;

impl EdDsaRdfc2022 {
pub const NAME: &'static str = "DataIntegrityProof";

pub const IRI: &'static iref::Iri = iri!("https://w3id.org/security#DataIntegrityProof");
}

impl StandardCryptographicSuite for EdDsaRdfc2022 {
type Configuration = NoConfiguration;

type Transformation = CanonicalizeClaimsAndConfiguration;

type Hashing = HashCanonicalClaimsAndConfiguration<Sha256>;

type VerificationMethod = Multikey;

type SignatureAlgorithm = MultibaseSigning<ssi_crypto::algorithm::EdDSA, Base58Btc>;

type ProofOptions = ();

fn type_(&self) -> TypeRef {
TypeRef::DataIntegrityProof(CryptosuiteStr::new("eddsa-rdfc-2022").unwrap())
}
}

0 comments on commit 5c47f16

Please sign in to comment.