Skip to content

Commit 1178212

Browse files
Merge pull request #368 from andrewwhitehead/edition-2024
Update to Rust 2024 edition
2 parents 51db591 + b81832e commit 1178212

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+607
-486
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: "Anoncreds"
22

33
env:
4-
RUST_VERSION: "1.81.0"
4+
RUST_VERSION: "1.85.0"
55
CROSS_VERSION: "0.2.4"
66

77
on:
@@ -350,6 +350,9 @@ jobs:
350350
matrix:
351351
architecture:
352352
[aarch64-apple-ios, aarch64-apple-ios-sim, x86_64-apple-ios]
353+
env:
354+
IPHONEOS_DEPLOYMENT_TARGET: 10.0
355+
IPHONESIMULATOR_DEPLOYMENT_TARGET: 10.0
353356

354357
steps:
355358
- name: Checkout

Cargo.toml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ authors = [
55
"Hyperledger AnonCreds Contributors <anoncreds@lists.hyperledger.org>",
66
]
77
description = "Verifiable credential issuance and presentation for Hyperledger AnonCreds (https://www.hyperledger.org/projects), which provides a foundation for self-sovereign identity."
8-
edition = "2021"
8+
edition = "2024"
99
license = "Apache-2.0"
1010
readme = "../README.md"
1111
repository = "https://github.com/hyperledger/anoncreds-rs/"
1212
categories = ["authentication", "cryptography"]
1313
keywords = ["hyperledger", "ssi", "verifiable", "credentials"]
14-
rust-version = "1.58"
14+
rust-version = "1.85"
1515

1616
[lib]
1717
name = "anoncreds"
@@ -28,25 +28,25 @@ zeroize = ["dep:zeroize"]
2828

2929
[dependencies]
3030
anoncreds-clsignatures = "0.3.2"
31-
base64 = { version = "0.21.5", optional = true }
31+
base64 = { version = "0.22", optional = true }
3232
bitvec = { version = "1.0.1", features = ["serde"] }
3333
bs58 = "0.5.0"
3434
chrono = { version = "0.4.31", optional = true, features = ["serde"] }
35-
env_logger = { version = "0.9.3", optional = true }
35+
env_logger = { version = "0.11", optional = true }
3636
ffi-support = { version = "0.4.0", optional = true }
3737
log = "0.4.17"
38-
once_cell = "1.17.1"
39-
rand = "0.8.5"
38+
once_cell = "1"
39+
rand = "0.9"
4040
regex = "1.7.1"
4141
rmp-serde = { version = "1.1.2", optional = true }
4242
serde = { version = "1.0.155", features = ["derive"] }
4343
serde_json = { version = "1.0.94", features = ["raw_value"] }
4444
sha2 = "0.10.6"
45-
thiserror = "1.0.39"
45+
thiserror = "2"
4646
zeroize = { version = "1.5.7", optional = true, features = ["zeroize_derive"] }
4747

4848
[dev-dependencies]
49-
rstest = "0.18.2"
49+
rstest = "0.26"
5050

5151
[profile.release]
5252
codegen-units = 1

Cross.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[build.env]
2+
passthrough = ["CFLAGS"]
3+
4+
[target.aarch64-unknown-linux-gnu]
5+
image = "ghcr.io/rust-cross/manylinux2014-cross:aarch64"
6+
7+
[target.x86_64-unknown-linux-gnu]
8+
image = "ghcr.io/rust-cross/manylinux2014-cross:x86_64"

