Skip to main content

pallet_auto_id/
lib.rs

1// Copyright (C) 2023 Subspace Labs, Inc.
2// SPDX-License-Identifier: Apache-2.0
3
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// 	http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15
16//! Pallet AutoID
17
18#![cfg_attr(not(feature = "std"), no_std)]
19// TODO: Remove once FRAME macros stop generating `.clone()` calls on `Copy` types with user spans
20#![expect(clippy::clone_on_copy, reason = "Comes from Substrate")]
21
22#[cfg(feature = "runtime-benchmarks")]
23mod benchmarking;
24#[cfg(test)]
25mod tests;
26pub mod weights;
27
28extern crate alloc;
29
30#[cfg(not(feature = "std"))]
31use alloc::collections::BTreeSet;
32#[cfg(not(feature = "std"))]
33use alloc::vec::Vec;
34use frame_support::dispatch::{DispatchResult, DispatchResultWithPostInfo};
35use frame_support::ensure;
36use frame_support::traits::Time;
37use frame_support::weights::Weight;
38pub use pallet::*;
39use parity_scale_codec::{Decode, DecodeWithMemTracking, Encode};
40use scale_info::TypeInfo;
41use sp_auto_id::auto_id_runtime_interface::{decode_tbs_certificate, verify_signature};
42use sp_auto_id::{DerVec, SignatureVerificationRequest, Validity};
43use sp_core::{H256, U256};
44use sp_io::hashing::blake2_256;
45#[cfg(feature = "std")]
46use std::collections::BTreeSet;
47use subspace_runtime_primitives::Moment;
48pub use weights::WeightInfo;
49
50/// Unique AutoId identifier.
51pub type Identifier = H256;
52
53/// Serial issued by the subject.
54pub type Serial = U256;
55
56/// X509 certificate.
57#[derive(Debug, Decode, Encode, TypeInfo, PartialEq, Eq, Clone)]
58pub struct X509Certificate {
59    /// Issuer identifier of this certificate.
60    pub issuer_id: Option<Identifier>,
61    /// Serial number for this certificate
62    pub serial: U256,
63    /// Subject common name of the certificate.
64    pub subject_common_name: Vec<u8>,
65    /// Der encoded certificate's subject's public key info.
66    pub subject_public_key_info: DerVec,
67    /// Validity of the certificate
68    pub validity: Validity,
69    /// Der encoded full X509 certificate.
70    pub raw: DerVec,
71    /// A list of all certificate serials issues by the subject.
72    /// Serial of root certificate is included as well.
73    pub issued_serials: BTreeSet<Serial>,
74    /// Certificate action nonce.
75    pub nonce: U256,
76}
77
78/// Certificate associated with AutoId.
79#[derive(Debug, Decode, Encode, TypeInfo, PartialEq, Eq, Clone)]
80pub enum Certificate {
81    X509(X509Certificate),
82}
83
84impl Certificate {
85    /// Returns the subject distinguished name.
86    #[cfg(test)]
87    fn subject_common_name(&self) -> Vec<u8> {
88        match self {
89            Certificate::X509(cert) => cert.subject_common_name.clone(),
90        }
91    }
92
93    /// Returns the subject public key info.
94    fn subject_public_key_info(&self) -> DerVec {
95        match self {
96            Certificate::X509(cert) => cert.subject_public_key_info.clone(),
97        }
98    }
99
100    fn issue_certificate_serial<T: Config>(&mut self, serial: U256) -> DispatchResult {
101        match self {
102            Certificate::X509(cert) => {
103                ensure!(
104                    !cert.issued_serials.contains(&serial),
105                    Error::<T>::CertificateSerialAlreadyIssued
106                );
107                cert.issued_serials.insert(serial);
108                Ok(())
109            }
110        }
111    }
112
113    fn issuer_id(&self) -> Option<Identifier> {
114        match self {
115            Certificate::X509(cert) => cert.issuer_id,
116        }
117    }
118
119    fn serial(&self) -> Serial {
120        match self {
121            Certificate::X509(cert) => cert.serial,
122        }
123    }
124
125    fn issued_serials(&self) -> BTreeSet<Serial> {
126        match self {
127            Certificate::X509(cert) => cert.issued_serials.clone(),
128        }
129    }
130
131    /// Checks if the certificate is valid at this time.
132    pub(crate) fn is_valid_at(&self, time: Moment) -> bool {
133        match self {
134            Certificate::X509(cert) => cert.validity.is_valid_at(time),
135        }
136    }
137
138    /// Deterministically derives an identifier from the certificate.
139    ///
140    /// The identifier is derived by hashing the subject common name of the certificate.
141    /// If the certificate is a leaf certificate, the issuer identifier is combined with the subject common name.
142    fn derive_identifier(&self) -> Identifier {
143        match &self {
144            Certificate::X509(cert) => {
145                if let Some(issuer_id) = cert.issuer_id {
146                    let mut data = issuer_id.to_fixed_bytes().to_vec();
147
148                    data.extend_from_slice(cert.subject_common_name.as_ref());
149
150                    blake2_256(&data).into()
151                } else {
152                    // Root certificate
153                    blake2_256(cert.subject_common_name.as_ref()).into()
154                }
155            }
156        }
157    }
158
159    fn nonce(&self) -> U256 {
160        match self {
161            Certificate::X509(cert) => cert.nonce,
162        }
163    }
164
165    fn inc_nonce<T: Config>(&mut self) -> DispatchResult {
166        match self {
167            Certificate::X509(cert) => {
168                cert.nonce = cert
169                    .nonce
170                    .checked_add(U256::one())
171                    .ok_or(Error::<T>::NonceOverflow)?;
172                Ok(())
173            }
174        }
175    }
176}
177
178/// A representation of AutoId
179#[derive(Debug, Decode, Encode, TypeInfo, PartialEq, Eq, Clone)]
180pub struct AutoId {
181    /// Certificate associated with this AutoId.
182    pub certificate: Certificate,
183}
184
185/// Type holds X509 certificate details used to register an AutoId.
186#[derive(Debug, Decode, Encode, TypeInfo, PartialEq, Eq, Clone, DecodeWithMemTracking)]
187pub enum RegisterAutoIdX509 {
188    Root {
189        certificate: DerVec,
190        signature_algorithm: DerVec,
191        signature: Vec<u8>,
192    },
193    Leaf {
194        issuer_id: Identifier,
195        certificate: DerVec,
196        signature_algorithm: DerVec,
197        signature: Vec<u8>,
198    },
199}
200
201/// Request to renew AutoId.
202#[derive(Debug, Decode, Encode, TypeInfo, PartialEq, Eq, Clone, DecodeWithMemTracking)]
203pub enum RenewAutoId {
204    X509(RenewX509Certificate),
205}
206
207/// Type holds X509 certificate details used to renew.
208#[derive(Debug, Decode, Encode, TypeInfo, PartialEq, Eq, Clone, DecodeWithMemTracking)]
209pub struct RenewX509Certificate {
210    issuer_id: Option<Identifier>,
211    certificate: DerVec,
212    signature_algorithm: DerVec,
213    signature: Vec<u8>,
214}
215
216/// Signature holds algorithm used and the signature value.
217#[derive(Debug, Decode, Encode, TypeInfo, PartialEq, Eq, Clone, DecodeWithMemTracking)]
218pub struct Signature {
219    pub signature_algorithm: DerVec,
220    pub value: Vec<u8>,
221}
222
223/// Request to register a new AutoId.
224#[derive(Debug, Decode, Encode, TypeInfo, PartialEq, Eq, Clone, DecodeWithMemTracking)]
225pub enum RegisterAutoId {
226    X509(RegisterAutoIdX509),
227}
228
229/// Specific action type taken by the subject of the Certificate.
230#[derive(Debug, Decode, Encode, TypeInfo, PartialEq, Eq, Clone)]
231pub enum CertificateActionType {
232    RevokeCertificate,
233    DeactivateAutoId,
234}
235
236/// Signing data used to verify the certificate action.
237#[derive(Debug, Decode, Encode, TypeInfo, PartialEq, Eq, Clone)]
238pub struct CertificateAction {
239    /// On which AutoId the action is taken.
240    pub id: Identifier,
241    /// Current nonce of the certificate.
242    pub nonce: U256,
243    /// Type of action taken.
244    pub action_type: CertificateActionType,
245}
246
247#[frame_support::pallet]
248mod pallet {
249    use super::*;
250    use crate::weights::WeightInfo;
251    use crate::{AutoId, Identifier, RegisterAutoId, Serial, Signature};
252    use frame_support::pallet_prelude::*;
253    use frame_support::traits::Time;
254    use frame_system::pallet_prelude::*;
255
256    #[pallet::config]
257    pub trait Config: frame_system::Config<RuntimeEvent: From<Event<Self>>> {
258        type Time: Time<Moment = subspace_runtime_primitives::Moment>;
259        type Weights: WeightInfo;
260    }
261
262    #[pallet::pallet]
263    #[pallet::without_storage_info]
264    pub struct Pallet<T>(_);
265
266    /// Stores the auto id identifier against an AutoId.
267    #[pallet::storage]
268    pub(super) type AutoIds<T> = StorageMap<_, Identity, Identifier, AutoId, OptionQuery>;
269
270    /// Stores list of revoked certificates.
271    ///
272    /// It maps the issuer's identifier to the list of revoked serial numbers of certificates. Before accepting
273    /// the certificate, external entities should check if the certificate or its issuer has been revoked.
274    #[pallet::storage]
275    pub(super) type CertificateRevocationList<T> =
276        StorageMap<_, Identity, Identifier, BTreeSet<Serial>, OptionQuery>;
277
278    #[pallet::error]
279    pub enum Error<T> {
280        /// Issuer auto id does not exist.
281        UnknownIssuer,
282        /// Unknown AutoId identifier.
283        UnknownAutoId,
284        /// Certificate is invalid,
285        InvalidCertificate,
286        /// Invalid signature.
287        InvalidSignature,
288        /// Certificate serial already issued.
289        CertificateSerialAlreadyIssued,
290        /// Certificate expired.
291        ExpiredCertificate,
292        /// Certificate revoked.
293        CertificateRevoked,
294        /// Certificate already revoked.
295        CertificateAlreadyRevoked,
296        /// Nonce overflow.
297        NonceOverflow,
298        /// Identifier already exists.
299        AutoIdIdentifierAlreadyExists,
300        /// Identifier mismatch.
301        AutoIdIdentifierMismatch,
302        /// Public key mismatch.
303        PublicKeyMismatch,
304    }
305
306    #[pallet::event]
307    #[pallet::generate_deposit(pub (super) fn deposit_event)]
308    pub enum Event<T: Config> {
309        /// Emits when a new AutoId is registered.
310        NewAutoIdRegistered(Identifier),
311        /// Emits when a Certificate associated with AutoId is revoked.
312        CertificateRevoked(Identifier),
313        /// Emits when an AutoId is deactivated.
314        AutoIdDeactivated(Identifier),
315        /// Emits when an AutoId is renewed.
316        AutoIdRenewed(Identifier),
317    }
318
319    #[pallet::call]
320    impl<T: Config> Pallet<T> {
321        /// Registers a new AutoId after validating the provided certificate.
322        #[pallet::call_index(0)]
323        #[pallet::weight(Pallet::<T>::max_register_auto_id_weight())]
324        pub fn register_auto_id(
325            origin: OriginFor<T>,
326            req: RegisterAutoId,
327        ) -> DispatchResultWithPostInfo {
328            ensure_signed(origin)?;
329            Self::do_register_auto_id(req)
330        }
331
332        /// Revokes a certificate associated with given AutoId.
333        ///
334        /// The signature is verified against the issuer's public key.
335        #[pallet::call_index(1)]
336        #[pallet::weight(Pallet::<T>::max_revoke_auto_id_weight())]
337        pub fn revoke_certificate(
338            origin: OriginFor<T>,
339            auto_id_identifier: Identifier,
340            signature: Signature,
341        ) -> DispatchResultWithPostInfo {
342            ensure_signed(origin)?;
343            Self::do_revoke_certificate(auto_id_identifier, signature)
344        }
345
346        /// Deactivates a given AutoId.
347        #[pallet::call_index(2)]
348        #[pallet::weight(<T as Config>::Weights::deactivate_auto_id())]
349        pub fn deactivate_auto_id(
350            origin: OriginFor<T>,
351            auto_id_identifier: Identifier,
352            signature: Signature,
353        ) -> DispatchResult {
354            ensure_signed(origin)?;
355            Self::do_deactivate_auto_id(auto_id_identifier, signature)?;
356            Ok(())
357        }
358
359        /// Renews a given AutoId.
360        #[pallet::call_index(3)]
361        #[pallet::weight(Pallet::<T>::max_renew_auto_id_weight())]
362        pub fn renew_auto_id(
363            origin: OriginFor<T>,
364            auto_id_identifier: Identifier,
365            req: RenewAutoId,
366        ) -> DispatchResultWithPostInfo {
367            ensure_signed(origin)?;
368            Self::do_renew_auto_id_certificate(auto_id_identifier, req)
369        }
370    }
371}
372
373impl<T: Config> Pallet<T> {
374    pub(crate) fn do_register_auto_id(req: RegisterAutoId) -> DispatchResultWithPostInfo {
375        let current_time = T::Time::now();
376        let (certificate, weight) = match req {
377            RegisterAutoId::X509(x509_req) => match x509_req {
378                RegisterAutoIdX509::Root {
379                    certificate,
380                    signature_algorithm,
381                    signature,
382                } => {
383                    let tbs_certificate = decode_tbs_certificate(certificate.clone())
384                        .ok_or(Error::<T>::InvalidCertificate)?;
385                    let req = SignatureVerificationRequest {
386                        public_key_info: tbs_certificate.subject_public_key_info.clone(),
387                        signature_algorithm,
388                        data: certificate.0.clone(),
389                        signature,
390                    };
391                    verify_signature(req).ok_or(Error::<T>::InvalidSignature)?;
392
393                    ensure!(
394                        tbs_certificate.validity.is_valid_at(current_time),
395                        Error::<T>::ExpiredCertificate
396                    );
397
398                    (
399                        Certificate::X509(X509Certificate {
400                            issuer_id: None,
401                            serial: tbs_certificate.serial,
402                            subject_common_name: tbs_certificate.subject_common_name,
403                            subject_public_key_info: tbs_certificate.subject_public_key_info,
404                            validity: tbs_certificate.validity,
405                            raw: certificate,
406                            issued_serials: BTreeSet::from([tbs_certificate.serial]),
407                            nonce: U256::zero(),
408                        }),
409                        T::Weights::register_issuer_auto_id(),
410                    )
411                }
412                RegisterAutoIdX509::Leaf {
413                    issuer_id,
414                    certificate,
415                    signature_algorithm,
416                    signature,
417                } => {
418                    let mut issuer_auto_id =
419                        AutoIds::<T>::get(issuer_id).ok_or(Error::<T>::UnknownIssuer)?;
420                    let issuer_public_key_info =
421                        issuer_auto_id.certificate.subject_public_key_info();
422
423                    ensure!(
424                        issuer_auto_id.certificate.is_valid_at(current_time),
425                        Error::<T>::ExpiredCertificate
426                    );
427
428                    let tbs_certificate = decode_tbs_certificate(certificate.clone())
429                        .ok_or(Error::<T>::InvalidCertificate)?;
430
431                    let req = SignatureVerificationRequest {
432                        public_key_info: issuer_public_key_info,
433                        signature_algorithm,
434                        data: certificate.0.clone(),
435                        signature,
436                    };
437                    verify_signature(req).ok_or(Error::<T>::InvalidSignature)?;
438                    ensure!(
439                        tbs_certificate.validity.is_valid_at(current_time),
440                        Error::<T>::ExpiredCertificate
441                    );
442
443                    ensure!(
444                        !CertificateRevocationList::<T>::get(issuer_id).is_some_and(|serials| {
445                            serials.iter().any(|s| {
446                                *s == issuer_auto_id.certificate.serial()
447                                    || *s == tbs_certificate.serial
448                            })
449                        }),
450                        Error::<T>::CertificateRevoked
451                    );
452
453                    issuer_auto_id
454                        .certificate
455                        .issue_certificate_serial::<T>(tbs_certificate.serial)?;
456
457                    AutoIds::<T>::insert(issuer_id, issuer_auto_id);
458
459                    (
460                        Certificate::X509(X509Certificate {
461                            issuer_id: Some(issuer_id),
462                            serial: tbs_certificate.serial,
463                            subject_common_name: tbs_certificate.subject_common_name,
464                            subject_public_key_info: tbs_certificate.subject_public_key_info,
465                            validity: tbs_certificate.validity,
466                            raw: certificate,
467                            issued_serials: BTreeSet::from([tbs_certificate.serial]),
468                            nonce: U256::zero(),
469                        }),
470                        T::Weights::register_leaf_auto_id(),
471                    )
472                }
473            },
474        };
475
476        let auto_id_identifier = certificate.derive_identifier();
477        let auto_id = AutoId { certificate };
478
479        ensure!(
480            !AutoIds::<T>::contains_key(auto_id_identifier),
481            Error::<T>::AutoIdIdentifierAlreadyExists
482        );
483
484        AutoIds::<T>::insert(auto_id_identifier, auto_id);
485
486        Self::deposit_event(Event::<T>::NewAutoIdRegistered(auto_id_identifier));
487        Ok(Some(weight).into())
488    }
489
490    fn do_renew_auto_id_certificate(
491        auto_id_identifier: Identifier,
492        req: RenewAutoId,
493    ) -> DispatchResultWithPostInfo {
494        let current_time = T::Time::now();
495        let auto_id = AutoIds::<T>::get(auto_id_identifier).ok_or(Error::<T>::UnknownAutoId)?;
496        let RenewAutoId::X509(req) = req;
497        let tbs_certificate = decode_tbs_certificate(req.certificate.clone())
498            .ok_or(Error::<T>::InvalidCertificate)?;
499
500        let (issuer_public_key_info, weight) = match req.issuer_id {
501            None => {
502                // revoke old certificate serial
503                CertificateRevocationList::<T>::mutate(auto_id_identifier, |serials| {
504                    serials
505                        .get_or_insert_with(BTreeSet::new)
506                        .insert(auto_id.certificate.serial());
507                });
508                (
509                    auto_id.certificate.subject_public_key_info(),
510                    T::Weights::renew_issuer_auto_id(),
511                )
512            }
513            Some(issuer_id) => {
514                let mut issuer_auto_id =
515                    AutoIds::<T>::get(issuer_id).ok_or(Error::<T>::UnknownIssuer)?;
516                let issuer_public_key_info = issuer_auto_id.certificate.subject_public_key_info();
517                ensure!(
518                    issuer_auto_id.certificate.is_valid_at(current_time),
519                    Error::<T>::ExpiredCertificate
520                );
521                ensure!(
522                    !CertificateRevocationList::<T>::get(issuer_id).is_some_and(|serials| {
523                        serials.iter().any(|s| {
524                            *s == issuer_auto_id.certificate.serial()
525                                || *s == tbs_certificate.serial
526                        })
527                    }),
528                    Error::<T>::CertificateRevoked
529                );
530
531                issuer_auto_id
532                    .certificate
533                    .issue_certificate_serial::<T>(tbs_certificate.serial)?;
534
535                // revoke old certificate serial
536                CertificateRevocationList::<T>::mutate(issuer_id, |serials| {
537                    serials
538                        .get_or_insert_with(BTreeSet::new)
539                        .insert(auto_id.certificate.serial());
540                });
541
542                AutoIds::<T>::insert(issuer_id, issuer_auto_id);
543                (issuer_public_key_info, T::Weights::renew_leaf_auto_id())
544            }
545        };
546
547        let signature_req = SignatureVerificationRequest {
548            public_key_info: issuer_public_key_info,
549            signature_algorithm: req.signature_algorithm,
550            data: req.certificate.0.clone(),
551            signature: req.signature,
552        };
553        verify_signature(signature_req).ok_or(Error::<T>::InvalidSignature)?;
554        ensure!(
555            tbs_certificate.validity.is_valid_at(current_time),
556            Error::<T>::ExpiredCertificate
557        );
558
559        ensure!(
560            auto_id.certificate.subject_public_key_info()
561                == tbs_certificate.subject_public_key_info,
562            Error::<T>::PublicKeyMismatch
563        );
564
565        let updated_certificate = Certificate::X509(X509Certificate {
566            issuer_id: req.issuer_id,
567            serial: tbs_certificate.serial,
568            subject_common_name: tbs_certificate.subject_common_name,
569            subject_public_key_info: tbs_certificate.subject_public_key_info,
570            validity: tbs_certificate.validity,
571            raw: req.certificate,
572            issued_serials: auto_id.certificate.issued_serials(),
573            nonce: auto_id.certificate.nonce(),
574        });
575
576        ensure!(
577            auto_id_identifier == updated_certificate.derive_identifier(),
578            Error::<T>::AutoIdIdentifierMismatch
579        );
580
581        let updated_auto_id = AutoId {
582            certificate: updated_certificate,
583        };
584
585        AutoIds::<T>::insert(auto_id_identifier, updated_auto_id);
586
587        Self::deposit_event(Event::<T>::AutoIdRenewed(auto_id_identifier));
588        Ok(Some(weight).into())
589    }
590
591    fn do_verify_signature(
592        auto_id: &AutoId,
593        signing_data: CertificateAction,
594        signature: Signature,
595    ) -> DispatchResult {
596        let Signature {
597            signature_algorithm,
598            value: signature,
599        } = signature;
600        let req = SignatureVerificationRequest {
601            public_key_info: auto_id.certificate.subject_public_key_info(),
602            signature_algorithm,
603            data: signing_data.encode(),
604            signature,
605        };
606
607        verify_signature(req).ok_or(Error::<T>::InvalidSignature)?;
608        Ok(())
609    }
610
611    fn do_revoke_certificate(
612        auto_id_identifier: Identifier,
613        signature: Signature,
614    ) -> DispatchResultWithPostInfo {
615        let auto_id = AutoIds::<T>::get(auto_id_identifier).ok_or(Error::<T>::UnknownAutoId)?;
616
617        let (issuer_id, mut issuer_auto_id, weight) = match auto_id.certificate.issuer_id() {
618            Some(issuer_id) => (
619                issuer_id,
620                AutoIds::<T>::get(issuer_id).ok_or(Error::<T>::UnknownIssuer)?,
621                T::Weights::revoke_leaf_auto_id(),
622            ),
623            // self revoke
624            None => (
625                auto_id_identifier,
626                auto_id.clone(),
627                T::Weights::revoke_issuer_auto_id(),
628            ),
629        };
630
631        ensure!(
632            !CertificateRevocationList::<T>::get(issuer_id).is_some_and(|serials| {
633                serials.iter().any(|s| {
634                    *s == auto_id.certificate.serial() || *s == issuer_auto_id.certificate.serial()
635                })
636            }),
637            Error::<T>::CertificateAlreadyRevoked
638        );
639
640        Self::do_verify_signature(
641            &issuer_auto_id,
642            CertificateAction {
643                id: auto_id_identifier,
644                nonce: issuer_auto_id.certificate.nonce(),
645                action_type: CertificateActionType::RevokeCertificate,
646            },
647            signature,
648        )?;
649
650        CertificateRevocationList::<T>::mutate(issuer_id, |serials| {
651            serials
652                .get_or_insert_with(BTreeSet::new)
653                .insert(auto_id.certificate.serial());
654        });
655
656        issuer_auto_id.certificate.inc_nonce::<T>()?;
657        AutoIds::<T>::insert(issuer_id, issuer_auto_id);
658
659        Self::deposit_event(Event::<T>::CertificateRevoked(auto_id_identifier));
660        Ok(Some(weight).into())
661    }
662
663    fn do_deactivate_auto_id(
664        auto_id_identifier: Identifier,
665        signature: Signature,
666    ) -> DispatchResult {
667        let auto_id = AutoIds::<T>::get(auto_id_identifier).ok_or(Error::<T>::UnknownIssuer)?;
668        Self::do_verify_signature(
669            &auto_id,
670            CertificateAction {
671                id: auto_id_identifier,
672                nonce: auto_id.certificate.nonce(),
673                action_type: CertificateActionType::DeactivateAutoId,
674            },
675            signature,
676        )?;
677
678        // TODO: remove all the AutoIds registered using leaf certificates if this is the issuer.
679        AutoIds::<T>::remove(auto_id_identifier);
680
681        Self::deposit_event(Event::<T>::AutoIdDeactivated(auto_id_identifier));
682        Ok(())
683    }
684
685    fn max_register_auto_id_weight() -> Weight {
686        T::Weights::register_issuer_auto_id().max(T::Weights::register_leaf_auto_id())
687    }
688
689    fn max_revoke_auto_id_weight() -> Weight {
690        T::Weights::revoke_issuer_auto_id().max(T::Weights::revoke_leaf_auto_id())
691    }
692
693    fn max_renew_auto_id_weight() -> Weight {
694        T::Weights::renew_issuer_auto_id().max(T::Weights::renew_leaf_auto_id())
695    }
696}