diff --git a/Cargo.toml b/Cargo.toml index 56251ff3a..5f24adfd0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -83,7 +83,7 @@ zkryptium = "0.2.2" # BBS log = "0.4.21" async-std = "1.9" async-trait = "0.1.68" -thiserror = "1.0.40" +thiserror = "2.0" chrono = "0.4.24" iref = "3.2.2" static-iref = "3.0" diff --git a/crates/claims/crates/data-integrity/core/src/hashing.rs b/crates/claims/crates/data-integrity/core/src/hashing.rs index a966d9e02..fe707ca8b 100644 --- a/crates/claims/crates/data-integrity/core/src/hashing.rs +++ b/crates/claims/crates/data-integrity/core/src/hashing.rs @@ -1,3 +1,4 @@ +#![allow(deprecated)] // TODO upgrade `digest` crate when possible. use digest::{ consts::{U32, U48}, generic_array::{ArrayLength, GenericArray}, diff --git a/crates/claims/crates/data-integrity/suites/src/suites/dif/ecdsa_secp256k1_recovery_signature_2020.rs b/crates/claims/crates/data-integrity/suites/src/suites/dif/ecdsa_secp256k1_recovery_signature_2020.rs index 75d0c010b..6c5ac14b5 100644 --- a/crates/claims/crates/data-integrity/suites/src/suites/dif/ecdsa_secp256k1_recovery_signature_2020.rs +++ b/crates/claims/crates/data-integrity/suites/src/suites/dif/ecdsa_secp256k1_recovery_signature_2020.rs @@ -36,7 +36,7 @@ impl StandardCryptographicSuite for EcdsaSecp256k1RecoverySignature2020 { type ProofOptions = (); - fn type_(&self) -> TypeRef { + fn type_(&self) -> TypeRef<'_> { TypeRef::Other(Self::NAME) } } 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 e0b7f308c..0aadced4a 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 @@ -83,7 +83,7 @@ impl StandardCryptographicSuite for AleoSignature2021 { type ProofOptions = (); - fn type_(&self) -> TypeRef { + fn type_(&self) -> TypeRef<'_> { TypeRef::Other(Self::NAME) } } diff --git a/crates/claims/crates/data-integrity/suites/src/suites/unspecified/eip712_signature_2021.rs b/crates/claims/crates/data-integrity/suites/src/suites/unspecified/eip712_signature_2021.rs index dee6a29fe..4b891eb3a 100644 --- a/crates/claims/crates/data-integrity/suites/src/suites/unspecified/eip712_signature_2021.rs +++ b/crates/claims/crates/data-integrity/suites/src/suites/unspecified/eip712_signature_2021.rs @@ -95,7 +95,7 @@ impl StandardCryptographicSuite for Eip712Signature2021 { type ProofOptions = (); - fn type_(&self) -> TypeRef { + fn type_(&self) -> TypeRef<'_> { TypeRef::Other(Self::NAME) } } diff --git a/crates/claims/crates/data-integrity/suites/src/suites/unspecified/ethereum_personal_signature_2021.rs b/crates/claims/crates/data-integrity/suites/src/suites/unspecified/ethereum_personal_signature_2021.rs index e863acdaf..fc058bb0b 100644 --- a/crates/claims/crates/data-integrity/suites/src/suites/unspecified/ethereum_personal_signature_2021.rs +++ b/crates/claims/crates/data-integrity/suites/src/suites/unspecified/ethereum_personal_signature_2021.rs @@ -56,7 +56,7 @@ impl StandardCryptographicSuite for EthereumPersonalSignature2021 { type ProofOptions = (); - fn type_(&self) -> TypeRef { + fn type_(&self) -> TypeRef<'_> { TypeRef::Other(Self::NAME) } } diff --git a/crates/claims/crates/data-integrity/suites/src/suites/unspecified/ethereum_personal_signature_2021/v0_1.rs b/crates/claims/crates/data-integrity/suites/src/suites/unspecified/ethereum_personal_signature_2021/v0_1.rs index 265f3d47c..fe157f785 100644 --- a/crates/claims/crates/data-integrity/suites/src/suites/unspecified/ethereum_personal_signature_2021/v0_1.rs +++ b/crates/claims/crates/data-integrity/suites/src/suites/unspecified/ethereum_personal_signature_2021/v0_1.rs @@ -31,7 +31,7 @@ impl StandardCryptographicSuite for EthereumPersonalSignature2021v0_1 { type ProofOptions = (); - fn type_(&self) -> TypeRef { + fn type_(&self) -> TypeRef<'_> { TypeRef::Other(Self::NAME) } } 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 624e929dc..ccb7b1c49 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 @@ -65,7 +65,7 @@ impl StandardCryptographicSuite for SolanaSignature2021 { type ProofOptions = (); - fn type_(&self) -> TypeRef { + fn type_(&self) -> TypeRef<'_> { TypeRef::Other(Self::NAME) } } diff --git a/crates/claims/crates/data-integrity/suites/src/suites/unspecified/tezos.rs b/crates/claims/crates/data-integrity/suites/src/suites/unspecified/tezos.rs index 34d7b5ad5..b09f4393c 100644 --- a/crates/claims/crates/data-integrity/suites/src/suites/unspecified/tezos.rs +++ b/crates/claims/crates/data-integrity/suites/src/suites/unspecified/tezos.rs @@ -99,7 +99,7 @@ impl Options { } impl RecoverPublicJwk for Options { - fn public_jwk(&self) -> Cow { + fn public_jwk(&self) -> Cow<'_, JWK> { Cow::Borrowed(&self.public_key_jwk) } } diff --git a/crates/claims/crates/data-integrity/suites/src/suites/unspecified/tezos/ed25519_blake2b_digest_size20_base58_check_encoded_signature_2021.rs b/crates/claims/crates/data-integrity/suites/src/suites/unspecified/tezos/ed25519_blake2b_digest_size20_base58_check_encoded_signature_2021.rs index 13ed0802b..4c8556964 100644 --- a/crates/claims/crates/data-integrity/suites/src/suites/unspecified/tezos/ed25519_blake2b_digest_size20_base58_check_encoded_signature_2021.rs +++ b/crates/claims/crates/data-integrity/suites/src/suites/unspecified/tezos/ed25519_blake2b_digest_size20_base58_check_encoded_signature_2021.rs @@ -36,7 +36,7 @@ impl StandardCryptographicSuite for Ed25519BLAKE2BDigestSize20Base58CheckEncoded type ProofOptions = Options; - fn type_(&self) -> TypeRef { + fn type_(&self) -> TypeRef<'_> { TypeRef::Other(Self::NAME) } } diff --git a/crates/claims/crates/data-integrity/suites/src/suites/unspecified/tezos/p256_blake2b_digest_size20_base58_check_encoded_signature_2021.rs b/crates/claims/crates/data-integrity/suites/src/suites/unspecified/tezos/p256_blake2b_digest_size20_base58_check_encoded_signature_2021.rs index cba3bf43e..c56b40060 100644 --- a/crates/claims/crates/data-integrity/suites/src/suites/unspecified/tezos/p256_blake2b_digest_size20_base58_check_encoded_signature_2021.rs +++ b/crates/claims/crates/data-integrity/suites/src/suites/unspecified/tezos/p256_blake2b_digest_size20_base58_check_encoded_signature_2021.rs @@ -36,7 +36,7 @@ impl StandardCryptographicSuite for P256BLAKE2BDigestSize20Base58CheckEncodedSig type ProofOptions = Options; - fn type_(&self) -> TypeRef { + fn type_(&self) -> TypeRef<'_> { TypeRef::Other(Self::NAME) } } diff --git a/crates/claims/crates/data-integrity/suites/src/suites/unspecified/tezos/tezos_jcs_signature_2021.rs b/crates/claims/crates/data-integrity/suites/src/suites/unspecified/tezos/tezos_jcs_signature_2021.rs index 6b3f801ef..155f108d4 100644 --- a/crates/claims/crates/data-integrity/suites/src/suites/unspecified/tezos/tezos_jcs_signature_2021.rs +++ b/crates/claims/crates/data-integrity/suites/src/suites/unspecified/tezos/tezos_jcs_signature_2021.rs @@ -80,7 +80,7 @@ impl StandardCryptographicSuite for TezosJcsSignature2021 { type ProofOptions = Options; - fn type_(&self) -> TypeRef { + fn type_(&self) -> TypeRef<'_> { TypeRef::Other(Self::NAME) } } diff --git a/crates/claims/crates/data-integrity/suites/src/suites/unspecified/tezos/tezos_signature_2021.rs b/crates/claims/crates/data-integrity/suites/src/suites/unspecified/tezos/tezos_signature_2021.rs index 6ee7a707f..d3c03006b 100644 --- a/crates/claims/crates/data-integrity/suites/src/suites/unspecified/tezos/tezos_signature_2021.rs +++ b/crates/claims/crates/data-integrity/suites/src/suites/unspecified/tezos/tezos_signature_2021.rs @@ -64,7 +64,7 @@ impl StandardCryptographicSuite for TezosSignature2021 { type ProofOptions = Options; - fn type_(&self) -> TypeRef { + fn type_(&self) -> TypeRef<'_> { TypeRef::Other(Self::NAME) } } diff --git a/crates/claims/crates/data-integrity/suites/src/suites/w3c/bbs_2023/mod.rs b/crates/claims/crates/data-integrity/suites/src/suites/w3c/bbs_2023/mod.rs index 5237d600a..74ddb45aa 100644 --- a/crates/claims/crates/data-integrity/suites/src/suites/w3c/bbs_2023/mod.rs +++ b/crates/claims/crates/data-integrity/suites/src/suites/w3c/bbs_2023/mod.rs @@ -87,7 +87,7 @@ impl StandardCryptographicSuite for Bbs2023 { type SignatureAlgorithm = Bbs2023SignatureAlgorithm; - fn type_(&self) -> TypeRef { + fn type_(&self) -> TypeRef<'_> { TypeRef::DataIntegrityProof(CryptosuiteStr::new("bbs-2023").unwrap()) } } diff --git a/crates/claims/crates/data-integrity/suites/src/suites/w3c/bbs_2023/tests/mod.rs b/crates/claims/crates/data-integrity/suites/src/suites/w3c/bbs_2023/tests/mod.rs index 6c96f0d9b..a7a158113 100644 --- a/crates/claims/crates/data-integrity/suites/src/suites/w3c/bbs_2023/tests/mod.rs +++ b/crates/claims/crates/data-integrity/suites/src/suites/w3c/bbs_2023/tests/mod.rs @@ -32,13 +32,13 @@ pub struct JsonCredential { } impl JsonLdObject for JsonCredential { - fn json_ld_context(&self) -> Option> { + fn json_ld_context(&self) -> Option> { Some(Cow::Borrowed(&self.context)) } } impl JsonLdNodeObject for JsonCredential { - fn json_ld_type(&self) -> JsonLdTypes { + fn json_ld_type(&self) -> JsonLdTypes<'_> { JsonLdTypes::new(&[], Cow::Borrowed(&self.types)) } } diff --git a/crates/claims/crates/jws/src/compact/url_safe.rs b/crates/claims/crates/jws/src/compact/url_safe.rs index f2adce6cc..0c401f363 100644 --- a/crates/claims/crates/jws/src/compact/url_safe.rs +++ b/crates/claims/crates/jws/src/compact/url_safe.rs @@ -208,7 +208,7 @@ impl<'a> PartialEq<&'a Jws> for String { /// don't know if it is URL-safe. /// Use [`JwsVec`](crate::JwsVec) if you don't have any expectations about the /// encoding. -#[derive(Clone, serde::Serialize)] +#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, serde::Serialize)] #[serde(transparent)] pub struct JwsBuf(String); diff --git a/crates/claims/crates/jws/src/lib.rs b/crates/claims/crates/jws/src/lib.rs index f709ce283..a06dfce8d 100644 --- a/crates/claims/crates/jws/src/lib.rs +++ b/crates/claims/crates/jws/src/lib.rs @@ -948,6 +948,7 @@ pub fn recover(algorithm: Algorithm, data: &[u8], signature: &[u8]) -> Result::from_slice(&hash); let recovered_key = VerifyingKey::recover_from_prehash(digest, &sig, rec_id) .map_err(ssi_jwk::Error::from)?; diff --git a/crates/claims/crates/jws/src/signature.rs b/crates/claims/crates/jws/src/signature.rs index 1d4207698..a21bab5f9 100644 --- a/crates/claims/crates/jws/src/signature.rs +++ b/crates/claims/crates/jws/src/signature.rs @@ -1,6 +1,6 @@ use ssi_claims_core::SignatureError; use ssi_jwk::{Algorithm, JWK}; -use std::borrow::Cow; +use std::{borrow::Cow, rc::Rc, sync::Arc}; use crate::{DecodedJws, DecodedSigningBytes, Header, JwsBuf, JwsSignature}; @@ -134,7 +134,7 @@ pub trait JwsSigner { } } -impl JwsSigner for &T { +impl JwsSigner for &T { async fn fetch_info(&self) -> Result { T::fetch_info(*self).await } @@ -148,6 +148,48 @@ impl JwsSigner for &T { } } +impl JwsSigner for Box { + async fn fetch_info(&self) -> Result { + T::fetch_info(self).await + } + + async fn sign_bytes(&self, signing_bytes: &[u8]) -> Result, SignatureError> { + T::sign_bytes(self, signing_bytes).await + } + + async fn sign(&self, payload: impl JwsPayload) -> Result { + T::sign(self, payload).await + } +} + +impl JwsSigner for Rc { + async fn fetch_info(&self) -> Result { + T::fetch_info(self).await + } + + async fn sign_bytes(&self, signing_bytes: &[u8]) -> Result, SignatureError> { + T::sign_bytes(self, signing_bytes).await + } + + async fn sign(&self, payload: impl JwsPayload) -> Result { + T::sign(self, payload).await + } +} + +impl JwsSigner for Arc { + async fn fetch_info(&self) -> Result { + T::fetch_info(self).await + } + + async fn sign_bytes(&self, signing_bytes: &[u8]) -> Result, SignatureError> { + T::sign_bytes(self, signing_bytes).await + } + + async fn sign(&self, payload: impl JwsPayload) -> Result { + T::sign(self, payload).await + } +} + impl JwsSigner for Cow<'_, T> { async fn fetch_info(&self) -> Result { T::fetch_info(self.as_ref()).await diff --git a/crates/claims/crates/jwt/src/claims/matching.rs b/crates/claims/crates/jwt/src/claims/matching.rs index d4e396c65..2b32e2928 100644 --- a/crates/claims/crates/jwt/src/claims/matching.rs +++ b/crates/claims/crates/jwt/src/claims/matching.rs @@ -187,7 +187,7 @@ mod tests { } } - fn try_get(&self) -> Result>, InvalidClaimValue> { + fn try_get(&self) -> Result>, InvalidClaimValue> { match_claim_type! { match C { CustomClaim => { diff --git a/crates/claims/crates/vc/examples/sign.rs b/crates/claims/crates/vc/examples/sign.rs index 716a5216f..c84e31af5 100644 --- a/crates/claims/crates/vc/examples/sign.rs +++ b/crates/claims/crates/vc/examples/sign.rs @@ -39,13 +39,13 @@ pub struct Credential { } impl ssi_json_ld::JsonLdObject for Credential { - fn json_ld_context(&self) -> Option> { + fn json_ld_context(&self) -> Option> { Some(Cow::Borrowed(self.context.as_ref())) } } impl ssi_json_ld::JsonLdNodeObject for Credential { - fn json_ld_type(&self) -> ssi_json_ld::JsonLdTypes { + fn json_ld_type(&self) -> ssi_json_ld::JsonLdTypes<'_> { self.type_.to_json_ld_types() } } @@ -278,7 +278,7 @@ impl VerificationMethodResolver for Keyring { _issuer: Option<&Iri>, method: Option>, _options: ssi_verification_methods::ResolutionOptions, - ) -> Result, VerificationMethodResolutionError> { + ) -> Result, VerificationMethodResolutionError> { match method { Some(ReferenceOrOwnedRef::Owned(_key)) => { // If we get here, this means the VC embeds the public key used diff --git a/crates/crypto/src/signatures/bbs.rs b/crates/crypto/src/signatures/bbs.rs index 472ae8adc..9e9823221 100644 --- a/crates/crypto/src/signatures/bbs.rs +++ b/crates/crypto/src/signatures/bbs.rs @@ -4,6 +4,67 @@ //! //! [BBS curves]: https://datatracker.ietf.org/doc/html/draft-yonezawa-pairing-friendly-curves#section-4.2.2 //! [BBS+]: https://mattrglobal.github.io/bbs-signatures-spec/ +// This shows how the generators are created with nothing up my sleeve values +// ```ignore +// const PREHASH: &'static [u8] = b"To be, or not to be- that is the question: +// Whether 'tis nobler in the mind to suffer +// The slings and arrows of outrageous fortune +// Or to take arms against a sea of troubles, +// And by opposing end them. To die- to sleep- +// No more; and by a sleep to say we end +// The heartache, and the thousand natural shocks +// That flesh is heir to. 'Tis a consummation +// Devoutly to be wish'd. To die- to sleep. +// To sleep- perchance to dream: ay, there's the rub! +// For in that sleep of death what dreams may come +// When we have shuffled off this mortal coil, +// Must give us pause. There's the respect +// That makes calamity of so long life. +// For who would bear the whips and scorns of time, +// Th' oppressor's wrong, the proud man's contumely, +// The pangs of despis'd love, the law's delay, +// The insolence of office, and the spurns +// That patient merit of th' unworthy takes, +// When he himself might his quietus make +// With a bare bodkin? Who would these fardels bear, +// To grunt and sweat under a weary life, +// But that the dread of something after death- +// The undiscover'd country, from whose bourn +// No traveller returns- puzzles the will, +// And makes us rather bear those ills we have +// Than fly to others that we know not of? +// Thus conscience does make cowards of us all, +// And thus the native hue of resolution +// Is sicklied o'er with the pale cast of thought, +// And enterprises of great pith and moment +// With this regard their currents turn awry +// And lose the name of action.- Soft you now! +// The fair Ophelia!- Nymph, in thy orisons +// Be all my sins rememb'red."; +// const DST_G1: &'static [u8] = b"BLS12381G1_XMD:BLAKE2B_SSWU_RO_BLS_SIGNATURES:1_0_0"; +// const DST_G2: &'static [u8] = b"BLS12381G2_XMD:BLAKE2B_SSWU_RO_BLS_SIGNATURES:1_0_0"; +// +// use pairing_plus::{ +// bls12_381::{G1, G2}, +// hash_to_field::{BaseFromRO, ExpandMsgXmd}, +// hash_to_curve::HashToCurve, +// serdes::SerDes, +// CurveProjective, +// }; +// fn main() { +// let g1 = >>::hash_to_curve(PREHASH, DST_G1); +// let g2 = >>::hash_to_curve(PREHASH, DST_G2); +// +// let mut g1_bytes = Vec::new(); +// let mut g2_bytes = Vec::new(); +// +// g1.serialize(&mut g1_bytes, true).unwrap(); +// g2.serialize(&mut g2_bytes, true).unwrap(); +// +// assert_eq!(g1_bytes.as_slice(), ssi::bbs::BLINDING_G1); +// assert_eq!(g2_bytes.as_slice(), ssi::bbs::BLINDING_G2); +// } +// ``` use bbs::prelude::*; use pairing_plus::{ bls12_381::{Bls12, Fr, G1, G2}, @@ -21,68 +82,6 @@ use std::fmt::Formatter; use thiserror::Error; use zeroize::Zeroize; -/// This shows how the generators are created with nothing up my sleeve values -/// ```ignore -/// const PREHASH: &'static [u8] = b"To be, or not to be- that is the question: -/// Whether 'tis nobler in the mind to suffer -/// The slings and arrows of outrageous fortune -/// Or to take arms against a sea of troubles, -/// And by opposing end them. To die- to sleep- -/// No more; and by a sleep to say we end -/// The heartache, and the thousand natural shocks -/// That flesh is heir to. 'Tis a consummation -/// Devoutly to be wish'd. To die- to sleep. -/// To sleep- perchance to dream: ay, there's the rub! -/// For in that sleep of death what dreams may come -/// When we have shuffled off this mortal coil, -/// Must give us pause. There's the respect -/// That makes calamity of so long life. -/// For who would bear the whips and scorns of time, -/// Th' oppressor's wrong, the proud man's contumely, -/// The pangs of despis'd love, the law's delay, -/// The insolence of office, and the spurns -/// That patient merit of th' unworthy takes, -/// When he himself might his quietus make -/// With a bare bodkin? Who would these fardels bear, -/// To grunt and sweat under a weary life, -/// But that the dread of something after death- -/// The undiscover'd country, from whose bourn -/// No traveller returns- puzzles the will, -/// And makes us rather bear those ills we have -/// Than fly to others that we know not of? -/// Thus conscience does make cowards of us all, -/// And thus the native hue of resolution -/// Is sicklied o'er with the pale cast of thought, -/// And enterprises of great pith and moment -/// With this regard their currents turn awry -/// And lose the name of action.- Soft you now! -/// The fair Ophelia!- Nymph, in thy orisons -/// Be all my sins rememb'red."; -/// const DST_G1: &'static [u8] = b"BLS12381G1_XMD:BLAKE2B_SSWU_RO_BLS_SIGNATURES:1_0_0"; -/// const DST_G2: &'static [u8] = b"BLS12381G2_XMD:BLAKE2B_SSWU_RO_BLS_SIGNATURES:1_0_0"; -/// -/// use pairing_plus::{ -/// bls12_381::{G1, G2}, -/// hash_to_field::{BaseFromRO, ExpandMsgXmd}, -/// hash_to_curve::HashToCurve, -/// serdes::SerDes, -/// CurveProjective, -/// }; -/// fn main() { -/// let g1 = >>::hash_to_curve(PREHASH, DST_G1); -/// let g2 = >>::hash_to_curve(PREHASH, DST_G2); -/// -/// let mut g1_bytes = Vec::new(); -/// let mut g2_bytes = Vec::new(); -/// -/// g1.serialize(&mut g1_bytes, true).unwrap(); -/// g2.serialize(&mut g2_bytes, true).unwrap(); -/// -/// assert_eq!(g1_bytes.as_slice(), ssi::bbs::BLINDING_G1); -/// assert_eq!(g2_bytes.as_slice(), ssi::bbs::BLINDING_G2); -/// } -/// ``` - pub const BLINDING_G1: &[u8] = &[ 185, 201, 5, 142, 138, 68, 184, 112, 20, 249, 139, 228, 225, 129, 141, 183, 24, 248, 178, 213, 16, 31, 200, 158, 105, 131, 98, 95, 50, 31, 20, 184, 77, 124, 246, 225, 85, 0, 73, 135, 162, diff --git a/crates/jwk/src/lib.rs b/crates/jwk/src/lib.rs index f92380431..d3d294fbb 100644 --- a/crates/jwk/src/lib.rs +++ b/crates/jwk/src/lib.rs @@ -1027,9 +1027,12 @@ pub fn serialize_p256(params: &ECParams) -> Result, Error> { // TODO: check that curve is P-256 use p256::elliptic_curve::{sec1::EncodedPoint, FieldBytes}; + #[allow(deprecated)] // TODO upgrade `digest` crate when possible. let x = FieldBytes::::from_slice( ¶ms.x_coordinate.as_ref().ok_or(Error::MissingPoint)?.0, ); + + #[allow(deprecated)] // TODO upgrade `digest` crate when possible. let y = FieldBytes::::from_slice( ¶ms.y_coordinate.as_ref().ok_or(Error::MissingPoint)?.0, ); @@ -1043,9 +1046,11 @@ pub fn serialize_p256(params: &ECParams) -> Result, Error> { pub fn serialize_p384(params: &ECParams) -> Result, Error> { // TODO: check that curve is P-384 use p384::elliptic_curve::{sec1::EncodedPoint, FieldBytes}; + #[allow(deprecated)] // TODO upgrade `digest` crate when possible. let x = FieldBytes::::from_slice( ¶ms.x_coordinate.as_ref().ok_or(Error::MissingPoint)?.0, ); + #[allow(deprecated)] // TODO upgrade `digest` crate when possible. let y = FieldBytes::::from_slice( ¶ms.y_coordinate.as_ref().ok_or(Error::MissingPoint)?.0, ); diff --git a/crates/multicodec/src/codec/bls12_381.rs b/crates/multicodec/src/codec/bls12_381.rs index ab204dbcd..f325fc537 100644 --- a/crates/multicodec/src/codec/bls12_381.rs +++ b/crates/multicodec/src/codec/bls12_381.rs @@ -11,7 +11,7 @@ impl Codec for BBSplusPublicKey { BBSplusPublicKey::from_bytes(bytes).map_err(|_| Error::InvalidData) } - fn to_bytes(&self) -> std::borrow::Cow<[u8]> { + fn to_bytes(&self) -> std::borrow::Cow<'_, [u8]> { Cow::Owned(self.to_bytes().to_vec()) } } diff --git a/crates/ucan/src/lib.rs b/crates/ucan/src/lib.rs index 13a010c29..061da8fc8 100644 --- a/crates/ucan/src/lib.rs +++ b/crates/ucan/src/lib.rs @@ -44,19 +44,14 @@ pub struct Ucan { codec: UcanCodec, } -#[derive(Clone, PartialEq, Debug)] +#[derive(Default, Clone, PartialEq, Debug)] enum UcanCodec { // maintain serialization Raw(String), + #[default] DagJson, } -impl Default for UcanCodec { - fn default() -> Self { - Self::DagJson - } -} - impl Ucan { pub async fn verify_signature(&self, resolver: &impl DIDResolver) -> Result<(), Error> where