docs/design/w3c/w3c-representation.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Methods purpose - have to forms of credentials (probably even duplicate in walle
5555
///
5656
/// # Returns
5757
/// Error code
58-
#[no_mangle]
58+
#[unsafe(no_mangle)]
5959
pub extern "C" fn anoncreds_credential_to_w3c(
6060
cred: ObjectHandle,
6161
issuer_id: FfiStr,
@@ -71,7 +71,7 @@ pub extern "C" fn anoncreds_credential_to_w3c(
7171
///
7272
/// # Returns
7373
/// Error code
74-
#[no_mangle]
74+
#[unsafe(no_mangle)]
7575
pub extern "C" fn anoncreds_credential_from_w3c(
7676
cred: ObjectHandle,
7777
cred_p: *mut ObjectHandle,
@@ -120,7 +120,7 @@ The reasons for adding duplication methods:
120120
///
121121
/// # Returns
122122
/// Error code
123-
#[no_mangle]
123+
#[unsafe(no_mangle)]
124124
pub extern "C" fn anoncreds_create_w3c_credential(
125125
cred_def: ObjectHandle,
126126
cred_def_private: ObjectHandle,
@@ -145,7 +145,7 @@ pub extern "C" fn anoncreds_create_w3c_credential(
145145
///
146146
/// # Returns
147147
/// Error code
148-
#[no_mangle]
148+
#[unsafe(no_mangle)]
149149
pub extern "C" fn anoncreds_process_w3c_credential(
150150
cred: ObjectHandle,
151151
cred_req_metadata: ObjectHandle,
@@ -166,7 +166,7 @@ pub extern "C" fn anoncreds_process_w3c_credential(
166166
///
167167
/// # Returns
168168
/// Error code
169-
#[no_mangle]
169+
#[unsafe(no_mangle)]
170170
pub extern "C" fn anoncreds_w3c_credential_get_integrity_proof_details(
171171
handle: ObjectHandle,
172172
cred_proof_info_p: *mut ObjectHandle,
@@ -188,7 +188,7 @@ pub extern "C" fn anoncreds_w3c_credential_get_integrity_proof_details(
188188
///
189189
/// # Returns
190190
/// Error code
191-
#[no_mangle]
191+
#[unsafe(no_mangle)]
192192
pub extern "C" fn anoncreds_create_w3c_presentation(
193193
pres_req: ObjectHandle,
194194
credentials: FfiList<FfiCredentialEntry>,
@@ -219,7 +219,7 @@ pub extern "C" fn anoncreds_create_w3c_presentation(
219219
///
220220
/// # Returns
221221
/// Error code
222-
#[no_mangle]
222+
#[unsafe(no_mangle)]
223223
pub extern "C" fn anoncreds_verify_w3c_presentation(
224224
presentation: ObjectHandle,
225225
pres_req: ObjectHandle,

src/data_types/cred_def.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ pub enum SignatureType {
1818
CL,
1919
}
2020

21+
impl SignatureType {
22+
pub const fn as_str(&self) -> &'static str {
23+
match self {
24+
Self::CL => CL_SIGNATURE_TYPE,
25+
}
26+
}
27+
}
28+
2129
impl FromStr for SignatureType {
2230
type Err = ConversionError;
2331

@@ -29,6 +37,12 @@ impl FromStr for SignatureType {
2937
}
3038
}
3139

40+
impl std::fmt::Display for SignatureType {
41+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
42+
f.write_str(self.as_str())
43+
}
44+
}
45+
3246
#[derive(Debug, Serialize, Deserialize)]
3347
pub struct CredentialDefinitionData {
3448
pub primary: CredentialPrimaryPublicKey,

src/data_types/cred_request.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::cl::{
44
};
55
use crate::error::{Result, ValidationError};
66
use crate::invalid;
7-
use crate::utils::validation::{is_uri_identifier, Validatable, LEGACY_DID_IDENTIFIER};
7+
use crate::utils::validation::{LEGACY_DID_IDENTIFIER, Validatable, is_uri_identifier};
88

99
use super::{cred_def::CredentialDefinitionId, nonce::Nonce};
1010

src/data_types/credential.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ use std::collections::HashMap;
44
#[cfg(feature = "zeroize")]
55
use zeroize::Zeroize;
66

7+
use crate::Error;
78
use crate::cl::{CredentialSignature, RevocationRegistry, SignatureCorrectnessProof, Witness};
89
use crate::error::{ConversionError, ValidationError};
910
use crate::types::MakeCredentialValues;
1011
use crate::utils::validation::Validatable;
11-
use crate::Error;
1212

1313
use super::rev_reg_def::RevocationRegistryDefinitionId;
1414
use super::{cred_def::CredentialDefinitionId, schema::SchemaId};

src/data_types/link_secret.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::fmt;
22

3-
use crate::cl::{bn::BigNumber, Prover as CryptoProver};
3+
use crate::cl::{Prover as CryptoProver, bn::BigNumber};
44
use crate::error::ConversionError;
55

66
pub struct LinkSecret(pub(crate) BigNumber);

src/data_types/macros.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ macro_rules! impl_anoncreds_object_identifier {
33
($i:ident) => {
44
use $crate::error::ValidationError;
55
use $crate::utils::validation::{
6-
Validatable, LEGACY_CRED_DEF_IDENTIFIER, LEGACY_DID_IDENTIFIER,
7-
LEGACY_REV_REG_DEF_IDENTIFIER, LEGACY_SCHEMA_IDENTIFIER, URI_IDENTIFIER,
6+
LEGACY_CRED_DEF_IDENTIFIER, LEGACY_DID_IDENTIFIER, LEGACY_REV_REG_DEF_IDENTIFIER,
7+
LEGACY_SCHEMA_IDENTIFIER, URI_IDENTIFIER, Validatable,
88
};
99

1010
#[derive(Debug, Clone, PartialEq, Eq, Hash, Deserialize, Serialize, Default)]
@@ -53,7 +53,7 @@ macro_rules! impl_anoncreds_object_identifier {
5353
return Err($crate::invalid!(
5454
"type: {} does not have a validation regex",
5555
invalid_name,
56-
))
56+
));
5757
}
5858
};
5959

src/data_types/nonce.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ use std::convert::TryFrom;
22
use std::fmt;
33
use std::hash::{Hash, Hasher};
44

5-
use crate::cl::{new_nonce, Nonce as CryptoNonce};
5+
use crate::cl::{Nonce as CryptoNonce, new_nonce};
66
use crate::error::ConversionError;
77
use serde::de::{Error, SeqAccess};
8-
use serde::{de::Visitor, Deserialize, Deserializer, Serialize, Serializer};
8+
use serde::{Deserialize, Deserializer, Serialize, Serializer, de::Visitor};
99
use serde_json::Value;
1010

1111
pub struct Nonce {

0 commit comments

Comments
 (0)