@twin.org/standards-w3c-did 0.0.1-next.25 → 0.0.1-next.27
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/dist/cjs/index.cjs +369 -6
- package/dist/esm/index.mjs +365 -7
- package/dist/types/index.d.ts +9 -1
- package/dist/types/models/{IDidProof.d.ts → IDataIntegrityProof.d.ts} +6 -6
- package/dist/types/models/IDidDocumentVerificationMethod.d.ts +3 -2
- package/dist/types/models/IDidVerifiableCredential.d.ts +4 -3
- package/dist/types/models/IDidVerifiablePresentation.d.ts +3 -2
- package/dist/types/models/IJsonWebSignature2020Proof.d.ts +33 -0
- package/dist/types/models/IMultikey.d.ts +41 -0
- package/dist/types/models/IProofSignerVerifier.d.ts +30 -0
- package/dist/types/models/didContexts.d.ts +9 -1
- package/dist/types/models/didTypes.d.ts +4 -4
- package/dist/types/models/proofTypes.d.ts +17 -0
- package/dist/types/signerVerifiers/dataIntegrityProofSignerVerifier.d.ts +36 -0
- package/dist/types/signerVerifiers/jsonWebSignature2020SignerVerifier.d.ts +35 -0
- package/dist/types/utils/multikeyHelper.d.ts +37 -0
- package/dist/types/utils/proofHelper.d.ts +37 -0
- package/docs/changelog.md +1 -1
- package/docs/reference/classes/DataIntegrityProofSignerVerifier.md +134 -0
- package/docs/reference/classes/JsonWebSignature2020SignerVerifier.md +133 -0
- package/docs/reference/classes/MultikeyHelper.md +119 -0
- package/docs/reference/classes/ProofHelper.md +121 -0
- package/docs/reference/index.md +13 -1
- package/docs/reference/interfaces/{IDidProof.md → IDataIntegrityProof.md} +17 -5
- package/docs/reference/interfaces/IDidDocumentVerificationMethod.md +9 -1
- package/docs/reference/interfaces/IDidVerifiableCredential.md +2 -2
- package/docs/reference/interfaces/IDidVerifiablePresentation.md +1 -1
- package/docs/reference/interfaces/IJsonWebSignature2020Proof.md +52 -0
- package/docs/reference/interfaces/IMultikey.md +68 -0
- package/docs/reference/interfaces/IProofSignerVerifier.md +99 -0
- package/docs/reference/type-aliases/ProofTypes.md +5 -0
- package/docs/reference/variables/DidContexts.md +14 -2
- package/docs/reference/variables/DidTypes.md +6 -6
- package/docs/reference/variables/ProofTypes.md +19 -0
- package/locales/en.json +27 -1
- package/package.json +4 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The types for proofs.
|
|
3
|
+
*/
|
|
4
|
+
export declare const ProofTypes: {
|
|
5
|
+
/**
|
|
6
|
+
* The type for Data Integrity Proof.
|
|
7
|
+
*/
|
|
8
|
+
readonly DataIntegrityProof: "DataIntegrityProof";
|
|
9
|
+
/**
|
|
10
|
+
* The type for Json Web Signature 2020.
|
|
11
|
+
*/
|
|
12
|
+
readonly JsonWebSignature2020: "JsonWebSignature2020";
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* The types for proofs.
|
|
16
|
+
*/
|
|
17
|
+
export type ProofTypes = (typeof ProofTypes)[keyof typeof ProofTypes];
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { IJsonLdNodeObject } from "@twin.org/data-json-ld";
|
|
2
|
+
import { type IJwk } from "@twin.org/web";
|
|
3
|
+
import type { IProofSignerVerifier } from "../models/IProofSignerVerifier";
|
|
4
|
+
/**
|
|
5
|
+
* Helper methods for creating and verifying proofs.
|
|
6
|
+
* https://www.w3.org/TR/vc-di-eddsa/#eddsa-jcs-2022
|
|
7
|
+
*/
|
|
8
|
+
export declare class DataIntegrityProofSignerVerifier implements IProofSignerVerifier {
|
|
9
|
+
/**
|
|
10
|
+
* Runtime name for the class.
|
|
11
|
+
*/
|
|
12
|
+
readonly CLASS_NAME: string;
|
|
13
|
+
/**
|
|
14
|
+
* Create a proof for the given data.
|
|
15
|
+
* @param unsecuredDocument The data to create the proof for.
|
|
16
|
+
* @param unsignedProof The proof options.
|
|
17
|
+
* @param signKey The key to sign the proof with.
|
|
18
|
+
* @returns The created proof.
|
|
19
|
+
*/
|
|
20
|
+
createProof(unsecuredDocument: IJsonLdNodeObject, unsignedProof: IJsonLdNodeObject, signKey: IJwk): Promise<IJsonLdNodeObject>;
|
|
21
|
+
/**
|
|
22
|
+
* Verify a proof for the given data in format.
|
|
23
|
+
* @param securedDocument The credential to verify.
|
|
24
|
+
* @param signedProof The proof to verify.
|
|
25
|
+
* @param verifyKey The public key to verify the proof with.
|
|
26
|
+
* @returns True if the credential was verified.
|
|
27
|
+
*/
|
|
28
|
+
verifyProof(securedDocument: IJsonLdNodeObject, signedProof: IJsonLdNodeObject, verifyKey: IJwk): Promise<boolean>;
|
|
29
|
+
/**
|
|
30
|
+
* Create a hash for the given data.
|
|
31
|
+
* @param unsecuredDocument The data to create the proof for.
|
|
32
|
+
* @param unsignedProof The unsigned proof.
|
|
33
|
+
* @returns The created hash.
|
|
34
|
+
*/
|
|
35
|
+
createHash(unsecuredDocument: IJsonLdNodeObject, unsignedProof: IJsonLdNodeObject): Promise<Uint8Array>;
|
|
36
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type IJsonLdNodeObject } from "@twin.org/data-json-ld";
|
|
2
|
+
import { type IJwk } from "@twin.org/web";
|
|
3
|
+
import type { IProofSignerVerifier } from "../models/IProofSignerVerifier";
|
|
4
|
+
/**
|
|
5
|
+
* Helper methods for creating and verifying proofs.
|
|
6
|
+
*/
|
|
7
|
+
export declare class JsonWebSignature2020SignerVerifier implements IProofSignerVerifier {
|
|
8
|
+
/**
|
|
9
|
+
* Runtime name for the class.
|
|
10
|
+
*/
|
|
11
|
+
readonly CLASS_NAME: string;
|
|
12
|
+
/**
|
|
13
|
+
* Create a proof for the given data.
|
|
14
|
+
* @param unsecuredDocument The data to create the proof for.
|
|
15
|
+
* @param unsignedProof The proof options.
|
|
16
|
+
* @param signKey The key to sign the proof with.
|
|
17
|
+
* @returns The created proof.
|
|
18
|
+
*/
|
|
19
|
+
createProof(unsecuredDocument: IJsonLdNodeObject, unsignedProof: IJsonLdNodeObject, signKey: IJwk): Promise<IJsonLdNodeObject>;
|
|
20
|
+
/**
|
|
21
|
+
* Verify a proof for the given data in format.
|
|
22
|
+
* @param securedDocument The credential to verify.
|
|
23
|
+
* @param signedProof The proof to verify.
|
|
24
|
+
* @param verifyKey The public key to verify the proof with.
|
|
25
|
+
* @returns True if the credential was verified.
|
|
26
|
+
*/
|
|
27
|
+
verifyProof(securedDocument: IJsonLdNodeObject, signedProof: IJsonLdNodeObject, verifyKey: IJwk): Promise<boolean>;
|
|
28
|
+
/**
|
|
29
|
+
* Create a hash for the given data.
|
|
30
|
+
* @param unsecuredDocument The data to create the proof for.
|
|
31
|
+
* @param unsignedProof The unsigned proof.
|
|
32
|
+
* @returns The created hash.
|
|
33
|
+
*/
|
|
34
|
+
createHash(unsecuredDocument: IJsonLdNodeObject, unsignedProof: IJsonLdNodeObject): Promise<Uint8Array>;
|
|
35
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { IJwk } from "@twin.org/web";
|
|
2
|
+
import type { IMultikey } from "../models/IMultikey";
|
|
3
|
+
/**
|
|
4
|
+
* Helper methods for multikey.
|
|
5
|
+
*/
|
|
6
|
+
export declare class MultikeyHelper {
|
|
7
|
+
/**
|
|
8
|
+
* Runtime name for the class.
|
|
9
|
+
*/
|
|
10
|
+
static readonly CLASS_NAME: string;
|
|
11
|
+
/**
|
|
12
|
+
* Convert a multikey to a JWK.
|
|
13
|
+
* @param multikey The multikey to convert.
|
|
14
|
+
* @returns The JWK.
|
|
15
|
+
* @throws GeneralError if the multikey is invalid.
|
|
16
|
+
*/
|
|
17
|
+
static toJwk(multikey: IMultikey): IJwk;
|
|
18
|
+
/**
|
|
19
|
+
* Convert a JWK to a Multikey.
|
|
20
|
+
* @param controller The controller of the multikey.
|
|
21
|
+
* @param id The id of the multikey.
|
|
22
|
+
* @param jwk The jwk to convert.
|
|
23
|
+
* @returns The multikey.
|
|
24
|
+
* @throws GeneralError if the jwk is invalid.
|
|
25
|
+
*/
|
|
26
|
+
static fromJwk(controller: string, id: string, jwk: IJwk): IMultikey;
|
|
27
|
+
/**
|
|
28
|
+
* Convert a multikey to raw keys.
|
|
29
|
+
* @param multikey The multikey to convert.
|
|
30
|
+
* @returns The JWK.
|
|
31
|
+
* @throws GeneralError if the multikey is invalid.
|
|
32
|
+
*/
|
|
33
|
+
static toRaw(multikey: IMultikey): {
|
|
34
|
+
publicKey: Uint8Array;
|
|
35
|
+
privateKey: Uint8Array;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { IJsonLdNodeObject } from "@twin.org/data-json-ld";
|
|
2
|
+
import type { IJwk } from "@twin.org/web";
|
|
3
|
+
import type { IProofSignerVerifier } from "../models/IProofSignerVerifier";
|
|
4
|
+
import { ProofTypes } from "../models/proofTypes";
|
|
5
|
+
/**
|
|
6
|
+
* Helper methods for creating and verifying proofs.
|
|
7
|
+
*/
|
|
8
|
+
export declare class ProofHelper {
|
|
9
|
+
/**
|
|
10
|
+
* Runtime name for the class.
|
|
11
|
+
*/
|
|
12
|
+
static readonly CLASS_NAME: string;
|
|
13
|
+
/**
|
|
14
|
+
* Create a signer verifier.
|
|
15
|
+
* @param proofType The type of proof to create.
|
|
16
|
+
* @returns The created signer verifier.
|
|
17
|
+
* @throws GeneralError if the proof type is not supported.
|
|
18
|
+
*/
|
|
19
|
+
static createSignerVerifier(proofType: ProofTypes): IProofSignerVerifier;
|
|
20
|
+
/**
|
|
21
|
+
* Create a proof for the given data.
|
|
22
|
+
* @param proofType The type of proof to create.
|
|
23
|
+
* @param unsecuredDocument The data to create the proof for.
|
|
24
|
+
* @param unsignedProof The proof options.
|
|
25
|
+
* @param signKey The key to sign the proof with.
|
|
26
|
+
* @returns The created proof.
|
|
27
|
+
*/
|
|
28
|
+
static createProof(proofType: ProofTypes, unsecuredDocument: IJsonLdNodeObject, unsignedProof: IJsonLdNodeObject, signKey: IJwk): Promise<IJsonLdNodeObject>;
|
|
29
|
+
/**
|
|
30
|
+
* Verify a proof for the given data.
|
|
31
|
+
* @param securedDocument The credential to verify.
|
|
32
|
+
* @param signedProof The proof to verify.
|
|
33
|
+
* @param verifyKey The public key to verify the proof with.
|
|
34
|
+
* @returns True if the credential was verified.
|
|
35
|
+
*/
|
|
36
|
+
static verifyProof(securedDocument: IJsonLdNodeObject, signedProof: IJsonLdNodeObject, verifyKey: IJwk): Promise<boolean>;
|
|
37
|
+
}
|
package/docs/changelog.md
CHANGED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# Class: DataIntegrityProofSignerVerifier
|
|
2
|
+
|
|
3
|
+
Helper methods for creating and verifying proofs.
|
|
4
|
+
https://www.w3.org/TR/vc-di-eddsa/#eddsa-jcs-2022
|
|
5
|
+
|
|
6
|
+
## Implements
|
|
7
|
+
|
|
8
|
+
- [`IProofSignerVerifier`](../interfaces/IProofSignerVerifier.md)
|
|
9
|
+
|
|
10
|
+
## Constructors
|
|
11
|
+
|
|
12
|
+
### new DataIntegrityProofSignerVerifier()
|
|
13
|
+
|
|
14
|
+
> **new DataIntegrityProofSignerVerifier**(): [`DataIntegrityProofSignerVerifier`](DataIntegrityProofSignerVerifier.md)
|
|
15
|
+
|
|
16
|
+
#### Returns
|
|
17
|
+
|
|
18
|
+
[`DataIntegrityProofSignerVerifier`](DataIntegrityProofSignerVerifier.md)
|
|
19
|
+
|
|
20
|
+
## Properties
|
|
21
|
+
|
|
22
|
+
### CLASS\_NAME
|
|
23
|
+
|
|
24
|
+
> `readonly` **CLASS\_NAME**: `string`
|
|
25
|
+
|
|
26
|
+
Runtime name for the class.
|
|
27
|
+
|
|
28
|
+
## Methods
|
|
29
|
+
|
|
30
|
+
### createProof()
|
|
31
|
+
|
|
32
|
+
> **createProof**(`unsecuredDocument`, `unsignedProof`, `signKey`): `Promise`\<`IJsonLdNodeObject`\>
|
|
33
|
+
|
|
34
|
+
Create a proof for the given data.
|
|
35
|
+
|
|
36
|
+
#### Parameters
|
|
37
|
+
|
|
38
|
+
##### unsecuredDocument
|
|
39
|
+
|
|
40
|
+
`IJsonLdNodeObject`
|
|
41
|
+
|
|
42
|
+
The data to create the proof for.
|
|
43
|
+
|
|
44
|
+
##### unsignedProof
|
|
45
|
+
|
|
46
|
+
`IJsonLdNodeObject`
|
|
47
|
+
|
|
48
|
+
The proof options.
|
|
49
|
+
|
|
50
|
+
##### signKey
|
|
51
|
+
|
|
52
|
+
`IJwk`
|
|
53
|
+
|
|
54
|
+
The key to sign the proof with.
|
|
55
|
+
|
|
56
|
+
#### Returns
|
|
57
|
+
|
|
58
|
+
`Promise`\<`IJsonLdNodeObject`\>
|
|
59
|
+
|
|
60
|
+
The created proof.
|
|
61
|
+
|
|
62
|
+
#### Implementation of
|
|
63
|
+
|
|
64
|
+
[`IProofSignerVerifier`](../interfaces/IProofSignerVerifier.md).[`createProof`](../interfaces/IProofSignerVerifier.md#createproof)
|
|
65
|
+
|
|
66
|
+
***
|
|
67
|
+
|
|
68
|
+
### verifyProof()
|
|
69
|
+
|
|
70
|
+
> **verifyProof**(`securedDocument`, `signedProof`, `verifyKey`): `Promise`\<`boolean`\>
|
|
71
|
+
|
|
72
|
+
Verify a proof for the given data in format.
|
|
73
|
+
|
|
74
|
+
#### Parameters
|
|
75
|
+
|
|
76
|
+
##### securedDocument
|
|
77
|
+
|
|
78
|
+
`IJsonLdNodeObject`
|
|
79
|
+
|
|
80
|
+
The credential to verify.
|
|
81
|
+
|
|
82
|
+
##### signedProof
|
|
83
|
+
|
|
84
|
+
`IJsonLdNodeObject`
|
|
85
|
+
|
|
86
|
+
The proof to verify.
|
|
87
|
+
|
|
88
|
+
##### verifyKey
|
|
89
|
+
|
|
90
|
+
`IJwk`
|
|
91
|
+
|
|
92
|
+
The public key to verify the proof with.
|
|
93
|
+
|
|
94
|
+
#### Returns
|
|
95
|
+
|
|
96
|
+
`Promise`\<`boolean`\>
|
|
97
|
+
|
|
98
|
+
True if the credential was verified.
|
|
99
|
+
|
|
100
|
+
#### Implementation of
|
|
101
|
+
|
|
102
|
+
[`IProofSignerVerifier`](../interfaces/IProofSignerVerifier.md).[`verifyProof`](../interfaces/IProofSignerVerifier.md#verifyproof)
|
|
103
|
+
|
|
104
|
+
***
|
|
105
|
+
|
|
106
|
+
### createHash()
|
|
107
|
+
|
|
108
|
+
> **createHash**(`unsecuredDocument`, `unsignedProof`): `Promise`\<`Uint8Array`\<`ArrayBufferLike`\>\>
|
|
109
|
+
|
|
110
|
+
Create a hash for the given data.
|
|
111
|
+
|
|
112
|
+
#### Parameters
|
|
113
|
+
|
|
114
|
+
##### unsecuredDocument
|
|
115
|
+
|
|
116
|
+
`IJsonLdNodeObject`
|
|
117
|
+
|
|
118
|
+
The data to create the proof for.
|
|
119
|
+
|
|
120
|
+
##### unsignedProof
|
|
121
|
+
|
|
122
|
+
`IJsonLdNodeObject`
|
|
123
|
+
|
|
124
|
+
The unsigned proof.
|
|
125
|
+
|
|
126
|
+
#### Returns
|
|
127
|
+
|
|
128
|
+
`Promise`\<`Uint8Array`\<`ArrayBufferLike`\>\>
|
|
129
|
+
|
|
130
|
+
The created hash.
|
|
131
|
+
|
|
132
|
+
#### Implementation of
|
|
133
|
+
|
|
134
|
+
[`IProofSignerVerifier`](../interfaces/IProofSignerVerifier.md).[`createHash`](../interfaces/IProofSignerVerifier.md#createhash)
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# Class: JsonWebSignature2020SignerVerifier
|
|
2
|
+
|
|
3
|
+
Helper methods for creating and verifying proofs.
|
|
4
|
+
|
|
5
|
+
## Implements
|
|
6
|
+
|
|
7
|
+
- [`IProofSignerVerifier`](../interfaces/IProofSignerVerifier.md)
|
|
8
|
+
|
|
9
|
+
## Constructors
|
|
10
|
+
|
|
11
|
+
### new JsonWebSignature2020SignerVerifier()
|
|
12
|
+
|
|
13
|
+
> **new JsonWebSignature2020SignerVerifier**(): [`JsonWebSignature2020SignerVerifier`](JsonWebSignature2020SignerVerifier.md)
|
|
14
|
+
|
|
15
|
+
#### Returns
|
|
16
|
+
|
|
17
|
+
[`JsonWebSignature2020SignerVerifier`](JsonWebSignature2020SignerVerifier.md)
|
|
18
|
+
|
|
19
|
+
## Properties
|
|
20
|
+
|
|
21
|
+
### CLASS\_NAME
|
|
22
|
+
|
|
23
|
+
> `readonly` **CLASS\_NAME**: `string`
|
|
24
|
+
|
|
25
|
+
Runtime name for the class.
|
|
26
|
+
|
|
27
|
+
## Methods
|
|
28
|
+
|
|
29
|
+
### createProof()
|
|
30
|
+
|
|
31
|
+
> **createProof**(`unsecuredDocument`, `unsignedProof`, `signKey`): `Promise`\<`IJsonLdNodeObject`\>
|
|
32
|
+
|
|
33
|
+
Create a proof for the given data.
|
|
34
|
+
|
|
35
|
+
#### Parameters
|
|
36
|
+
|
|
37
|
+
##### unsecuredDocument
|
|
38
|
+
|
|
39
|
+
`IJsonLdNodeObject`
|
|
40
|
+
|
|
41
|
+
The data to create the proof for.
|
|
42
|
+
|
|
43
|
+
##### unsignedProof
|
|
44
|
+
|
|
45
|
+
`IJsonLdNodeObject`
|
|
46
|
+
|
|
47
|
+
The proof options.
|
|
48
|
+
|
|
49
|
+
##### signKey
|
|
50
|
+
|
|
51
|
+
`IJwk`
|
|
52
|
+
|
|
53
|
+
The key to sign the proof with.
|
|
54
|
+
|
|
55
|
+
#### Returns
|
|
56
|
+
|
|
57
|
+
`Promise`\<`IJsonLdNodeObject`\>
|
|
58
|
+
|
|
59
|
+
The created proof.
|
|
60
|
+
|
|
61
|
+
#### Implementation of
|
|
62
|
+
|
|
63
|
+
[`IProofSignerVerifier`](../interfaces/IProofSignerVerifier.md).[`createProof`](../interfaces/IProofSignerVerifier.md#createproof)
|
|
64
|
+
|
|
65
|
+
***
|
|
66
|
+
|
|
67
|
+
### verifyProof()
|
|
68
|
+
|
|
69
|
+
> **verifyProof**(`securedDocument`, `signedProof`, `verifyKey`): `Promise`\<`boolean`\>
|
|
70
|
+
|
|
71
|
+
Verify a proof for the given data in format.
|
|
72
|
+
|
|
73
|
+
#### Parameters
|
|
74
|
+
|
|
75
|
+
##### securedDocument
|
|
76
|
+
|
|
77
|
+
`IJsonLdNodeObject`
|
|
78
|
+
|
|
79
|
+
The credential to verify.
|
|
80
|
+
|
|
81
|
+
##### signedProof
|
|
82
|
+
|
|
83
|
+
`IJsonLdNodeObject`
|
|
84
|
+
|
|
85
|
+
The proof to verify.
|
|
86
|
+
|
|
87
|
+
##### verifyKey
|
|
88
|
+
|
|
89
|
+
`IJwk`
|
|
90
|
+
|
|
91
|
+
The public key to verify the proof with.
|
|
92
|
+
|
|
93
|
+
#### Returns
|
|
94
|
+
|
|
95
|
+
`Promise`\<`boolean`\>
|
|
96
|
+
|
|
97
|
+
True if the credential was verified.
|
|
98
|
+
|
|
99
|
+
#### Implementation of
|
|
100
|
+
|
|
101
|
+
[`IProofSignerVerifier`](../interfaces/IProofSignerVerifier.md).[`verifyProof`](../interfaces/IProofSignerVerifier.md#verifyproof)
|
|
102
|
+
|
|
103
|
+
***
|
|
104
|
+
|
|
105
|
+
### createHash()
|
|
106
|
+
|
|
107
|
+
> **createHash**(`unsecuredDocument`, `unsignedProof`): `Promise`\<`Uint8Array`\<`ArrayBufferLike`\>\>
|
|
108
|
+
|
|
109
|
+
Create a hash for the given data.
|
|
110
|
+
|
|
111
|
+
#### Parameters
|
|
112
|
+
|
|
113
|
+
##### unsecuredDocument
|
|
114
|
+
|
|
115
|
+
`IJsonLdNodeObject`
|
|
116
|
+
|
|
117
|
+
The data to create the proof for.
|
|
118
|
+
|
|
119
|
+
##### unsignedProof
|
|
120
|
+
|
|
121
|
+
`IJsonLdNodeObject`
|
|
122
|
+
|
|
123
|
+
The unsigned proof.
|
|
124
|
+
|
|
125
|
+
#### Returns
|
|
126
|
+
|
|
127
|
+
`Promise`\<`Uint8Array`\<`ArrayBufferLike`\>\>
|
|
128
|
+
|
|
129
|
+
The created hash.
|
|
130
|
+
|
|
131
|
+
#### Implementation of
|
|
132
|
+
|
|
133
|
+
[`IProofSignerVerifier`](../interfaces/IProofSignerVerifier.md).[`createHash`](../interfaces/IProofSignerVerifier.md#createhash)
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# Class: MultikeyHelper
|
|
2
|
+
|
|
3
|
+
Helper methods for multikey.
|
|
4
|
+
|
|
5
|
+
## Constructors
|
|
6
|
+
|
|
7
|
+
### new MultikeyHelper()
|
|
8
|
+
|
|
9
|
+
> **new MultikeyHelper**(): [`MultikeyHelper`](MultikeyHelper.md)
|
|
10
|
+
|
|
11
|
+
#### Returns
|
|
12
|
+
|
|
13
|
+
[`MultikeyHelper`](MultikeyHelper.md)
|
|
14
|
+
|
|
15
|
+
## Properties
|
|
16
|
+
|
|
17
|
+
### CLASS\_NAME
|
|
18
|
+
|
|
19
|
+
> `readonly` `static` **CLASS\_NAME**: `string`
|
|
20
|
+
|
|
21
|
+
Runtime name for the class.
|
|
22
|
+
|
|
23
|
+
## Methods
|
|
24
|
+
|
|
25
|
+
### toJwk()
|
|
26
|
+
|
|
27
|
+
> `static` **toJwk**(`multikey`): `IJwk`
|
|
28
|
+
|
|
29
|
+
Convert a multikey to a JWK.
|
|
30
|
+
|
|
31
|
+
#### Parameters
|
|
32
|
+
|
|
33
|
+
##### multikey
|
|
34
|
+
|
|
35
|
+
[`IMultikey`](../interfaces/IMultikey.md)
|
|
36
|
+
|
|
37
|
+
The multikey to convert.
|
|
38
|
+
|
|
39
|
+
#### Returns
|
|
40
|
+
|
|
41
|
+
`IJwk`
|
|
42
|
+
|
|
43
|
+
The JWK.
|
|
44
|
+
|
|
45
|
+
#### Throws
|
|
46
|
+
|
|
47
|
+
GeneralError if the multikey is invalid.
|
|
48
|
+
|
|
49
|
+
***
|
|
50
|
+
|
|
51
|
+
### fromJwk()
|
|
52
|
+
|
|
53
|
+
> `static` **fromJwk**(`controller`, `id`, `jwk`): [`IMultikey`](../interfaces/IMultikey.md)
|
|
54
|
+
|
|
55
|
+
Convert a JWK to a Multikey.
|
|
56
|
+
|
|
57
|
+
#### Parameters
|
|
58
|
+
|
|
59
|
+
##### controller
|
|
60
|
+
|
|
61
|
+
`string`
|
|
62
|
+
|
|
63
|
+
The controller of the multikey.
|
|
64
|
+
|
|
65
|
+
##### id
|
|
66
|
+
|
|
67
|
+
`string`
|
|
68
|
+
|
|
69
|
+
The id of the multikey.
|
|
70
|
+
|
|
71
|
+
##### jwk
|
|
72
|
+
|
|
73
|
+
`IJwk`
|
|
74
|
+
|
|
75
|
+
The jwk to convert.
|
|
76
|
+
|
|
77
|
+
#### Returns
|
|
78
|
+
|
|
79
|
+
[`IMultikey`](../interfaces/IMultikey.md)
|
|
80
|
+
|
|
81
|
+
The multikey.
|
|
82
|
+
|
|
83
|
+
#### Throws
|
|
84
|
+
|
|
85
|
+
GeneralError if the jwk is invalid.
|
|
86
|
+
|
|
87
|
+
***
|
|
88
|
+
|
|
89
|
+
### toRaw()
|
|
90
|
+
|
|
91
|
+
> `static` **toRaw**(`multikey`): `object`
|
|
92
|
+
|
|
93
|
+
Convert a multikey to raw keys.
|
|
94
|
+
|
|
95
|
+
#### Parameters
|
|
96
|
+
|
|
97
|
+
##### multikey
|
|
98
|
+
|
|
99
|
+
[`IMultikey`](../interfaces/IMultikey.md)
|
|
100
|
+
|
|
101
|
+
The multikey to convert.
|
|
102
|
+
|
|
103
|
+
#### Returns
|
|
104
|
+
|
|
105
|
+
`object`
|
|
106
|
+
|
|
107
|
+
The JWK.
|
|
108
|
+
|
|
109
|
+
##### publicKey
|
|
110
|
+
|
|
111
|
+
> **publicKey**: `Uint8Array`
|
|
112
|
+
|
|
113
|
+
##### privateKey
|
|
114
|
+
|
|
115
|
+
> **privateKey**: `Uint8Array`
|
|
116
|
+
|
|
117
|
+
#### Throws
|
|
118
|
+
|
|
119
|
+
GeneralError if the multikey is invalid.
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# Class: ProofHelper
|
|
2
|
+
|
|
3
|
+
Helper methods for creating and verifying proofs.
|
|
4
|
+
|
|
5
|
+
## Constructors
|
|
6
|
+
|
|
7
|
+
### new ProofHelper()
|
|
8
|
+
|
|
9
|
+
> **new ProofHelper**(): [`ProofHelper`](ProofHelper.md)
|
|
10
|
+
|
|
11
|
+
#### Returns
|
|
12
|
+
|
|
13
|
+
[`ProofHelper`](ProofHelper.md)
|
|
14
|
+
|
|
15
|
+
## Properties
|
|
16
|
+
|
|
17
|
+
### CLASS\_NAME
|
|
18
|
+
|
|
19
|
+
> `readonly` `static` **CLASS\_NAME**: `string`
|
|
20
|
+
|
|
21
|
+
Runtime name for the class.
|
|
22
|
+
|
|
23
|
+
## Methods
|
|
24
|
+
|
|
25
|
+
### createSignerVerifier()
|
|
26
|
+
|
|
27
|
+
> `static` **createSignerVerifier**(`proofType`): [`IProofSignerVerifier`](../interfaces/IProofSignerVerifier.md)
|
|
28
|
+
|
|
29
|
+
Create a signer verifier.
|
|
30
|
+
|
|
31
|
+
#### Parameters
|
|
32
|
+
|
|
33
|
+
##### proofType
|
|
34
|
+
|
|
35
|
+
[`ProofTypes`](../type-aliases/ProofTypes.md)
|
|
36
|
+
|
|
37
|
+
The type of proof to create.
|
|
38
|
+
|
|
39
|
+
#### Returns
|
|
40
|
+
|
|
41
|
+
[`IProofSignerVerifier`](../interfaces/IProofSignerVerifier.md)
|
|
42
|
+
|
|
43
|
+
The created signer verifier.
|
|
44
|
+
|
|
45
|
+
#### Throws
|
|
46
|
+
|
|
47
|
+
GeneralError if the proof type is not supported.
|
|
48
|
+
|
|
49
|
+
***
|
|
50
|
+
|
|
51
|
+
### createProof()
|
|
52
|
+
|
|
53
|
+
> `static` **createProof**(`proofType`, `unsecuredDocument`, `unsignedProof`, `signKey`): `Promise`\<`IJsonLdNodeObject`\>
|
|
54
|
+
|
|
55
|
+
Create a proof for the given data.
|
|
56
|
+
|
|
57
|
+
#### Parameters
|
|
58
|
+
|
|
59
|
+
##### proofType
|
|
60
|
+
|
|
61
|
+
[`ProofTypes`](../type-aliases/ProofTypes.md)
|
|
62
|
+
|
|
63
|
+
The type of proof to create.
|
|
64
|
+
|
|
65
|
+
##### unsecuredDocument
|
|
66
|
+
|
|
67
|
+
`IJsonLdNodeObject`
|
|
68
|
+
|
|
69
|
+
The data to create the proof for.
|
|
70
|
+
|
|
71
|
+
##### unsignedProof
|
|
72
|
+
|
|
73
|
+
`IJsonLdNodeObject`
|
|
74
|
+
|
|
75
|
+
The proof options.
|
|
76
|
+
|
|
77
|
+
##### signKey
|
|
78
|
+
|
|
79
|
+
`IJwk`
|
|
80
|
+
|
|
81
|
+
The key to sign the proof with.
|
|
82
|
+
|
|
83
|
+
#### Returns
|
|
84
|
+
|
|
85
|
+
`Promise`\<`IJsonLdNodeObject`\>
|
|
86
|
+
|
|
87
|
+
The created proof.
|
|
88
|
+
|
|
89
|
+
***
|
|
90
|
+
|
|
91
|
+
### verifyProof()
|
|
92
|
+
|
|
93
|
+
> `static` **verifyProof**(`securedDocument`, `signedProof`, `verifyKey`): `Promise`\<`boolean`\>
|
|
94
|
+
|
|
95
|
+
Verify a proof for the given data.
|
|
96
|
+
|
|
97
|
+
#### Parameters
|
|
98
|
+
|
|
99
|
+
##### securedDocument
|
|
100
|
+
|
|
101
|
+
`IJsonLdNodeObject`
|
|
102
|
+
|
|
103
|
+
The credential to verify.
|
|
104
|
+
|
|
105
|
+
##### signedProof
|
|
106
|
+
|
|
107
|
+
`IJsonLdNodeObject`
|
|
108
|
+
|
|
109
|
+
The proof to verify.
|
|
110
|
+
|
|
111
|
+
##### verifyKey
|
|
112
|
+
|
|
113
|
+
`IJwk`
|
|
114
|
+
|
|
115
|
+
The public key to verify the proof with.
|
|
116
|
+
|
|
117
|
+
#### Returns
|
|
118
|
+
|
|
119
|
+
`Promise`\<`boolean`\>
|
|
120
|
+
|
|
121
|
+
True if the credential was verified.
|