@trustvc/trustvc 2.0.7 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -155,7 +155,7 @@ const signedWrappedDocument = await signOA(wrappedDocument, {
|
|
|
155
155
|
|
|
156
156
|
#### b) TrustVC W3C Signing (signW3C)
|
|
157
157
|
|
|
158
|
-
The `signW3C` function signs W3C Verifiable Credentials using the provided cryptographic suite and key pair. By default, it uses the **ecdsa-sd-2023** crypto suite unless otherwise specified.
|
|
158
|
+
The `signW3C` function signs W3C Verifiable Credentials using the provided cryptographic suite and key pair. By default, it uses the **ecdsa-sd-2023** crypto suite unless otherwise specified. It also supports **bbs-2023** for modern BBS signatures.
|
|
159
159
|
|
|
160
160
|
```ts
|
|
161
161
|
import { signW3C, VerificationType } from '@trustvc/trustvc';
|
|
@@ -195,7 +195,7 @@ const signingResult = await signW3C(rawDocument, {
|
|
|
195
195
|
secretKeyMultibase: '<secretKeyMultibase>'
|
|
196
196
|
});
|
|
197
197
|
|
|
198
|
-
// You can also specify mandatory pointers for selective disclosure with ecdsa-sd-2023
|
|
198
|
+
// You can also specify mandatory pointers for selective disclosure with ecdsa-sd-2023 / bbs-2023
|
|
199
199
|
const signingResultWithPointers = await signW3C(
|
|
200
200
|
rawDocument,
|
|
201
201
|
{
|
|
@@ -212,7 +212,22 @@ const signingResultWithPointers = await signW3C(
|
|
|
212
212
|
}
|
|
213
213
|
);
|
|
214
214
|
|
|
215
|
-
//
|
|
215
|
+
// Using BBS-2023 cryptosuite
|
|
216
|
+
const signingResultWithBbs2023 = await signW3C(
|
|
217
|
+
rawDocument,
|
|
218
|
+
{
|
|
219
|
+
'@context': 'https://w3id.org/security/multikey/v1',
|
|
220
|
+
id: 'did:web:trustvc.github.io:did:1#multikey-2',
|
|
221
|
+
type: VerificationType.Multikey,
|
|
222
|
+
controller: 'did:web:trustvc.github.io:did:1',
|
|
223
|
+
publicKeyMultibase: 'zUC75kRac7BdtjawFUxowfgD6mzqnRHFxAfMDaBynebdYgakviQkPS1KNJEw7uGWqj91H3hSE4pTERb3EZKLgKXjpqHWrN8dyE8SKyPBE3k7kUGjBNAqJoNGgUzqUW3DSaWrcNr',
|
|
224
|
+
secretKeyMultibase: '<secretKeyMultibase>',
|
|
225
|
+
},
|
|
226
|
+
'bbs-2023'
|
|
227
|
+
);
|
|
228
|
+
|
|
229
|
+
// ⚠️ DEPRECATED: BbsBlsSignature2020 is no longer supported
|
|
230
|
+
// Use 'ecdsa-sd-2023 or bbs-2023' cryptosuite instead as shown above
|
|
216
231
|
const signingResultWithBbs = await signW3C(
|
|
217
232
|
rawDocument,
|
|
218
233
|
{
|
|
@@ -222,7 +237,7 @@ const signingResultWithBbs = await signW3C(
|
|
|
222
237
|
publicKeyBase58: 'oRfEeWFresvhRtXCkihZbxyoi2JER7gHTJ5psXhHsdCoU1MttRMi3Yp9b9fpjmKh7bMgfWKLESiK2YovRd8KGzJsGuamoAXfqDDVhckxuc9nmsJ84skCSTijKeU4pfAcxeJ',
|
|
223
238
|
privateKeyBase58: '<privateKeyBase58>',
|
|
224
239
|
},
|
|
225
|
-
'BbsBlsSignature2020'
|
|
240
|
+
'BbsBlsSignature2020' // This will return an error
|
|
226
241
|
);
|
|
227
242
|
|
|
228
243
|
```
|
|
@@ -231,7 +246,7 @@ const signingResultWithBbs = await signW3C(
|
|
|
231
246
|
|
|
232
247
|
### 3. **Deriving (Selective Disclosure)**
|
|
233
248
|
|
|
234
|
-
> When using ECDSA-SD-2023 crypto
|
|
249
|
+
> When using ECDSA-SD-2023 or BBS-2023 crypto suites, we can derive a new credential with selective disclosure. This means you can choose which parts of the credential to reveal while keeping others hidden.
|
|
235
250
|
|
|
236
251
|
```ts
|
|
237
252
|
import { deriveW3C } from '@trustvc/trustvc';
|
|
@@ -282,7 +297,7 @@ const derivationResult = await deriveW3C(signedDocument, {
|
|
|
282
297
|
|
|
283
298
|
### 4. **Verifying**
|
|
284
299
|
|
|
285
|
-
> TrustVC simplifies the verification process with a single function that supports both W3C Verifiable Credentials (VCs) and OpenAttestation Verifiable Documents (VDs). Whether you're working with W3C standards or OpenAttestation standards, TrustVC handles the verification seamlessly. For ECDSA-signed documents, which normally require derivation before verification, TrustVC automatically handles this process internally - if a document is not derived, the `verifyDocument` function will automatically derive and verify the document in a single step.
|
|
300
|
+
> TrustVC simplifies the verification process with a single function that supports both W3C Verifiable Credentials (VCs) and OpenAttestation Verifiable Documents (VDs). Whether you're working with W3C standards or OpenAttestation standards, TrustVC handles the verification seamlessly. For ECDSA-SD-2023 and BBS-2023 signed documents, which normally require derivation before verification, TrustVC automatically handles this process internally - if a document is not derived, the `verifyDocument` function will automatically derive and verify the document in a single step.
|
|
286
301
|
|
|
287
302
|
```ts
|
|
288
303
|
import { verifyDocument } from '@trustvc/trustvc';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PrivateKeyPair } from '@trustvc/w3c-issuer';
|
|
2
|
-
import { VerifiableCredential, CryptoSuiteName, SignedVerifiableCredential
|
|
2
|
+
import { VerifiableCredential, CryptoSuiteName, SignedVerifiableCredential } from '@trustvc/w3c-vc';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Configuration for a W3C Verifiable Document using a Bitstring Status List.
|
|
@@ -79,7 +79,7 @@ declare class DocumentBuilder {
|
|
|
79
79
|
renderMethod(method: RenderMethod): this;
|
|
80
80
|
qrCode(method: qrCode): this;
|
|
81
81
|
sign(privateKey: PrivateKeyPair, cryptoSuite?: CryptoSuiteName, options?: SignOptions): Promise<SignedVerifiableCredential>;
|
|
82
|
-
derive(revealedAttributes:
|
|
82
|
+
derive(revealedAttributes: string[]): Promise<SignedVerifiableCredential>;
|
|
83
83
|
verify(): Promise<boolean>;
|
|
84
84
|
toString(): string;
|
|
85
85
|
private isTransferableRecordsConfig;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { SignedVerifiableCredential,
|
|
1
|
+
import { SignedVerifiableCredential, DerivedResult } from '@trustvc/w3c-vc';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Derives a credential with selective disclosure based on revealed attributes.
|
|
5
5
|
* @param {object} credential - The verifiable credential to be selectively disclosed.
|
|
6
|
-
* @param {
|
|
6
|
+
* @param {string[]} revealedAttributes - Array of selective pointers.
|
|
7
7
|
* @returns {Promise<DerivedResult>} A DerivedResult containing the derived proof or an error message.
|
|
8
8
|
*/
|
|
9
|
-
declare const deriveW3C: (credential: SignedVerifiableCredential, revealedAttributes:
|
|
9
|
+
declare const deriveW3C: (credential: SignedVerifiableCredential, revealedAttributes: string[]) => Promise<DerivedResult>;
|
|
10
10
|
|
|
11
11
|
export { deriveW3C };
|
package/dist/types/w3c/sign.d.ts
CHANGED
|
@@ -6,8 +6,8 @@ import { PrivateKeyPair } from '@trustvc/w3c-issuer';
|
|
|
6
6
|
* @param {RawVerifiableCredential} credential - The verifiable credential object that needs to be signed.
|
|
7
7
|
* @param {PrivateKeyPair} keyPair - The private and public key pair used for signing the credential.
|
|
8
8
|
* @param {CryptoSuiteName} [cryptoSuite='ecdsa-sd-2023'] - The cryptographic suite to be used for signing (default is 'ecdsa-sd-2023').
|
|
9
|
-
* @param {object} [options] - Optional parameters including mandatoryPointers for ECDSA-SD-2023.
|
|
10
|
-
* @param {string[]} [options.mandatoryPointers] - Optional mandatory pointers for ECDSA-SD-2023.
|
|
9
|
+
* @param {object} [options] - Optional parameters including mandatoryPointers for both ECDSA-SD-2023 / BBS-2023.
|
|
10
|
+
* @param {string[]} [options.mandatoryPointers] - Optional mandatory pointers for both ECDSA-SD-2023 / BBS-2023.
|
|
11
11
|
* @returns {Promise<SigningResult>} A promise that resolves to the result of the signing operation, which includes the signed credential.
|
|
12
12
|
*/
|
|
13
13
|
declare const signW3C: (credential: RawVerifiableCredential, keyPair: PrivateKeyPair, cryptoSuite?: CryptoSuiteName, options?: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trustvc/trustvc",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "TrustVC library",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -122,11 +122,11 @@
|
|
|
122
122
|
"@tradetrust-tt/tradetrust": "^6.10.2",
|
|
123
123
|
"@tradetrust-tt/tradetrust-utils": "^2.4.2",
|
|
124
124
|
"@tradetrust-tt/tt-verify": "^9.6.0",
|
|
125
|
-
"@trustvc/w3c": "^1.3.0-alpha.
|
|
126
|
-
"@trustvc/w3c-context": "^1.3.0-alpha.
|
|
127
|
-
"@trustvc/w3c-credential-status": "^1.3.0-alpha.
|
|
128
|
-
"@trustvc/w3c-issuer": "^1.3.0-alpha.
|
|
129
|
-
"@trustvc/w3c-vc": "^1.3.0-alpha.
|
|
125
|
+
"@trustvc/w3c": "^1.3.0-alpha.14",
|
|
126
|
+
"@trustvc/w3c-context": "^1.3.0-alpha.12",
|
|
127
|
+
"@trustvc/w3c-credential-status": "^1.3.0-alpha.12",
|
|
128
|
+
"@trustvc/w3c-issuer": "^1.3.0-alpha.10",
|
|
129
|
+
"@trustvc/w3c-vc": "^1.3.0-alpha.14",
|
|
130
130
|
"ethers": "^5.8.0",
|
|
131
131
|
"ethersV6": "npm:ethers@^6.14.4",
|
|
132
132
|
"js-sha3": "^0.9.3",
|