@@ -22,13 +22,13 @@ import { bail } from '../../util.js';
2222import {
2323 AtomicStatementV2 ,
2424 CommitmentInput ,
25- CredentialRequestStatement ,
2625 CredentialsInputs ,
2726 DIDString ,
2827 IdentityCommitmentInput ,
29- IdentityCredentialRequestStatement ,
30- isAccountCredentialRequestStatement ,
31- isIdentityCredentialRequestStatement ,
28+ SpecifiedCredentialStatement ,
29+ SpecifiedIdentityCredentialStatement ,
30+ isSpecifiedAccountCredentialStatement ,
31+ isSpecifiedIdentityCredentialStatement ,
3232} from '../../web3-id/index.js' ;
3333import { Web3IdProofRequest , getVerifiablePresentation } from '../web3Id.js' ;
3434import { GivenContextJSON , givenContextFromJSON , givenContextToJSON } from './internal.js' ;
@@ -72,7 +72,7 @@ export type IdentityBasedCredential = {
7272} ;
7373
7474function createIdentityCredentialStub (
75- { id, statement } : IdentityCredentialRequestStatement ,
75+ { id, statement } : SpecifiedIdentityCredentialStatement ,
7676 ipIndex : number
7777) : IdentityBasedCredential {
7878 const network = id . split ( ':' ) [ 1 ] as Network ;
@@ -170,11 +170,11 @@ export function fromJSON(value: JSON): VerifiablePresentationV1 {
170170export async function createFromAnchor (
171171 grpc : ConcordiumGRPCClient ,
172172 presentationRequest : Request . Type ,
173- requestStatements : CredentialRequestStatement [ ] ,
173+ statements : SpecifiedCredentialStatement [ ] ,
174174 inputs : CommitmentInput [ ] ,
175- additionalContext : GivenContext [ ] ,
176- globalContext : CryptographicParameters
175+ additionalContext : GivenContext [ ]
177176) : Promise < VerifiablePresentationV1 > {
177+ const globalContext = await grpc . getCryptographicParameters ( ) ;
178178 const transaction = await grpc . getBlockItemStatus ( presentationRequest . transactionRef ) ;
179179 if ( transaction . status !== TransactionStatusEnum . Finalized ) {
180180 throw new Error ( 'anchor reference not finalized' ) ;
@@ -201,24 +201,24 @@ export async function createFromAnchor(
201201
202202 const blockContext : GivenContext = { label : 'BlockHash' , context : blockHash } ;
203203 const proofContext = createContext ( presentationRequest . requestContext , [ ...additionalContext , blockContext ] ) ;
204- return create ( requestStatements , inputs , proofContext , globalContext ) ;
204+ return create ( statements , inputs , proofContext , globalContext ) ;
205205}
206206
207207// TODO: this entire function should call a function in @concordium /rust-bindings to create the verifiable
208208// presentation from the function arguments. For now, we hack something together from the old protocol which
209209// means filtering and mapping the input/output.
210210export function create (
211- requestStatements : CredentialRequestStatement [ ] ,
211+ requestStatements : SpecifiedCredentialStatement [ ] ,
212212 inputs : CommitmentInput [ ] ,
213213 proofContext : Context ,
214214 globalContext : CryptographicParameters
215215) : VerifiablePresentationV1 {
216216 // first we filter out the id statements, as they're not compatible with the current implementation
217217 // in concordium-base
218- const idStatements : [ number , IdentityCredentialRequestStatement ] [ ] = [ ] ;
219- const compatibleStatements : Exclude < CredentialRequestStatement , IdentityCredentialRequestStatement > [ ] = [ ] ;
218+ const idStatements : [ number , SpecifiedIdentityCredentialStatement ] [ ] = [ ] ;
219+ const compatibleStatements : Exclude < SpecifiedCredentialStatement , SpecifiedIdentityCredentialStatement > [ ] = [ ] ;
220220 requestStatements . forEach ( ( s , i ) => {
221- if ( isIdentityCredentialRequestStatement ( s ) ) idStatements . push ( [ i , s ] ) ;
221+ if ( isSpecifiedIdentityCredentialStatement ( s ) ) idStatements . push ( [ i , s ] ) ;
222222 else compatibleStatements . push ( s ) ;
223223 } ) ;
224224
@@ -240,7 +240,7 @@ export function create(
240240 const compatibleCredentials : Credential [ ] = verifiableCredential . map < Credential > ( ( c , i ) => {
241241 const { proof, ...credentialSubject } = c . credentialSubject ;
242242 const { created, type : _type , ...proofValues } = proof ;
243- const type = isAccountCredentialRequestStatement ( compatibleStatements [ i ] )
243+ const type = isSpecifiedAccountCredentialStatement ( compatibleStatements [ i ] )
244244 ? 'ConcordiumAccountBasedCredential'
245245 : 'ConcordiumWeb3BasedCredential' ;
246246 return {
@@ -281,3 +281,12 @@ export function verify(
281281) : true | Error {
282282 return true ;
283283}
284+
285+ export async function verifyWithNode (
286+ presentation : VerifiablePresentationV1 ,
287+ request : Request . Type ,
288+ grpc : ConcordiumGRPCClient ,
289+ network : Network
290+ ) : Promise < true | Error > {
291+ return true ;
292+ }
0 commit comments