From 8147f1abc1b8941407a46ece01a2795f8776faae Mon Sep 17 00:00:00 2001 From: Simon Bihel Date: Thu, 1 Aug 2024 09:24:42 +0100 Subject: [PATCH] Use all features --- .github/workflows/build.yml | 2 +- .../crates/data-integrity/suites/Cargo.toml | 22 +++++++++++--- .../suites/unspecified/aleo_signature_2021.rs | 2 +- .../unspecified/solana_signature_2021.rs | 2 +- crates/jwk/Cargo.toml | 13 ++++++-- crates/jwk/src/aleo.rs | 14 ++++----- crates/verification-methods/Cargo.toml | 30 +++++++++++++++---- .../methods/unspecified/aleo_method_2021.rs | 6 ++-- 8 files changed, 67 insertions(+), 24 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c715fc16b..33f10b6d1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -55,7 +55,7 @@ jobs: cargo test --examples - name: Doc - run: cargo doc --no-deps --workspace + run: cargo doc --no-deps --workspace --all-features test-each-feature: if: ${{ !github.event.pull_request.draft }} diff --git a/crates/claims/crates/data-integrity/suites/Cargo.toml b/crates/claims/crates/data-integrity/suites/Cargo.toml index 6eb34e8c9..b19e9a5b8 100644 --- a/crates/claims/crates/data-integrity/suites/Cargo.toml +++ b/crates/claims/crates/data-integrity/suites/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ssi-data-integrity-suites" -version = "0.1.0" +version = "0.1.1" edition = "2021" authors = ["Spruce Systems, Inc."] license = "Apache-2.0" @@ -48,13 +48,21 @@ secp256k1 = ["ssi-verification-methods/secp256k1", "k256"] ## This includes: ## - `EcdsaSecp256r1Signature2019` (requires `w3c`) ## - `EcdsaRdfc2019` (requires `w3c`) -secp256r1 = ["ssi-data-integrity-core/secp256r1", "ssi-verification-methods/secp256r1", "p256"] +secp256r1 = [ + "ssi-data-integrity-core/secp256r1", + "ssi-verification-methods/secp256r1", + "p256", +] ## Signature suites based on secp384r1. ## ## This includes: ## - `EcdsaRdfc2019` (requires `w3c`) -secp384r1 = ["ssi-data-integrity-core/secp384r1", "ssi-verification-methods/secp384r1", "p384"] +secp384r1 = [ + "ssi-data-integrity-core/secp384r1", + "ssi-verification-methods/secp384r1", + "p384", +] ## Signature suites based on RSA. ## @@ -69,7 +77,13 @@ rsa = ["ssi-verification-methods/rsa"] ## - `TezosSignature2021` ## - `Ed25519BLAKE2BDigestSize20Base58CheckEncodedSignature2021` (requires `ed25519`) ## - `P256BLAKE2BDigestSize20Base58CheckEncodedSignature2021` (requires `secp256r1`) -tezos = ["serde_json", "serde_jcs", "ssi-tzkey", "bs58", "ssi-verification-methods/tezos"] +tezos = [ + "serde_json", + "serde_jcs", + "ssi-tzkey", + "bs58", + "ssi-verification-methods/tezos", +] ## Enables `AleoSignature2021`. aleo = ["ssi-jwk/aleo", "ssi-verification-methods/aleo", "k256"] diff --git a/crates/claims/crates/data-integrity/suites/src/suites/unspecified/aleo_signature_2021.rs b/crates/claims/crates/data-integrity/suites/src/suites/unspecified/aleo_signature_2021.rs index 5d42f2659..2db151907 100644 --- a/crates/claims/crates/data-integrity/suites/src/suites/unspecified/aleo_signature_2021.rs +++ b/crates/claims/crates/data-integrity/suites/src/suites/unspecified/aleo_signature_2021.rs @@ -18,7 +18,7 @@ use static_iref::iri; /// Aleo Signature 2021 /// -/// Linked data signature suite using [Aleo](crate::aleo). +/// Linked data signature suite using Aleo. /// /// Only verification is supported. /// diff --git a/crates/claims/crates/data-integrity/suites/src/suites/unspecified/solana_signature_2021.rs b/crates/claims/crates/data-integrity/suites/src/suites/unspecified/solana_signature_2021.rs index acdcc70fc..eb8b66def 100644 --- a/crates/claims/crates/data-integrity/suites/src/suites/unspecified/solana_signature_2021.rs +++ b/crates/claims/crates/data-integrity/suites/src/suites/unspecified/solana_signature_2021.rs @@ -40,7 +40,7 @@ use static_iref::iri; /// /// # Signature protocol /// -/// The [`SolanaWallet`] protocol is used. +/// The [`SolanaSignatureAlgorithm`] protocol is used. #[derive(Debug, Default, Clone, Copy)] pub struct SolanaSignature2021; diff --git a/crates/jwk/Cargo.toml b/crates/jwk/Cargo.toml index c3db009d1..cc7f6d1d1 100644 --- a/crates/jwk/Cargo.toml +++ b/crates/jwk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ssi-jwk" -version = "0.2.0" +version = "0.2.1" edition = "2021" authors = ["Spruce Systems, Inc."] license = "Apache-2.0" @@ -29,7 +29,16 @@ rsa = ["dep:rsa"] ## Enable aleo ecosystem keys. ## ## Not compatible with WASM targets. -aleo = ["rand", "blake2", "snarkvm-dpc", "snarkvm-algorithms", "snarkvm-curves", "snarkvm-utilities", "snarkvm-parameters", "bs58"] +aleo = [ + "rand", + "blake2", + "snarkvm-dpc", + "snarkvm-algorithms", + "snarkvm-curves", + "snarkvm-utilities", + "snarkvm-parameters", + "bs58", +] ## enable ripemd-160 hashing for keys, e.g. for bitcoin. ripemd-160 = ["ssi-crypto/ripemd-160", "secp256k1"] diff --git a/crates/jwk/src/aleo.rs b/crates/jwk/src/aleo.rs index 3b86b38f6..f52baa2da 100644 --- a/crates/jwk/src/aleo.rs +++ b/crates/jwk/src/aleo.rs @@ -5,7 +5,7 @@ //! [Aleo]: https://developer.aleo.org/testnet/getting_started/overview#the-network //! //! This module provides [sign] and [verify] functions for Aleo signatures -//! using static parameters ([COM_PARAMS], [ENC_PARAMS], [SIG_PARAMS]) +//! using static parameters ([struct@COM_PARAMS], [struct@ENC_PARAMS], [struct@SIG_PARAMS]) //! and a [JWK-based keypair representation](OKP_CURVE). use crate::{Base64urlUInt, OctetParams, Params, JWK}; @@ -150,16 +150,16 @@ lazy_static::lazy_static! { /// /// An Aleo private key JWK is expected to contain an account address in the public key ("x") /// parameter that corresponds to the private key ("d") parameter, -/// using [SIG_PARAMS], [COM_PARAMS] and [ENC_PARAMS]. +/// using [struct@SIG_PARAMS], [struct@COM_PARAMS] and [struct@ENC_PARAMS]. /// /// An Aleo public key JWK contains the public key ("x") parameter and MUST not contain a private /// key ("d") parameter. An Aleo public key JWK is usable for verification of signatures using -/// [ENC_PARAMS]. +/// [struct@ENC_PARAMS]. pub const OKP_CURVE: &str = "AleoTestnet1Key"; /// Generate an Aleo private key in [unofficial JWK format][OKP_CURVE]. **CPU-intensive (slow)**. /// -/// Uses [SIG_PARAMS], [COM_PARAMS], and [ENC_PARAMS]. +/// Uses [struct@SIG_PARAMS], [struct@COM_PARAMS], and [struct@ENC_PARAMS]. pub fn generate_private_key_jwk() -> Result { let mut rng = rand::rngs::OsRng {}; let sig_params = SIG_PARAMS.clone(); @@ -185,7 +185,7 @@ pub fn generate_private_key_jwk() -> Result { /// Convert JWK private key to Aleo private key /// -/// Uses [SIG_PARAMS], [COM_PARAMS], and [ENC_PARAMS] to compute the account address. +/// Uses [struct@SIG_PARAMS], [struct@COM_PARAMS], and [struct@ENC_PARAMS] to compute the account address. fn aleo_jwk_to_private_key(jwk: &JWK) -> Result, ParsePrivateKeyError> { let params = match &jwk.params { Params::OKP(ref okp_params) => { @@ -242,7 +242,7 @@ fn aleo_jwk_to_address(jwk: &JWK) -> Result, ParseAddressErr /// Create an Aleo signature. /// -/// The message is signed using [ENC_PARAMS] and a View Key derived from the given JWK private key with [SIG_PARAMS] and [COM_PARAMS]. +/// The message is signed using [struct@ENC_PARAMS] and a View Key derived from the given JWK private key with [struct@SIG_PARAMS] and [struct@COM_PARAMS]. /// /// The JWK private key `key` is expected to use key type `OKP` with curve according to /// [OKP_CURVE]. @@ -265,7 +265,7 @@ pub fn sign(msg: &[u8], key: &JWK) -> Result, AleoSignError> { /// Verify an Aleo signature by an Aleo address as a string. /// -/// Verification uses [ENC_PARAMS]. +/// Verification uses [struct@ENC_PARAMS]. pub fn verify(msg: &[u8], address: &str, sig: &[u8]) -> Result<(), AleoVerifyError> { let address = Address::::from_str(address).map_err(AleoVerifyError::AddressFromStr)?; diff --git a/crates/verification-methods/Cargo.toml b/crates/verification-methods/Cargo.toml index 06a3e43b2..a19847cf6 100644 --- a/crates/verification-methods/Cargo.toml +++ b/crates/verification-methods/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ssi-verification-methods" -version = "0.1.0" +version = "0.1.1" edition = "2021" authors = ["Spruce Systems, Inc."] license = "Apache-2.0" @@ -9,13 +9,27 @@ repository = "https://github.com/spruceid/ssi/" documentation = "https://docs.rs/ssi-verification-methods/" [features] -default = ["ed25519", "rsa", "secp256k1", "secp256r1", "secp384r1", "tezos", "eip712", "solana"] +default = [ + "ed25519", + "rsa", + "secp256k1", + "secp256r1", + "secp384r1", + "tezos", + "eip712", + "solana", +] ## enable RSA keys rsa = [] ## enable ed25519 keys -ed25519 = ["ed25519-dalek", "rand_core", "ssi-jws/ed25519", "ssi-multicodec/ed25519"] +ed25519 = [ + "ed25519-dalek", + "rand_core", + "ssi-jws/ed25519", + "ssi-multicodec/ed25519", +] ## enable secp256k1 keys secp256k1 = ["k256", "sha2", "ssi-jws/secp256k1", "ssi-multicodec/k256"] @@ -37,7 +51,12 @@ aleo = ["ssi-caips/aleo"] solana = [] -bbs = ["ssi-multicodec/bls12-381", "ssi-jwk/bbs", "ssi-bbs", "ssi-verification-methods-core/bbs"] +bbs = [ + "ssi-multicodec/bls12-381", + "ssi-jwk/bbs", + "ssi-bbs", + "ssi-verification-methods-core/bbs", +] [dependencies] ssi-core.workspace = true @@ -76,4 +95,5 @@ p256 = { workspace = true, optional = true, features = ["ecdsa"] } p384 = { workspace = true, optional = true, features = ["ecdsa"] } # rand_core_0_5 = { version = "0.5", optional = true, package = "rand_core" } -rand_core = { version = "0.6.4", optional = true } \ No newline at end of file +rand_core = { version = "0.6.4", optional = true } + diff --git a/crates/verification-methods/src/methods/unspecified/aleo_method_2021.rs b/crates/verification-methods/src/methods/unspecified/aleo_method_2021.rs index fd2767912..07c32c273 100644 --- a/crates/verification-methods/src/methods/unspecified/aleo_method_2021.rs +++ b/crates/verification-methods/src/methods/unspecified/aleo_method_2021.rs @@ -18,14 +18,14 @@ pub const ALEO_METHOD_2021_TYPE: &str = "AleoMethod2021"; /// Aleo Method 2021. /// /// Schnorr signature with [Edwards BLS12] curve -/// https://developer.aleo.org/aleo/concepts/accounts +/// /// -/// The verification method object must have a [blockchainAccountId] property, identifying the +/// The verification method object must have a `blockchainAccountId` property, identifying the /// signer's Aleo /// account address and network id for verification purposes. The chain id part of the account address /// identifies an Aleo network as specified in the proposed [CAIP for Aleo Blockchain /// Reference][caip-aleo-chain-ref]. Signatures use parameters defined per network. Currently only -/// network id "1" (CAIP-2 "aleo:1" / [Aleo Testnet I][testnet1]) is supported. The account +/// network id "1" (CAIP-2 "aleo:1" / testnet1) is supported. The account /// address format is documented in [Aleo /// documentation](https://developer.aleo.org/aleo/concepts/accounts#account-address). #[derive(