@@ -14,7 +14,7 @@ use concordium_base::{
1414 contracts_common:: AccountAddress ,
1515 id:: {
1616 constants:: { ArCurve , IpPairing } ,
17- types:: { ArInfos , IpIdentity } ,
17+ types:: { ArInfo , ArInfos , CredentialValidity , IpIdentity , IpInfo } ,
1818 } ,
1919 web3id,
2020} ;
@@ -150,50 +150,61 @@ pub async fn verify_credential_metadata(
150150 }
151151
152152 CredentialMetadata :: Identity { issuer, validity } => {
153-
154153 // get all the identity providers at current block
155154 let identity_providers = client. get_identity_providers ( bi) . await ?
156155 . response
157156 . try_collect :: < Vec < _ > > ( )
158157 . map_err ( |_e| CredentialLookupError :: InvalidResponse ( "Error getting identity providers" . into ( ) ) )
159158 . await ?;
160159
161- // find the matching identity provider info
162- let matching_idp = identity_providers. iter ( )
163- . find ( |idp| {
164- idp. ip_identity . 0 == issuer. 0
165- } )
166- . ok_or ( CredentialLookupError :: InvalidResponse ( "Error occurred while getting matching identity provider" . into ( ) ) ) ?;
167-
168160 // get anonymity revokers
169161 let anonymity_revokers = client. get_anonymity_revokers ( bi) . await ?. response
170162 . try_collect :: < Vec < _ > > ( )
171163 . map_err ( |_e|
172164 CredentialLookupError :: InvalidResponse ( "Error while getting annonymity revokers." . into ( ) ,
173165 ) )
174166 . await ?;
167+
168+ let now = client. get_block_info ( bi) . await ?. response . block_slot_time ;
175169
176- // create a new BTreeMap to hold the Anonymity revoker identity -> the anonymity revoker info
177- let mut anonymity_revoker_infos = BTreeMap :: new ( ) ;
170+ // call verify now for the data gathered
171+ verify_identity_credential_metadata ( now, issuer, identity_providers, anonymity_revokers, validity)
172+ }
173+ }
174+ }
178175
179- for ar in anonymity_revokers {
180- anonymity_revoker_infos. insert ( ar. ar_identity , ar) ;
181- }
176+ /// verify metadata for an identity
177+ fn verify_identity_credential_metadata (
178+ utc_time : DateTime < Utc > ,
179+ issuer : IpIdentity ,
180+ identity_providers : Vec < IpInfo < IpPairing > > ,
181+ anonymity_revokers : Vec < ArInfo < ArCurve > > ,
182+ validity : CredentialValidity
183+ ) -> Result < CredentialWithMetadata , CredentialLookupError > {
184+ // get the matching identity provider
185+ let matching_idp = identity_providers. iter ( )
186+ . find ( |idp| {
187+ idp. ip_identity . 0 == issuer. 0
188+ } )
189+ . ok_or ( CredentialLookupError :: InvalidResponse ( "Error occurred while getting matching identity provider" . into ( ) ) ) ?;
182190
183- // build inputs
184- let inputs = CredentialsInputs :: Identity { ip_info : matching_idp . clone ( ) , ars_infos : ArInfos { anonymity_revokers : anonymity_revoker_infos } } ;
191+ // create a new BTreeMap to hold the Anonymity revoker identity -> the anonymity revoker info
192+ let mut anonymity_revoker_infos = BTreeMap :: new ( ) ;
185193
186- // Credential Status handling
187- let now = client. get_block_info ( bi) . await ?. response . block_slot_time ;
194+ for ar in anonymity_revokers {
195+ anonymity_revoker_infos. insert ( ar. ar_identity , ar) ;
196+ }
188197
189- let valid_to = validity . valid_to . upper ( )
190- . ok_or ( CredentialLookupError :: InvalidResponse ( "Error while getting annonymity revokers." . into ( ) ) ) ? ;
198+ // build inputs
199+ let inputs = CredentialsInputs :: Identity { ip_info : matching_idp . clone ( ) , ars_infos : ArInfos { anonymity_revokers : anonymity_revoker_infos } } ;
191200
192- let credential_status = determine_credential_status_valid_to ( now, valid_to) ;
201+ // Credential Status handling
202+ let valid_to = validity. valid_to . upper ( )
203+ . ok_or ( CredentialLookupError :: InvalidResponse ( "Error while getting annonymity revokers." . into ( ) ) ) ?;
193204
194- Ok ( CredentialWithMetadata { inputs : inputs , status : credential_status } )
195- }
196- }
205+ let credential_status = determine_credential_status_valid_to ( utc_time , valid_to ) ;
206+
207+ Ok ( CredentialWithMetadata { inputs : inputs , status : credential_status } )
197208}
198209
199210/// determine the credential status where both the valid from and valid to is provided
0 commit comments