Skip to content

Commit

Permalink
Use all features
Browse files Browse the repository at this point in the history
  • Loading branch information
sbihel committed Aug 1, 2024
1 parent 94743ca commit 8147f1a
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
22 changes: 18 additions & 4 deletions crates/claims/crates/data-integrity/suites/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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.
##
Expand All @@ -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"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
13 changes: 11 additions & 2 deletions crates/jwk/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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"]
Expand Down
14 changes: 7 additions & 7 deletions crates/jwk/src/aleo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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<JWK, AleoGeneratePrivateKeyError> {
let mut rng = rand::rngs::OsRng {};
let sig_params = SIG_PARAMS.clone();
Expand All @@ -185,7 +185,7 @@ pub fn generate_private_key_jwk() -> Result<JWK, AleoGeneratePrivateKeyError> {

/// 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<PrivateKey<Components>, ParsePrivateKeyError> {
let params = match &jwk.params {
Params::OKP(ref okp_params) => {
Expand Down Expand Up @@ -242,7 +242,7 @@ fn aleo_jwk_to_address(jwk: &JWK) -> Result<Address<Components>, 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].
Expand All @@ -265,7 +265,7 @@ pub fn sign(msg: &[u8], key: &JWK) -> Result<Vec<u8>, 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::<Components>::from_str(address).map_err(AleoVerifyError::AddressFromStr)?;
Expand Down
30 changes: 25 additions & 5 deletions crates/verification-methods/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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"]
Expand All @@ -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
Expand Down Expand Up @@ -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 }
rand_core = { version = "0.6.4", optional = true }

Original file line number Diff line number Diff line change
Expand Up @@ -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
/// <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(
Expand Down

0 comments on commit 8147f1a

Please sign in to comment.