Skip to content

Commit def3372

Browse files
authored
Merge pull request #583 from Concordium/vp-v1/naming-alignment
Vp v1/naming alignment
2 parents c4768a9 + af3e6ec commit def3372

23 files changed

+980
-317
lines changed

docs/pages/verifiable-presentations.md

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ This document describes how to create v1 verifiable presentations and how to ver
77
- [Build Statement](#build-statement)
88
- [Identity/account credential statements](#identityaccount-credential-statements)
99
- [JSON representation](#json-representation)
10-
- [Verifiable Presentation Request (proof request)](#verifiable-presentation-request-proof-request)
11-
- [Verifiable Presentation (proof)](#verifiable-presentation-proof)
10+
- [Verification Request](#verification-request)
11+
- [Verifiable Presentation](#verifiable-presentation)
1212
- [Verifiable Audit Record](#verifiable-audit-record)
1313
<!--toc:end-->
1414

@@ -131,7 +131,7 @@ Note that this type of statement is only allowed for the following attributes:
131131

132132
## JSON representation
133133

134-
The `VerifiablePresentationRequestV1`, `VerifiablePresentationV1`, and `VerifiableAuditRecordV1` can be represented as
134+
The `VerificationRequestV1`, `VerifiablePresentationV1`, and `VerifiableAuditRecordV1` can be represented as
135135
JSON by calling the associated `.toJSON` method (will also be called implicitly with `JSON.stringify`). Correspondingly,
136136
parsing the JSON values can be done with the `.fromJSON` function exposed for each type.
137137

@@ -142,13 +142,13 @@ Example: service serializes presentation request in response to frontend; fronte
142142
```ts
143143
const json = JSON.stringify(presentationRequest); // service sends back presentation request to frontend
144144
...
145-
const presentationRequest = VerifiablePresentationRequestV1.fromJSON(JSON.parse(json)); // frontend parses the JSON.
145+
const presentationRequest = VerificationRequestV1.fromJSON(JSON.parse(json)); // frontend parses the JSON.
146146
```
147147

148-
## Verifiable Presentation Request (proof request)
148+
## Verification Request
149149

150150
To get a _verifiable presentation_ of one or more _verifiable credentials_ owned by a user, the entity requesting
151-
the information must first build a _verifiable presentation request_. In the V1 protocol, this is done in the following
151+
the information must first build a _verification request_. In the V1 protocol, this is done in the following
152152
sequence:
153153

154154
1. Make the _request context_, consisting of
@@ -166,9 +166,9 @@ Once this is done, the request must be _anchored_ on chain with a transaction. T
166166
const nonce = Uint8Array.from(...) // randomly generated 32-byte value
167167
const connectionID = ... // e.g. a wallet-connect ID
168168
const contextString = 'My compliant web3 wine shop'
169-
const context = VerifiablePresentationRequestV1.createSimpleContext(nonce, connectionID, contextString)
169+
const context = VerificationRequestV1.createSimpleContext(nonce, connectionID, contextString)
170170

171-
const statement = new VerifiablePresentationRequestV1.statementBuilder()...
171+
const statement = new VerificationRequestV1.statementBuilder()...
172172

173173
// a GRPC client connected a node on the network the anchor should be registered on
174174
const grpcClient: ConcordiumGRPCClient = ...;
@@ -177,8 +177,8 @@ const sender: AccountAddress.Type = ...;
177177
// the keys for the account to sign the anchor transaction
178178
const signer: Signer = ...;
179179

180-
// create the presentation request with an on-chain anchor, which can be checked by the owner of the credentials.
181-
const presentationRequest = await VerifiablePresentationRequestV1.createAndAchor(
180+
// create the verification request with an on-chain anchor, which can be checked by the owner of the credentials.
181+
const verificationRequest = await VerificationRequestV1.createAndAchor(
182182
grpcClient,
183183
sender,
184184
signer,
@@ -187,24 +187,24 @@ const presentationRequest = await VerifiablePresentationRequestV1.createAndAchor
187187
);
188188
```
189189

190-
## Verifiable Presentation (proof)
190+
## Verifiable Presentation
191191

192192
Computing a _verifiable presentation_ from a _verifiable presentation request_ is a process of the following sequence
193193
for each credential statement in the request:
194194

195-
1. Identify valid credentials for the statement by looking at the ID qualifier of the `VerfiablePresentationRequest.Statement`.
195+
1. Identify valid credentials for the statement by looking at the ID qualifier of the `VerificationRequestV1.Statement`.
196196
2. Validate the attributes of the credential in the context of the statement.
197197
3. Construct a `VerifiablePresentationV1.Statement` corresponding to the credential. This is is _not_ the same as the
198-
`VerfiablePresentationRequest.Statement` we built for the `VerfiablePresentationRequest` previously; here we're working with
198+
`VerificationRequestV1.Statement` we built for the `VerificationRequestV1` previously; here we're working with
199199
a specific credential, e.g. from the users wallet.
200-
a. for `VerfiablePresentationRequest.IdentityStatement`s, the `source` also needs to be taken into account. This
200+
a. for `VerificationRequestV1.IdentityStatement`s, the `source` also needs to be taken into account. This
201201
specifies the type of credential requested by the dapp. This can either be set to
202202
`["Identity"] | ["Account"] | ["Identity", "Account"]`, where the latter means that the application constructing
203203
the proof can decide which proof to construct for the statement.
204204

205205
When this is done for all credential statements in the request, we construct the _proof context_ corresponding to the
206206
_request context_ of the request, specifying values for each requested context value in
207-
`VerifiablePresentationRequestV1.Context.requested`.
207+
`VerificationRequestV1.Context.requested`.
208208

209209
```ts
210210
// specify the resource ID (e.g. website URL or fingerprint of TLS certificate that the wallet is connected to)
@@ -213,14 +213,14 @@ _request context_ of the request, specifying values for each requested context v
213213
// request.
214214
const contextValues: GivenContext[] = [{label: 'ResourceID', context: ...}];
215215

216-
// The application goes through each statement in the presentation request, and constructs a corresponding statement
216+
// The application goes through each statement in the verification request, and constructs a corresponding statement
217217
// used as input to the presentation. The difference between the two statement types boil down to the presence of an ID
218218
// qualifier vs. an ID (selected by the application based on the id qualifier).
219-
const statements: VerifiablePresentationV1.Statement[] = presentationRequest.credentialStatements.map((entry) => {
219+
const statements: VerifiablePresentationV1.SubjectClaims[] = verificationRequest.credentialStatements.map((entry) => {
220220
// prioritize creating identity based proofs, as these are more privacy-preserving
221221
if (entry.source.includes('identity'))
222-
return {id: createIdentityStatementDID(...), statement: entry.statement};
223-
return {id: createAccountDID(...), statement: entry.statement};
222+
return VerifiablePresentationV1.createIdentityClaims(..., entry.statement);
223+
return VerifiablePresentation.createAccountClaims(..., entry.statement);
224224
});
225225

226226
// the inputs for the credential owned by the user, i.e. credential attribute values. For each
@@ -232,24 +232,24 @@ const inputs: CommitmentInput[] = [
232232

233233
const presentation = await VerifiablePresentationV1.createFromAnchor(
234234
grpcClient,
235-
presentationRequest,
235+
verificationRequest,
236236
statements,
237237
inputs,
238238
contextValues
239239
);
240240

241241
// verify the presentation elsewhere
242-
const result = VerifiablePresentationV1.verifyWithNode(presentation, presentationRequest, grpcClient, network);
242+
const result = VerifiablePresentationV1.verifyWithNode(presentation, verificationRequest, grpcClient, network);
243243
```
244244

245245
## Verifiable Audit Record
246246

247-
Services can opt in to create a _verification audit record_ from the _verifiable presentation request_ and corresponding
247+
Services can opt in to create a _verification audit record_ from the _verification request_ and corresponding
248248
_verifiable presentation_. This exists as a record and a corresponding anchor. The record should be stored by the dapp backend (e.g. in a database),
249249
and the anchor should be registered on chain. The transacton hash of the anchor registration should be stored along the record.
250250

251251
```ts
252252
const uuid: string = ...;
253-
const record = VerificationAuditRecordV1.create(uuid, presentationRequest, presentation);
253+
const record = VerificationAuditRecordV1.create(uuid, verificationRequest, presentation);
254254
const anchorTransactionHash = await VerificationAuditRecordV1.registerAnchor(record, grpcClient, sender, signer);
255255
```

examples/nodejs/common/verifiable-credential-statements.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { IdentityProviderDID, VerifiablePresentationRequestV1 } from '@concordium/web-sdk';
1+
import { IdentityProviderDID, VerificationRequestV1 } from '@concordium/web-sdk';
22

33
// #region documentation-snippet
4-
let builder = VerifiablePresentationRequestV1.statementBuilder();
4+
let builder = VerificationRequestV1.statementBuilder();
55

66
// Add an identity credential statement. Alternatively, if the proof produced from the
77
// statement should be tied to an account, use `builder.addAccountStatement`.

examples/nodejs/proofs/verifiable-presentation-id-cred.ts

Lines changed: 20 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ import {
44
IdentityObjectV1,
55
IdentityProvider,
66
IdentityProviderDID,
7-
VerifiablePresentationRequestV1,
87
VerifiablePresentationV1,
98
VerificationAuditRecordV1,
9+
VerificationRequestV1,
1010
createIdentityCommitmentInputWithHdWallet,
11-
createIdentityStatementDID,
1211
sha256,
1312
streamToList,
1413
} from '@concordium/web-sdk';
@@ -118,35 +117,30 @@ const grpc = new ConcordiumGRPCNodeClient(
118117

119118
const [sender, signer] = parseKeysFile(walletFile);
120119

121-
// First we generate the presentation request.
120+
// First we generate the verification request.
122121
//
123122
// This will normally happen server-side.
124-
const context = VerifiablePresentationRequestV1.createSimpleContext(
123+
const context = VerificationRequestV1.createSimpleContext(
125124
sha256([Buffer.from(Date.now().toString())]),
126125
randomUUID(),
127126
'Example VP'
128127
);
129-
const statements = VerifiablePresentationRequestV1.statementBuilder()
128+
const statements = VerificationRequestV1.statementBuilder()
130129
.addAccountOrIdentityStatement([new IdentityProviderDID(network, identityProviderIndex)], (b) => {
131130
b.addEUResidency();
132131
b.addMinimumAge(18);
133132
})
134133
.getStatements();
135-
const presentationRequest = await VerifiablePresentationRequestV1.createAndAchor(
136-
grpc,
137-
sender,
138-
signer,
139-
context,
140-
statements,
141-
{ info: 'Example VP anchor' }
142-
);
134+
const verificationRequest = await VerificationRequestV1.createAndAchor(grpc, sender, signer, context, statements, {
135+
info: 'Example VP anchor',
136+
});
143137

144-
console.log('PRESENTATION REQUEST: \n', JSONBig.stringify(presentationRequest, null, 2), '\n');
138+
console.log('VERIFICATION REQUEST: \n', JSONBig.stringify(verificationRequest, null, 2), '\n');
145139

146-
// simulate sending a response to the client requesting the presentation request
147-
const requestJson = JSONBig.stringify(presentationRequest);
140+
// simulate sending a response to the client requesting the verification request
141+
const requestJson = JSONBig.stringify(verificationRequest);
148142

149-
// Then we create the presentation.
143+
// Then we create the verifiable presentation.
150144
//
151145
// This will normally happen in an application that holds the user credentials. In this example, the information
152146
// normally held by said application, i.e. the credential used, the idp index, and the id index, is passed as program
@@ -167,21 +161,17 @@ const arsInfos: Record<number, ArInfo> = ars.reduce((acc, ar) => {
167161
}, {});
168162
const idp: IdentityProvider = { ipInfo, arsInfos };
169163

170-
// simulate receiving presentation request
171-
const requestParsed = VerifiablePresentationRequestV1.fromJSON(JSONBig.parse(requestJson));
164+
// simulate receiving verification request
165+
const requestParsed = VerificationRequestV1.fromJSON(JSONBig.parse(requestJson));
172166
// At this point, we have all the values held inside the application.
173167
// From the above, we retreive the secret input which is at the core of creating the verifiable presentation (proof)
174-
const credentialInput = createIdentityCommitmentInputWithHdWallet(idObject, idp, identityIndex, wallet);
168+
const proofInput = createIdentityCommitmentInputWithHdWallet(idObject, idp, identityIndex, wallet);
175169

176170
// we select the identity to prove the statement for
177-
const selectedIdentity = createIdentityStatementDID(network); // we unwrap here, as we know the statement exists (we created it just above)
178171
const idStatement = requestParsed.credentialStatements.find(
179172
(s) => s.type === 'identity'
180-
)! as VerifiablePresentationRequestV1.IdentityStatement; // we unwrap here, as we know the statement exists (we created it just above)
181-
const specifiedStatement: VerifiablePresentationV1.IdentityStatement = {
182-
id: selectedIdentity,
183-
statement: idStatement.statement,
184-
};
173+
)! as VerificationRequestV1.IdentityStatement; // we unwrap here, as we know the statement exists (we created it just above)
174+
const claims = VerifiablePresentationV1.createIdentityClaims(network, idp.ipInfo.ipIdentity, idStatement.statement);
185175

186176
console.log('Waiting for anchor transaction to finalize:', requestParsed.transactionRef.toString());
187177

@@ -191,8 +181,8 @@ await grpc.waitForTransactionFinalization(requestParsed.transactionRef);
191181
const presentation = await VerifiablePresentationV1.createFromAnchor(
192182
grpc,
193183
requestParsed,
194-
[specifiedStatement],
195-
[credentialInput],
184+
[claims],
185+
[proofInput],
196186
[{ label: 'ResourceID', context: 'Example VP use-case' }]
197187
);
198188

@@ -204,11 +194,11 @@ console.log('PRESENTATION:\n', JSONBig.stringify(presentation, null, 2), '\n');
204194
// simulate receiving presentation to be verified
205195
const presentationParsed = VerifiablePresentationV1.fromJSON(JSONBig.parse(presentationJson));
206196

207-
if (!(await VerifiablePresentationV1.verifyWithNode(presentationParsed, presentationRequest, grpc, network)))
197+
if (!(await VerifiablePresentationV1.verifyWithNode(presentationParsed, verificationRequest, grpc, network)))
208198
throw new Error('Failed to verify the presentation');
209199

210200
// Finally, the entity requesting the proof stores the audit report and registers a pulic version on chain
211-
const report = VerificationAuditRecordV1.create(randomUUID(), presentationRequest, presentation);
201+
const report = VerificationAuditRecordV1.create(randomUUID(), verificationRequest, presentation);
212202
const auditTransaction = await VerificationAuditRecordV1.registerAnchor(report, grpc, sender, signer, {
213203
info: 'Some public info',
214204
});

packages/rust-bindings/ts-src/dapp.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ import wasmBase64 from '../lib/dapp/web/esm/index_bg.wasm';
77
// Expected to resolve to base64 encoded bytes of wasm module
88

99
const bytes = Buffer.from(wasmBase64, 'base64');
10-
initSync(bytes);
10+
initSync({ module: bytes });
1111

1212
export * from '../lib/dapp/web/esm/index.js';

packages/rust-bindings/ts-src/wallet.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ import wasmBase64 from '../lib/wallet/web/esm/index_bg.wasm';
77
// Expected to resolve to base64 encoded bytes of wasm module
88

99
const bytes = Buffer.from(wasmBase64, 'base64');
10-
initSync(bytes);
10+
initSync({ module: bytes });
1111

1212
export * from '../lib/wallet/web/esm/index.js';

packages/sdk/CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,25 @@
22

33
## Unreleased
44

5+
## 11.1.0-alpha.2
6+
7+
### Added
8+
9+
- `VerifiablePresentationV1.createAccountClaims` and `VerifiablePresentationV1.createIdentityClaims` to build the
10+
subject claims used as input for the `VerifiablePresentationV1.create...` functions.
11+
12+
### Changed
13+
14+
- `createIdentityStatementDID` now takes the index of the identity provider of the identity.
15+
- `VerifiablePresentationRequestV1` renamed to `VerificationRequestV1`
16+
17+
- `VerifiablePresentationV1.Statement` renamed to `VerifiablePresentationV1.SubjectClaims` to align with the w3c VC spec
18+
- `VerifiablePresentationV1.AccountStatement` -> `VerifiablePresentationV1.AccountClaims`, created with
19+
`VerifiablePresentation.createAccountClaims`.
20+
- `VerifiablePresentationV1.IdentityStatement` -> `VerifiablePresentationV1.IdentityClaims`, created with
21+
`VerifiablePresentation.createIdentityClaims`.
22+
- `VerifiablePresentationV1.CredentialInputs` renamed to `VerifiablePresentationV1.VerificationMaterial`.
23+
524
## 11.1.0-alpha.1
625

726
### Fixed

packages/sdk/src/wasm/VerifiablePresentationV1/audit-record.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
} from '../../types.js';
1414
import { cborDecode, cborEncode } from '../../types/cbor.js';
1515
import { AccountAddress, DataBlob, TransactionExpiry, TransactionHash } from '../../types/index.js';
16-
import { VerifiablePresentationRequestV1, VerifiablePresentationV1 } from './index.js';
16+
import { VerifiablePresentationV1, VerificationRequestV1 } from './index.js';
1717

1818
const JSONBig = _JB({ alwaysParseAsBig: true, useNativeBigInt: true });
1919

@@ -37,7 +37,7 @@ class VerificationAuditRecordV1 {
3737
* @param id - Unique identifier for this audit record
3838
*/
3939
constructor(
40-
public readonly request: VerifiablePresentationRequestV1.Type,
40+
public readonly request: VerificationRequestV1.Type,
4141
public readonly presentation: VerifiablePresentationV1.Type,
4242
public readonly id: string
4343
) {}
@@ -79,7 +79,7 @@ export type JSON = Pick<Type, 'id'> & {
7979
/** The audit record version */
8080
version: 1;
8181
/** The serialized verifiable presentation request */
82-
request: VerifiablePresentationRequestV1.JSON;
82+
request: VerificationRequestV1.JSON;
8383
/** The serialized verifiable presentation */
8484
presentation: VerifiablePresentationV1.JSON;
8585
};
@@ -95,7 +95,7 @@ export type JSON = Pick<Type, 'id'> & {
9595
*/
9696
export function create(
9797
id: string,
98-
request: VerifiablePresentationRequestV1.Type,
98+
request: VerificationRequestV1.Type,
9999
presentation: VerifiablePresentationV1.Type
100100
): VerificationAuditRecordV1 {
101101
return new VerificationAuditRecordV1(request, presentation, id);
@@ -109,7 +109,7 @@ export function create(
109109
*/
110110
export function fromJSON(json: JSON): VerificationAuditRecordV1 {
111111
return new VerificationAuditRecordV1(
112-
VerifiablePresentationRequestV1.fromJSON(json.request),
112+
VerificationRequestV1.fromJSON(json.request),
113113
VerifiablePresentationV1.fromJSON(json.presentation),
114114
json.id
115115
);

packages/sdk/src/wasm/VerifiablePresentationV1/index.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,14 @@
99
* - VerifiablePresentationRequestV1: For creating and managing presentation requests
1010
* - VerifiablePresentationV1: For creating and verifying presentations with ZK proofs
1111
* - VerificationAuditRecord: For public audit trails of verification events
12-
* - PrivateVerificationAuditRecord: For private audit records with full data
1312
*/
1413
import * as VerificationAuditRecordV1 from './audit-record.js';
1514
import * as VerifiablePresentationV1 from './proof.js';
16-
import * as VerifiablePresentationRequestV1 from './request.js';
15+
import * as VerificationRequestV1 from './request.js';
1716

1817
export {
19-
/** Namespace for verifiable presentation request operations */
20-
VerifiablePresentationRequestV1,
18+
/** Namespace for verification request operations */
19+
VerificationRequestV1,
2120
/** Namespace for verifiable presentation proof operations */
2221
VerifiablePresentationV1,
2322
/** Namespace for verification audit record operations */

0 commit comments

Comments
 (0)