@sd-jwt/core 0.2.1 → 2.0.2-next.26
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/LICENSE +201 -0
- package/dist/index.d.mts +106 -0
- package/dist/index.d.ts +106 -0
- package/dist/index.js +606 -0
- package/dist/index.mjs +586 -0
- package/package.json +60 -48
- package/src/decoy.ts +15 -0
- package/src/index.ts +235 -0
- package/src/jwt.ts +107 -0
- package/src/kbjwt.ts +45 -0
- package/src/sdjwt.ts +318 -0
- package/src/test/decoy.spec.ts +30 -0
- package/src/test/index.spec.ts +379 -0
- package/src/test/jwt.spec.ts +141 -0
- package/src/test/kbjwt.spec.ts +275 -0
- package/src/test/pass.spec.ts +6 -0
- package/src/test/sdjwt.spec.ts +382 -0
- package/test/app-e2e.spec.ts +248 -0
- package/test/array_data_types.json +29 -0
- package/test/array_full_sd.json +21 -0
- package/test/array_in_sd.json +13 -0
- package/test/array_nested_in_plain.json +20 -0
- package/test/array_none_disclosed.json +17 -0
- package/test/array_of_nulls.json +15 -0
- package/test/array_of_objects.json +58 -0
- package/test/array_of_scalars.json +15 -0
- package/test/array_recursive_sd.json +35 -0
- package/test/array_recursive_sd_some_disclosed.json +55 -0
- package/test/complex.json +43 -0
- package/test/header_mod.json +44 -0
- package/test/json_serialization.json +44 -0
- package/test/key_binding.json +44 -0
- package/test/no_sd.json +36 -0
- package/test/object_data_types.json +60 -0
- package/test/recursions.json +98 -0
- package/tsconfig.json +7 -0
- package/vitest.config.mts +4 -0
- package/README.md +0 -97
- package/build/base64url.d.ts +0 -28
- package/build/base64url.js +0 -40
- package/build/base64url.js.map +0 -1
- package/build/hasherAlgorithm.d.ts +0 -70
- package/build/hasherAlgorithm.js +0 -75
- package/build/hasherAlgorithm.js.map +0 -1
- package/build/index.d.ts +0 -13
- package/build/index.js +0 -20
- package/build/index.js.map +0 -1
- package/build/jwt/compact.d.ts +0 -6
- package/build/jwt/compact.js +0 -27
- package/build/jwt/compact.js.map +0 -1
- package/build/jwt/error.d.ts +0 -2
- package/build/jwt/error.js +0 -7
- package/build/jwt/error.js.map +0 -1
- package/build/jwt/index.d.ts +0 -2
- package/build/jwt/index.js +0 -19
- package/build/jwt/index.js.map +0 -1
- package/build/jwt/jwt.d.ts +0 -208
- package/build/jwt/jwt.js +0 -325
- package/build/jwt/jwt.js.map +0 -1
- package/build/keyBinding/index.d.ts +0 -1
- package/build/keyBinding/index.js +0 -18
- package/build/keyBinding/index.js.map +0 -1
- package/build/keyBinding/keyBinding.d.ts +0 -64
- package/build/keyBinding/keyBinding.js +0 -119
- package/build/keyBinding/keyBinding.js.map +0 -1
- package/build/sdJwt/compact.d.ts +0 -8
- package/build/sdJwt/compact.js +0 -39
- package/build/sdJwt/compact.js.map +0 -1
- package/build/sdJwt/decoys.d.ts +0 -3
- package/build/sdJwt/decoys.js +0 -35
- package/build/sdJwt/decoys.js.map +0 -1
- package/build/sdJwt/disclosureFrame.d.ts +0 -8
- package/build/sdJwt/disclosureFrame.js +0 -87
- package/build/sdJwt/disclosureFrame.js.map +0 -1
- package/build/sdJwt/disclosureMapping.d.ts +0 -43
- package/build/sdJwt/disclosureMapping.js +0 -278
- package/build/sdJwt/disclosureMapping.js.map +0 -1
- package/build/sdJwt/disclosures.d.ts +0 -33
- package/build/sdJwt/disclosures.js +0 -114
- package/build/sdJwt/disclosures.js.map +0 -1
- package/build/sdJwt/error.d.ts +0 -2
- package/build/sdJwt/error.js +0 -7
- package/build/sdJwt/error.js.map +0 -1
- package/build/sdJwt/index.d.ts +0 -6
- package/build/sdJwt/index.js +0 -23
- package/build/sdJwt/index.js.map +0 -1
- package/build/sdJwt/presentationFrame.d.ts +0 -3
- package/build/sdJwt/presentationFrame.js +0 -64
- package/build/sdJwt/presentationFrame.js.map +0 -1
- package/build/sdJwt/sdJwt.d.ts +0 -206
- package/build/sdJwt/sdJwt.js +0 -442
- package/build/sdJwt/sdJwt.js.map +0 -1
- package/build/sdJwt/swapClaim.d.ts +0 -2
- package/build/sdJwt/swapClaim.js +0 -79
- package/build/sdJwt/swapClaim.js.map +0 -1
- package/build/sdJwt/types.d.ts +0 -5
- package/build/sdJwt/types.js +0 -3
- package/build/sdJwt/types.js.map +0 -1
- package/build/sdJwtVc/error.d.ts +0 -2
- package/build/sdJwtVc/error.js +0 -7
- package/build/sdJwtVc/error.js.map +0 -1
- package/build/sdJwtVc/index.d.ts +0 -2
- package/build/sdJwtVc/index.js +0 -19
- package/build/sdJwtVc/index.js.map +0 -1
- package/build/sdJwtVc/sdJwtVc.d.ts +0 -47
- package/build/sdJwtVc/sdJwtVc.js +0 -149
- package/build/sdJwtVc/sdJwtVc.js.map +0 -1
- package/build/signatureAndEncryptionAlgorithm.d.ts +0 -105
- package/build/signatureAndEncryptionAlgorithm.js +0 -110
- package/build/signatureAndEncryptionAlgorithm.js.map +0 -1
- package/build/types/disclosure.d.ts +0 -5
- package/build/types/disclosure.js +0 -3
- package/build/types/disclosure.js.map +0 -1
- package/build/types/frame.d.ts +0 -5
- package/build/types/frame.js +0 -3
- package/build/types/frame.js.map +0 -1
- package/build/types/hasher.d.ts +0 -14
- package/build/types/hasher.js +0 -3
- package/build/types/hasher.js.map +0 -1
- package/build/types/index.d.ts +0 -5
- package/build/types/index.js +0 -22
- package/build/types/index.js.map +0 -1
- package/build/types/present.d.ts +0 -2
- package/build/types/present.js +0 -3
- package/build/types/present.js.map +0 -1
- package/build/types/saltGenerator.d.ts +0 -17
- package/build/types/saltGenerator.js +0 -3
- package/build/types/saltGenerator.js.map +0 -1
- package/build/types/signer.d.ts +0 -2
- package/build/types/signer.js +0 -3
- package/build/types/signer.js.map +0 -1
- package/build/types/utils.d.ts +0 -2
- package/build/types/utils.js +0 -3
- package/build/types/utils.js.map +0 -1
- package/build/types/verifier.d.ts +0 -14
- package/build/types/verifier.js +0 -3
- package/build/types/verifier.js.map +0 -1
- package/build/utils/index.d.ts +0 -2
- package/build/utils/index.js +0 -19
- package/build/utils/index.js.map +0 -1
- package/build/utils/traverse.d.ts +0 -8
- package/build/utils/traverse.js +0 -29
- package/build/utils/traverse.js.map +0 -1
- package/build/utils/utils.d.ts +0 -8
- package/build/utils/utils.js +0 -118
- package/build/utils/utils.js.map +0 -1
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getDisclosuresForPresentationFrame = void 0;
|
|
4
|
-
const utils_1 = require("../utils");
|
|
5
|
-
const error_1 = require("./error");
|
|
6
|
-
const disclosureMapping_1 = require("./disclosureMapping");
|
|
7
|
-
const getDisclosuresForPresentationFrame = (signedPayload, presentationFrame, prettyClaims, disclosures = []) => {
|
|
8
|
-
const requiredDisclosureDigests = new Set();
|
|
9
|
-
const disclosureMap = (0, disclosureMapping_1.getDisclosureMap)(disclosures);
|
|
10
|
-
const payloadDisclosureMapping = (0, disclosureMapping_1.getPayloadDisclosureMapping)(signedPayload, disclosureMap);
|
|
11
|
-
// No disclosures needed
|
|
12
|
-
if (payloadDisclosureMapping === null) {
|
|
13
|
-
if (disclosures.length > 0) {
|
|
14
|
-
throw new error_1.SdJwtError('Payload disclosure mapping is null, but disclosures are present.');
|
|
15
|
-
}
|
|
16
|
-
return [];
|
|
17
|
-
}
|
|
18
|
-
for (const node of (0, utils_1.traverseNodes)(presentationFrame)) {
|
|
19
|
-
// We only want to process leaf nodes here
|
|
20
|
-
if (!node.isLeaf)
|
|
21
|
-
continue;
|
|
22
|
-
if (typeof node.value !== 'boolean') {
|
|
23
|
-
throw new error_1.SdJwtError(`Expected leaf value in presentation frame to be of type boolean, but found ${typeof node.value}`);
|
|
24
|
-
}
|
|
25
|
-
// If the value is false, it means we don't want to disclose it
|
|
26
|
-
if (node.value === false)
|
|
27
|
-
continue;
|
|
28
|
-
if (!(0, utils_1.hasByPath)(prettyClaims, node.path)) {
|
|
29
|
-
throw new error_1.SdJwtError(`Path ${node.path.join('.')} from presentation frame is not present in pretty SD-JWT payload. The presentation frame may only include properties that are present in the SD-JWT payload.`);
|
|
30
|
-
}
|
|
31
|
-
let path = [...node.path];
|
|
32
|
-
while (!(0, utils_1.hasByPath)(payloadDisclosureMapping, path)) {
|
|
33
|
-
if (path.pop() === undefined)
|
|
34
|
-
break;
|
|
35
|
-
}
|
|
36
|
-
// There are no disclosures on this path, meaning the property is disclosed by default in the signed payload
|
|
37
|
-
if (path.length === 0)
|
|
38
|
-
continue;
|
|
39
|
-
const disclosure = (0, utils_1.getByPath)(payloadDisclosureMapping, path);
|
|
40
|
-
// If disclosure is string, it means it's already the digest
|
|
41
|
-
if (typeof disclosure === 'string')
|
|
42
|
-
requiredDisclosureDigests.add(disclosure);
|
|
43
|
-
// Otherwise we want to get all the child digests as well
|
|
44
|
-
else {
|
|
45
|
-
for (const nestedItem of (0, utils_1.traverseNodes)(disclosure)) {
|
|
46
|
-
if (!nestedItem.isLeaf ||
|
|
47
|
-
typeof nestedItem.value !== 'string') {
|
|
48
|
-
continue;
|
|
49
|
-
}
|
|
50
|
-
requiredDisclosureDigests.add(nestedItem.value);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
for (const disclosureDigest of requiredDisclosureDigests.values()) {
|
|
55
|
-
const disclosure = disclosureMap[disclosureDigest];
|
|
56
|
-
if (!disclosure) {
|
|
57
|
-
throw new Error('disclosure not found');
|
|
58
|
-
}
|
|
59
|
-
disclosure.parentDisclosures.forEach((d) => requiredDisclosureDigests.add(d.digest));
|
|
60
|
-
}
|
|
61
|
-
return Array.from(requiredDisclosureDigests).map((digest) => disclosureMap[digest].disclosure);
|
|
62
|
-
};
|
|
63
|
-
exports.getDisclosuresForPresentationFrame = getDisclosuresForPresentationFrame;
|
|
64
|
-
//# sourceMappingURL=presentationFrame.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"presentationFrame.js","sourceRoot":"","sources":["../../src/sdJwt/presentationFrame.ts"],"names":[],"mappings":";;;AAAA,oCAA8D;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sdJwt.d.ts
DELETED
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
import { PresentationFrame } from '@sd-jwt/present';
|
|
2
|
-
import { Jwt, JwtAdditionalOptions, JwtVerificationResult } from '../jwt/jwt';
|
|
3
|
-
import { KeyBinding } from '../keyBinding';
|
|
4
|
-
import { DisclosureFrame, SaltGenerator, Verifier } from '../types';
|
|
5
|
-
import { Disclosure, DisclosureWithDigest } from './disclosures';
|
|
6
|
-
import { ReturnSdJwtWithHeaderAndPayload, ReturnSdJwtWithKeyBinding, ReturnSdJwtWithPayload } from './types';
|
|
7
|
-
import { HasherAlgorithm, HasherAndAlgorithm } from '@sd-jwt/types';
|
|
8
|
-
export type SdJwtToCompactOptions<DisclosablePayload extends Record<string, unknown>> = {
|
|
9
|
-
disclosureFrame?: DisclosureFrame<DisclosablePayload>;
|
|
10
|
-
shouldApplyFrame?: boolean;
|
|
11
|
-
};
|
|
12
|
-
export type SdJwtOptions<Header extends Record<string, unknown>, Payload extends Record<string, unknown>> = {
|
|
13
|
-
header?: Header;
|
|
14
|
-
payload?: Payload;
|
|
15
|
-
signature?: Uint8Array;
|
|
16
|
-
keyBinding?: KeyBinding;
|
|
17
|
-
disclosures?: Array<Disclosure>;
|
|
18
|
-
};
|
|
19
|
-
export type SdJwtAdditionalOptions<Payload extends Record<string, unknown>> = JwtAdditionalOptions & {
|
|
20
|
-
hasherAndAlgorithm?: HasherAndAlgorithm;
|
|
21
|
-
saltGenerator?: SaltGenerator;
|
|
22
|
-
disclosureFrame?: DisclosureFrame<Payload>;
|
|
23
|
-
};
|
|
24
|
-
export type SdJwtVerificationResult = JwtVerificationResult & {
|
|
25
|
-
isKeyBindingValid?: boolean;
|
|
26
|
-
};
|
|
27
|
-
export declare class SdJwt<Header extends Record<string, unknown> = Record<string, unknown>, Payload extends Record<string, unknown> = Record<string, unknown>> extends Jwt<Header, Payload> {
|
|
28
|
-
disclosures?: Array<Disclosure>;
|
|
29
|
-
keyBinding?: KeyBinding;
|
|
30
|
-
private saltGenerator?;
|
|
31
|
-
private hasherAndAlgorithm?;
|
|
32
|
-
disclosureFrame?: DisclosureFrame<Payload>;
|
|
33
|
-
constructor(options?: SdJwtOptions<Header, Payload>, additionalOptions?: SdJwtAdditionalOptions<Payload>);
|
|
34
|
-
/**
|
|
35
|
-
*
|
|
36
|
-
* Create an sd-jwt from a compact format. This will succeed for a normal jwt as well.
|
|
37
|
-
*
|
|
38
|
-
*/
|
|
39
|
-
static fromCompact<Header extends Record<string, unknown> = Record<string, unknown>, Payload extends Record<string, unknown> = Record<string, unknown>>(compact: string): ReturnSdJwtWithHeaderAndPayload<Header, Payload, SdJwt<Header, Payload>>;
|
|
40
|
-
/**
|
|
41
|
-
*
|
|
42
|
-
* Add a salt generator.
|
|
43
|
-
*
|
|
44
|
-
* Recommended size is 128 bits (i.e. 16 bytes).
|
|
45
|
-
*
|
|
46
|
-
* Salts will not be seeded and a new one will be used for each claim.
|
|
47
|
-
*
|
|
48
|
-
* @example
|
|
49
|
-
*
|
|
50
|
-
* Node.js: `crypto.randomBytes(128 / 8)`
|
|
51
|
-
*
|
|
52
|
-
* React Native: `expo-standard-web-crypto`
|
|
53
|
-
*
|
|
54
|
-
* Browser: `crypto.getRandomValues(new Uint8Array(128 / 8))`
|
|
55
|
-
*
|
|
56
|
-
*/
|
|
57
|
-
withSaltGenerator(saltGenerator: SaltGenerator): this;
|
|
58
|
-
/**
|
|
59
|
-
*
|
|
60
|
-
* Add a hasher that will be used to hash the disclosures.
|
|
61
|
-
*
|
|
62
|
-
* @note Make sure to return a base64url encoded version of the hash.
|
|
63
|
-
*
|
|
64
|
-
* @example
|
|
65
|
-
*
|
|
66
|
-
* Node.js: `createHash('sha256').update(input).digest().toString('base64url')`
|
|
67
|
-
*
|
|
68
|
-
*/
|
|
69
|
-
withHasher(hasherAndAlgorithm: HasherAndAlgorithm): ReturnSdJwtWithPayload<Header, Payload, this>;
|
|
70
|
-
/**
|
|
71
|
-
*
|
|
72
|
-
* Adds the algorithm of the hasher to the payload.
|
|
73
|
-
*
|
|
74
|
-
* For convience, this also allows you to set the hasher.
|
|
75
|
-
*
|
|
76
|
-
* @throws when the hasher and algorithm are not set.
|
|
77
|
-
*
|
|
78
|
-
*/
|
|
79
|
-
addHasherAlgorithmToPayload(hasherAndAlgorithm?: HasherAndAlgorithm): ReturnSdJwtWithPayload<Header, Payload, this>;
|
|
80
|
-
/**
|
|
81
|
-
*
|
|
82
|
-
* Set the `KeyBinding` jwt.
|
|
83
|
-
*
|
|
84
|
-
* This can be done as a holder to provide proof of possession of key material
|
|
85
|
-
*
|
|
86
|
-
*/
|
|
87
|
-
withKeyBinding(keyBinding: Jwt | KeyBinding<any, any> | string): ReturnSdJwtWithKeyBinding<Header, Payload, this>;
|
|
88
|
-
/**
|
|
89
|
-
*
|
|
90
|
-
* Set the disclosure frame which will be applied via `SdJwt.applyDisclosureFrame` or when `SdJwt.toCompact` is called.
|
|
91
|
-
*
|
|
92
|
-
*/
|
|
93
|
-
withDisclosureFrame(disclosureFrame: DisclosureFrame<Payload>): this;
|
|
94
|
-
/**
|
|
95
|
-
*
|
|
96
|
-
* Apply the disclosure frame.
|
|
97
|
-
*
|
|
98
|
-
* @throws when the salt generator is not set
|
|
99
|
-
* @throws when the hasher and algorithm is not set
|
|
100
|
-
* @throws when the payload is not set
|
|
101
|
-
* @throws when no disclosure frame is set
|
|
102
|
-
* @throws when disclosures are included and a signature is set, but no signer is provided `*`
|
|
103
|
-
* @throws when the disclosure frame is inconsistent with the payload
|
|
104
|
-
*
|
|
105
|
-
* * This is done as removing items from the payload alters the signature and it has to be resigned.
|
|
106
|
-
*
|
|
107
|
-
*/
|
|
108
|
-
applyDisclosureFrame(): Promise<void>;
|
|
109
|
-
disclosuresWithDigest(): Promise<DisclosureWithDigest[] | undefined>;
|
|
110
|
-
/**
|
|
111
|
-
*
|
|
112
|
-
* Assert that the disclosure frame is set.
|
|
113
|
-
*
|
|
114
|
-
*/
|
|
115
|
-
assertDisclosureFrame(): void;
|
|
116
|
-
/**
|
|
117
|
-
*
|
|
118
|
-
* Assert that the salt generator is set.
|
|
119
|
-
*
|
|
120
|
-
*/
|
|
121
|
-
private assertSaltGenerator;
|
|
122
|
-
/**
|
|
123
|
-
*
|
|
124
|
-
* Assert that the hasher and algorithm is set.
|
|
125
|
-
*
|
|
126
|
-
*/
|
|
127
|
-
private assertHashAndAlgorithm;
|
|
128
|
-
/**
|
|
129
|
-
*
|
|
130
|
-
* Assert that a certain claim is included in the disclosure frame.
|
|
131
|
-
*
|
|
132
|
-
* @throws when the disclosure frame is not set
|
|
133
|
-
*
|
|
134
|
-
*/
|
|
135
|
-
assertClaimInDisclosureFrame(claimKey: string): void;
|
|
136
|
-
/**
|
|
137
|
-
* This function creates a presentation of an SD-JWT, based on the presentation frame. The
|
|
138
|
-
* presentation frame is similar to the disclosure frame, and allows you to present a subset
|
|
139
|
-
* of the disclosures.
|
|
140
|
-
*
|
|
141
|
-
* If no `presentationFrame` is passed, the entire SD-JWT will be presented.
|
|
142
|
-
* To create a presentation without any of the disclosures, pass an empty object as the `presentationFrame`.
|
|
143
|
-
*
|
|
144
|
-
* @example
|
|
145
|
-
* The following example will expose `name`, `a.nested`, and `orderItems[0]` and `orderItems[2]`.
|
|
146
|
-
* Based on the disclosures it will also expose the parent and child disclosures when needed.
|
|
147
|
-
* E.g. if `a` can only be disclosed as a whole, disclosing `a.nested` will also disclose `a`.
|
|
148
|
-
* The same is true for child disclosures. If you expose `name`, and it potentially contains recursive
|
|
149
|
-
* disclosures, all disclosures under name will be disclosed as well.
|
|
150
|
-
* ```ts
|
|
151
|
-
* await sdJwt.present({
|
|
152
|
-
* name: true,
|
|
153
|
-
* a: {
|
|
154
|
-
* nested: 'property'
|
|
155
|
-
* }
|
|
156
|
-
* orderItems: [true, false, true]
|
|
157
|
-
* })
|
|
158
|
-
* ```
|
|
159
|
-
*
|
|
160
|
-
* @throws when the presentation frame does not match the decoded/pretty payload of the sd-jwt
|
|
161
|
-
* @throws when the presentation frame contains fields other than object, array or boolean
|
|
162
|
-
*
|
|
163
|
-
*/
|
|
164
|
-
present(presentationFrame?: PresentationFrame<Payload>): Promise<string>;
|
|
165
|
-
/**
|
|
166
|
-
*
|
|
167
|
-
* Verify the sd-jwt.
|
|
168
|
-
*
|
|
169
|
-
* It validates the following properties:
|
|
170
|
-
* - sd-jwt issuer signature
|
|
171
|
-
* - Optionally, the required claims
|
|
172
|
-
* - The `nbf` and `exp` claims
|
|
173
|
-
* - Whether the key binding is valid
|
|
174
|
-
*
|
|
175
|
-
*/
|
|
176
|
-
verify(verifier: Verifier<Header>, requiredClaimKeys?: Array<keyof Payload | string>, kbJwtPublicKeyJwk?: Record<string, unknown>, issuerPublicKeyJwk?: Record<string, unknown>): Promise<SdJwtVerificationResult>;
|
|
177
|
-
/**
|
|
178
|
-
*
|
|
179
|
-
* Utility method to check whether the expected hasher algorithm is used.
|
|
180
|
-
*
|
|
181
|
-
*/
|
|
182
|
-
checkHasher(expectedHasher: HasherAlgorithm | string): boolean;
|
|
183
|
-
assertNonSelectivelyDisclosableClaim(claimKey: string): void;
|
|
184
|
-
assertNonSelectivelyDisclosableClaims(): void;
|
|
185
|
-
/**
|
|
186
|
-
*
|
|
187
|
-
* Return all claims from the payload and the disclosures on their original place.
|
|
188
|
-
*
|
|
189
|
-
*/
|
|
190
|
-
getPrettyClaims<Claims extends Record<string, unknown> = Payload>(): Promise<Claims>;
|
|
191
|
-
/**
|
|
192
|
-
*
|
|
193
|
-
* Create a compact format of the sd-jwt.
|
|
194
|
-
*
|
|
195
|
-
* This will
|
|
196
|
-
* - Apply the disclosure frame
|
|
197
|
-
* - Add a signature if there is none
|
|
198
|
-
*
|
|
199
|
-
* @throws When the signature and signer are not defined
|
|
200
|
-
* @throws When a claim is requested to be selectively disclosable, but it was not found in the payload
|
|
201
|
-
*
|
|
202
|
-
*/
|
|
203
|
-
toCompact(): Promise<string>;
|
|
204
|
-
private __toCompact;
|
|
205
|
-
private calculateSdHash;
|
|
206
|
-
}
|