@originals/sdk 1.8.0 → 1.8.2
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/utils/hash.js +1 -0
- package/package.json +6 -5
- package/src/adapters/FeeOracleMock.ts +9 -0
- package/src/adapters/index.ts +5 -0
- package/src/adapters/providers/OrdHttpProvider.ts +126 -0
- package/src/adapters/providers/OrdMockProvider.ts +101 -0
- package/src/adapters/types.ts +66 -0
- package/src/bitcoin/BitcoinManager.ts +329 -0
- package/src/bitcoin/BroadcastClient.ts +54 -0
- package/src/bitcoin/OrdinalsClient.ts +120 -0
- package/src/bitcoin/PSBTBuilder.ts +106 -0
- package/src/bitcoin/fee-calculation.ts +38 -0
- package/src/bitcoin/providers/OrdNodeProvider.ts +92 -0
- package/src/bitcoin/providers/OrdinalsProvider.ts +56 -0
- package/src/bitcoin/providers/types.ts +59 -0
- package/src/bitcoin/transactions/commit.ts +465 -0
- package/src/bitcoin/transactions/index.ts +13 -0
- package/src/bitcoin/transfer.ts +43 -0
- package/src/bitcoin/utxo-selection.ts +322 -0
- package/src/bitcoin/utxo.ts +113 -0
- package/src/cel/ExternalReferenceManager.ts +87 -0
- package/src/cel/OriginalsCel.ts +460 -0
- package/src/cel/algorithms/createEventLog.ts +68 -0
- package/src/cel/algorithms/deactivateEventLog.ts +109 -0
- package/src/cel/algorithms/index.ts +11 -0
- package/src/cel/algorithms/updateEventLog.ts +99 -0
- package/src/cel/algorithms/verifyEventLog.ts +306 -0
- package/src/cel/algorithms/witnessEvent.ts +87 -0
- package/src/cel/cli/create.ts +330 -0
- package/src/cel/cli/index.ts +383 -0
- package/src/cel/cli/inspect.ts +549 -0
- package/src/cel/cli/migrate.ts +473 -0
- package/src/cel/cli/verify.ts +249 -0
- package/src/cel/hash.ts +71 -0
- package/src/cel/index.ts +16 -0
- package/src/cel/layers/BtcoCelManager.ts +408 -0
- package/src/cel/layers/PeerCelManager.ts +371 -0
- package/src/cel/layers/WebVHCelManager.ts +361 -0
- package/src/cel/layers/index.ts +27 -0
- package/src/cel/serialization/cbor.ts +189 -0
- package/src/cel/serialization/index.ts +10 -0
- package/src/cel/serialization/json.ts +209 -0
- package/src/cel/types.ts +160 -0
- package/src/cel/witnesses/BitcoinWitness.ts +184 -0
- package/src/cel/witnesses/HttpWitness.ts +241 -0
- package/src/cel/witnesses/WitnessService.ts +51 -0
- package/src/cel/witnesses/index.ts +11 -0
- package/src/contexts/credentials-v1.json +237 -0
- package/src/contexts/credentials-v2-examples.json +5 -0
- package/src/contexts/credentials-v2.json +340 -0
- package/src/contexts/credentials.json +237 -0
- package/src/contexts/data-integrity-v2.json +81 -0
- package/src/contexts/dids.json +58 -0
- package/src/contexts/ed255192020.json +93 -0
- package/src/contexts/ordinals-plus.json +23 -0
- package/src/contexts/originals.json +22 -0
- package/src/core/OriginalsSDK.ts +420 -0
- package/src/crypto/Multikey.ts +194 -0
- package/src/crypto/Signer.ts +262 -0
- package/src/crypto/noble-init.ts +138 -0
- package/src/did/BtcoDidResolver.ts +231 -0
- package/src/did/DIDManager.ts +705 -0
- package/src/did/Ed25519Verifier.ts +68 -0
- package/src/did/KeyManager.ts +239 -0
- package/src/did/WebVHManager.ts +499 -0
- package/src/did/createBtcoDidDocument.ts +60 -0
- package/src/did/providers/OrdinalsClientProviderAdapter.ts +68 -0
- package/src/events/EventEmitter.ts +222 -0
- package/src/events/index.ts +19 -0
- package/src/events/types.ts +331 -0
- package/src/examples/basic-usage.ts +78 -0
- package/src/examples/create-module-original.ts +435 -0
- package/src/examples/full-lifecycle-flow.ts +514 -0
- package/src/examples/run.ts +60 -0
- package/src/index.ts +204 -0
- package/src/kinds/KindRegistry.ts +320 -0
- package/src/kinds/index.ts +74 -0
- package/src/kinds/types.ts +470 -0
- package/src/kinds/validators/AgentValidator.ts +257 -0
- package/src/kinds/validators/AppValidator.ts +211 -0
- package/src/kinds/validators/DatasetValidator.ts +242 -0
- package/src/kinds/validators/DocumentValidator.ts +311 -0
- package/src/kinds/validators/MediaValidator.ts +269 -0
- package/src/kinds/validators/ModuleValidator.ts +225 -0
- package/src/kinds/validators/base.ts +276 -0
- package/src/kinds/validators/index.ts +12 -0
- package/src/lifecycle/BatchOperations.ts +381 -0
- package/src/lifecycle/LifecycleManager.ts +2156 -0
- package/src/lifecycle/OriginalsAsset.ts +524 -0
- package/src/lifecycle/ProvenanceQuery.ts +280 -0
- package/src/lifecycle/ResourceVersioning.ts +163 -0
- package/src/migration/MigrationManager.ts +587 -0
- package/src/migration/audit/AuditLogger.ts +176 -0
- package/src/migration/checkpoint/CheckpointManager.ts +112 -0
- package/src/migration/checkpoint/CheckpointStorage.ts +101 -0
- package/src/migration/index.ts +33 -0
- package/src/migration/operations/BaseMigration.ts +126 -0
- package/src/migration/operations/PeerToBtcoMigration.ts +105 -0
- package/src/migration/operations/PeerToWebvhMigration.ts +62 -0
- package/src/migration/operations/WebvhToBtcoMigration.ts +105 -0
- package/src/migration/rollback/RollbackManager.ts +170 -0
- package/src/migration/state/StateMachine.ts +92 -0
- package/src/migration/state/StateTracker.ts +156 -0
- package/src/migration/types.ts +356 -0
- package/src/migration/validation/BitcoinValidator.ts +107 -0
- package/src/migration/validation/CredentialValidator.ts +62 -0
- package/src/migration/validation/DIDCompatibilityValidator.ts +151 -0
- package/src/migration/validation/LifecycleValidator.ts +64 -0
- package/src/migration/validation/StorageValidator.ts +79 -0
- package/src/migration/validation/ValidationPipeline.ts +213 -0
- package/src/resources/ResourceManager.ts +655 -0
- package/src/resources/index.ts +21 -0
- package/src/resources/types.ts +202 -0
- package/src/storage/LocalStorageAdapter.ts +64 -0
- package/src/storage/MemoryStorageAdapter.ts +29 -0
- package/src/storage/StorageAdapter.ts +25 -0
- package/src/storage/index.ts +3 -0
- package/src/types/bitcoin.ts +98 -0
- package/src/types/common.ts +92 -0
- package/src/types/credentials.ts +89 -0
- package/src/types/did.ts +31 -0
- package/src/types/external-shims.d.ts +53 -0
- package/src/types/index.ts +7 -0
- package/src/types/network.ts +178 -0
- package/src/utils/EventLogger.ts +298 -0
- package/src/utils/Logger.ts +324 -0
- package/src/utils/MetricsCollector.ts +358 -0
- package/src/utils/bitcoin-address.ts +132 -0
- package/src/utils/cbor.ts +31 -0
- package/src/utils/encoding.ts +135 -0
- package/src/utils/hash.ts +12 -0
- package/src/utils/retry.ts +46 -0
- package/src/utils/satoshi-validation.ts +196 -0
- package/src/utils/serialization.ts +102 -0
- package/src/utils/telemetry.ts +44 -0
- package/src/utils/validation.ts +123 -0
- package/src/vc/CredentialManager.ts +955 -0
- package/src/vc/Issuer.ts +105 -0
- package/src/vc/Verifier.ts +54 -0
- package/src/vc/cryptosuites/bbs.ts +253 -0
- package/src/vc/cryptosuites/bbsSimple.ts +21 -0
- package/src/vc/cryptosuites/eddsa.ts +99 -0
- package/src/vc/documentLoader.ts +81 -0
- package/src/vc/proofs/data-integrity.ts +33 -0
- package/src/vc/utils/jsonld.ts +18 -0
package/src/vc/Issuer.ts
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { VerifiableCredential, VerifiablePresentation } from '../types';
|
|
2
|
+
import { multikey, MultikeyType } from '../crypto/Multikey';
|
|
3
|
+
import { DIDManager } from '../did/DIDManager';
|
|
4
|
+
import { createDocumentLoader } from './documentLoader';
|
|
5
|
+
import { DataIntegrityProofManager } from './proofs/data-integrity';
|
|
6
|
+
|
|
7
|
+
export interface IssueOptions {
|
|
8
|
+
proofPurpose: 'assertionMethod' | 'authentication';
|
|
9
|
+
documentLoader?: (iri: string) => Promise<{ document: unknown; documentUrl: string; contextUrl: string | null }>;
|
|
10
|
+
challenge?: string;
|
|
11
|
+
domain?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type VerificationMethodLike = {
|
|
15
|
+
id: string;
|
|
16
|
+
controller: string;
|
|
17
|
+
publicKeyMultibase: string;
|
|
18
|
+
secretKeyMultibase?: string;
|
|
19
|
+
type?: string;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export class Issuer {
|
|
23
|
+
constructor(private didManager: DIDManager, private verificationMethod: VerificationMethodLike) {}
|
|
24
|
+
|
|
25
|
+
private inferKeyType(publicKeyMultibase: string): MultikeyType {
|
|
26
|
+
try {
|
|
27
|
+
return multikey.decodePublicKey(publicKeyMultibase).type;
|
|
28
|
+
} catch {
|
|
29
|
+
return 'Ed25519';
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async issueCredential(
|
|
34
|
+
unsigned: Omit<VerifiableCredential, '@context' | 'proof'>,
|
|
35
|
+
options: IssueOptions
|
|
36
|
+
): Promise<VerifiableCredential> {
|
|
37
|
+
const documentLoader = options.documentLoader || createDocumentLoader(this.didManager);
|
|
38
|
+
await documentLoader(this.verificationMethod.id);
|
|
39
|
+
|
|
40
|
+
const issuerId = typeof unsigned.issuer === 'string' ? unsigned.issuer : (unsigned.issuer as { id?: string })?.id;
|
|
41
|
+
const credential: VerifiableCredential = {
|
|
42
|
+
...unsigned,
|
|
43
|
+
'@context': ['https://www.w3.org/ns/credentials/v2'],
|
|
44
|
+
issuer: issuerId || this.verificationMethod.controller,
|
|
45
|
+
proof: undefined
|
|
46
|
+
} as VerifiableCredential;
|
|
47
|
+
|
|
48
|
+
if (!this.verificationMethod.secretKeyMultibase) {
|
|
49
|
+
throw new Error('Missing secretKeyMultibase for issuance');
|
|
50
|
+
}
|
|
51
|
+
const keyType = this.inferKeyType(this.verificationMethod.publicKeyMultibase);
|
|
52
|
+
if (keyType !== 'Ed25519') {
|
|
53
|
+
throw new Error('Only Ed25519 supported for eddsa-rdfc-2022');
|
|
54
|
+
}
|
|
55
|
+
const proof = await DataIntegrityProofManager.createProof(credential, {
|
|
56
|
+
verificationMethod: this.verificationMethod.id,
|
|
57
|
+
proofPurpose: options.proofPurpose,
|
|
58
|
+
cryptosuite: 'eddsa-rdfc-2022',
|
|
59
|
+
type: 'DataIntegrityProof',
|
|
60
|
+
privateKey: this.verificationMethod.secretKeyMultibase,
|
|
61
|
+
documentLoader
|
|
62
|
+
});
|
|
63
|
+
return { ...credential, proof } as VerifiableCredential;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async issuePresentation(
|
|
67
|
+
presentation: Omit<VerifiablePresentation, '@context' | 'proof'>,
|
|
68
|
+
options: IssueOptions
|
|
69
|
+
): Promise<VerifiablePresentation> {
|
|
70
|
+
const documentLoader = options.documentLoader || createDocumentLoader(this.didManager);
|
|
71
|
+
await documentLoader(this.verificationMethod.id);
|
|
72
|
+
|
|
73
|
+
if (!this.verificationMethod.secretKeyMultibase) {
|
|
74
|
+
throw new Error('Missing secretKeyMultibase for issuance');
|
|
75
|
+
}
|
|
76
|
+
const keyType = this.inferKeyType(this.verificationMethod.publicKeyMultibase);
|
|
77
|
+
if (keyType !== 'Ed25519') {
|
|
78
|
+
throw new Error('Only Ed25519 supported for eddsa-rdfc-2022');
|
|
79
|
+
}
|
|
80
|
+
const presentationWithContext = {
|
|
81
|
+
...presentation,
|
|
82
|
+
'@context': ['https://www.w3.org/ns/credentials/v2']
|
|
83
|
+
} as Record<string, unknown>;
|
|
84
|
+
|
|
85
|
+
const proof = await DataIntegrityProofManager.createProof(
|
|
86
|
+
presentationWithContext,
|
|
87
|
+
{
|
|
88
|
+
verificationMethod: this.verificationMethod.id,
|
|
89
|
+
proofPurpose: options.proofPurpose,
|
|
90
|
+
cryptosuite: 'eddsa-rdfc-2022',
|
|
91
|
+
type: 'DataIntegrityProof',
|
|
92
|
+
privateKey: this.verificationMethod.secretKeyMultibase,
|
|
93
|
+
challenge: options.challenge,
|
|
94
|
+
domain: options.domain,
|
|
95
|
+
documentLoader
|
|
96
|
+
}
|
|
97
|
+
);
|
|
98
|
+
return {
|
|
99
|
+
...presentation,
|
|
100
|
+
'@context': ['https://www.w3.org/ns/credentials/v2'],
|
|
101
|
+
proof
|
|
102
|
+
} as VerifiablePresentation;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { VerifiableCredential, VerifiablePresentation } from '../types';
|
|
2
|
+
import { DIDManager } from '../did/DIDManager';
|
|
3
|
+
import { createDocumentLoader } from './documentLoader';
|
|
4
|
+
import { DataIntegrityProofManager } from './proofs/data-integrity';
|
|
5
|
+
import type { DataIntegrityProof } from './cryptosuites/eddsa';
|
|
6
|
+
|
|
7
|
+
export type VerificationResult = { verified: boolean; errors: string[] };
|
|
8
|
+
|
|
9
|
+
export class Verifier {
|
|
10
|
+
constructor(private didManager: DIDManager) {}
|
|
11
|
+
|
|
12
|
+
async verifyCredential(vc: VerifiableCredential, options: { documentLoader?: (iri: string) => Promise<unknown> } = {}): Promise<VerificationResult> {
|
|
13
|
+
try {
|
|
14
|
+
if (!vc || !vc['@context'] || !vc.type) throw new Error('Invalid credential');
|
|
15
|
+
if (!vc.proof) throw new Error('Credential has no proof');
|
|
16
|
+
const loader = options.documentLoader || createDocumentLoader(this.didManager);
|
|
17
|
+
const vcContext = vc['@context'];
|
|
18
|
+
const ctxs: string[] = Array.isArray(vcContext) ? vcContext.filter((c): c is string => typeof c === 'string') : [String(vcContext)];
|
|
19
|
+
for (const c of ctxs) await loader(c);
|
|
20
|
+
const proofValue = vc.proof;
|
|
21
|
+
const proof = Array.isArray(proofValue) ? proofValue[0] : proofValue;
|
|
22
|
+
const result = await DataIntegrityProofManager.verifyProof(vc, proof as unknown as DataIntegrityProof, { documentLoader: loader });
|
|
23
|
+
return result.verified ? { verified: true, errors: [] } : { verified: false, errors: result.errors ?? ['Verification failed'] };
|
|
24
|
+
} catch (e) {
|
|
25
|
+
const error = e as Error;
|
|
26
|
+
return { verified: false, errors: [error?.message ?? 'Unknown error in verifyCredential'] };
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async verifyPresentation(vp: VerifiablePresentation, options: { documentLoader?: (iri: string) => Promise<unknown> } = {}): Promise<VerificationResult> {
|
|
31
|
+
try {
|
|
32
|
+
if (!vp || !vp['@context'] || !vp.type) throw new Error('Invalid presentation');
|
|
33
|
+
if (!vp.proof) throw new Error('Presentation has no proof');
|
|
34
|
+
const loader = options.documentLoader || createDocumentLoader(this.didManager);
|
|
35
|
+
const vpContext = vp['@context'];
|
|
36
|
+
const ctxs: string[] = Array.isArray(vpContext) ? vpContext.filter((c): c is string => typeof c === 'string') : [String(vpContext)];
|
|
37
|
+
for (const c of ctxs) await loader(c);
|
|
38
|
+
if (vp.verifiableCredential) {
|
|
39
|
+
for (const c of vp.verifiableCredential) {
|
|
40
|
+
const res = await this.verifyCredential(c, { documentLoader: loader });
|
|
41
|
+
if (!res.verified) return res;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const proofValue = vp.proof;
|
|
45
|
+
const proof = Array.isArray(proofValue) ? proofValue[0] : proofValue;
|
|
46
|
+
const result = await DataIntegrityProofManager.verifyProof(vp, proof as unknown as DataIntegrityProof, { documentLoader: loader });
|
|
47
|
+
return result.verified ? { verified: true, errors: [] } : { verified: false, errors: result.errors ?? ['Verification failed'] };
|
|
48
|
+
} catch (e) {
|
|
49
|
+
const error = e as Error;
|
|
50
|
+
return { verified: false, errors: [error?.message ?? 'Unknown error in verifyPresentation'] };
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import * as cbor from 'cbor-js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Minimal BBS utility methods ported from legacy for working with
|
|
5
|
+
* Data Integrity BBS (bbs-2023) base and derived proof value encoding.
|
|
6
|
+
*
|
|
7
|
+
* Notes:
|
|
8
|
+
* - This module focuses on serialization/parsing helpers used by callers
|
|
9
|
+
* to pack/unpack proof values. It does not perform signing or verification.
|
|
10
|
+
* - All methods operate on Uint8Array inputs and return multibase strings
|
|
11
|
+
* (base64url with 'u' prefix) where applicable to match the spec.
|
|
12
|
+
*/
|
|
13
|
+
export class BBSCryptosuiteUtils {
|
|
14
|
+
private static encodeBase64urlNoPad(bytes: Uint8Array): string {
|
|
15
|
+
const b64 = Buffer.from(bytes).toString('base64');
|
|
16
|
+
const b64url = b64.replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/g, '');
|
|
17
|
+
return 'u' + b64url;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
private static decodeBase64urlNoPad(s: string): Uint8Array {
|
|
21
|
+
if (!s.startsWith('u')) throw new Error('Not a multibase base64url (u- prefixed) string');
|
|
22
|
+
const raw = s.slice(1);
|
|
23
|
+
const b64 = raw.replace(/-/g, '+').replace(/_/g, '/');
|
|
24
|
+
const pad = b64.length % 4 === 2 ? '==' : b64.length % 4 === 3 ? '=' : '';
|
|
25
|
+
return new Uint8Array(Buffer.from(b64 + pad, 'base64'));
|
|
26
|
+
}
|
|
27
|
+
private static compareBytes(a: Uint8Array, b: number[]): boolean {
|
|
28
|
+
if (a.length !== b.length) return false;
|
|
29
|
+
for (let i = 0; i < b.length; i++) {
|
|
30
|
+
if (a[i] !== b[i]) return false;
|
|
31
|
+
}
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
private static concatBytes(a: Uint8Array, b: Uint8Array): Uint8Array {
|
|
36
|
+
const out = new Uint8Array(a.length + b.length);
|
|
37
|
+
out.set(a, 0);
|
|
38
|
+
out.set(b, a.length);
|
|
39
|
+
return out;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// ===== Base proof (serialize/parse) =====
|
|
43
|
+
|
|
44
|
+
static serializeBaseProofValue(
|
|
45
|
+
bbsSignature: Uint8Array,
|
|
46
|
+
bbsHeader: Uint8Array,
|
|
47
|
+
publicKey: Uint8Array,
|
|
48
|
+
hmacKey: Uint8Array,
|
|
49
|
+
mandatoryPointers: string[],
|
|
50
|
+
featureOption: 'baseline' | 'anonymous_holder_binding' | 'pseudonym_issuer_pid' | 'pseudonym_hidden_pid',
|
|
51
|
+
pid?: Uint8Array,
|
|
52
|
+
signerBlind?: Uint8Array
|
|
53
|
+
): string {
|
|
54
|
+
let headerBytes: Uint8Array;
|
|
55
|
+
let components: (Uint8Array | string[] | Uint8Array)[];
|
|
56
|
+
|
|
57
|
+
switch (featureOption) {
|
|
58
|
+
case 'baseline':
|
|
59
|
+
headerBytes = new Uint8Array([0xd9, 0x5d, 0x02]);
|
|
60
|
+
components = [bbsSignature, bbsHeader, publicKey, hmacKey, mandatoryPointers];
|
|
61
|
+
break;
|
|
62
|
+
case 'anonymous_holder_binding':
|
|
63
|
+
headerBytes = new Uint8Array([0xd9, 0x5d, 0x04]);
|
|
64
|
+
if (!signerBlind) throw new Error('signerBlind is required for anonymous_holder_binding');
|
|
65
|
+
components = [bbsSignature, bbsHeader, publicKey, hmacKey, mandatoryPointers, signerBlind];
|
|
66
|
+
break;
|
|
67
|
+
case 'pseudonym_issuer_pid':
|
|
68
|
+
headerBytes = new Uint8Array([0xd9, 0x5d, 0x06]);
|
|
69
|
+
if (!pid) throw new Error('pid is required for pseudonym_issuer_pid');
|
|
70
|
+
components = [bbsSignature, bbsHeader, publicKey, hmacKey, mandatoryPointers, pid];
|
|
71
|
+
break;
|
|
72
|
+
case 'pseudonym_hidden_pid':
|
|
73
|
+
headerBytes = new Uint8Array([0xd9, 0x5d, 0x08]);
|
|
74
|
+
if (!signerBlind) throw new Error('signerBlind is required for pseudonym_hidden_pid');
|
|
75
|
+
components = [bbsSignature, bbsHeader, publicKey, hmacKey, mandatoryPointers, signerBlind];
|
|
76
|
+
break;
|
|
77
|
+
default:
|
|
78
|
+
throw new Error(`Unsupported feature option: ${featureOption}`);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const encodedComponents = cbor.encode(components);
|
|
82
|
+
const proofBytes = BBSCryptosuiteUtils.concatBytes(headerBytes, new Uint8Array(encodedComponents));
|
|
83
|
+
return BBSCryptosuiteUtils.encodeBase64urlNoPad(proofBytes);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
static parseBaseProofValue(proofValue: string): {
|
|
87
|
+
bbsSignature: Uint8Array;
|
|
88
|
+
bbsHeader: Uint8Array;
|
|
89
|
+
publicKey: Uint8Array;
|
|
90
|
+
hmacKey: Uint8Array;
|
|
91
|
+
mandatoryPointers: string[];
|
|
92
|
+
featureOption: 'baseline' | 'anonymous_holder_binding' | 'pseudonym_issuer_pid' | 'pseudonym_hidden_pid' | 'base_proof';
|
|
93
|
+
pid?: Uint8Array;
|
|
94
|
+
signerBlind?: Uint8Array;
|
|
95
|
+
} {
|
|
96
|
+
const decoded = BBSCryptosuiteUtils.decodeBase64urlNoPad(proofValue);
|
|
97
|
+
const header = decoded.slice(0, 3);
|
|
98
|
+
let featureOption: any;
|
|
99
|
+
if (this.compareBytes(header, [0xd9, 0x5d, 0x02])) featureOption = 'baseline';
|
|
100
|
+
else if (this.compareBytes(header, [0xd9, 0x5d, 0x04])) featureOption = 'anonymous_holder_binding';
|
|
101
|
+
else if (this.compareBytes(header, [0xd9, 0x5d, 0x06])) featureOption = 'pseudonym_issuer_pid';
|
|
102
|
+
else if (this.compareBytes(header, [0xd9, 0x5d, 0x08])) featureOption = 'pseudonym_hidden_pid';
|
|
103
|
+
else if (this.compareBytes(header, [0xd9, 0x5d, 0x03])) featureOption = 'base_proof';
|
|
104
|
+
else throw new Error('Invalid BBS base proof header');
|
|
105
|
+
|
|
106
|
+
const components: any[] = cbor.decode(decoded.slice(3).buffer) as any[];
|
|
107
|
+
const base = {
|
|
108
|
+
bbsSignature: components[0] as Uint8Array,
|
|
109
|
+
bbsHeader: components[1] as Uint8Array,
|
|
110
|
+
publicKey: components[2] as Uint8Array,
|
|
111
|
+
hmacKey: components[3] as Uint8Array,
|
|
112
|
+
mandatoryPointers: components[4] as string[],
|
|
113
|
+
featureOption
|
|
114
|
+
} as any;
|
|
115
|
+
|
|
116
|
+
if (featureOption === 'anonymous_holder_binding' || featureOption === 'pseudonym_hidden_pid') {
|
|
117
|
+
base.signerBlind = components[5] as Uint8Array;
|
|
118
|
+
}
|
|
119
|
+
if (featureOption === 'pseudonym_issuer_pid') {
|
|
120
|
+
base.pid = components[5] as Uint8Array;
|
|
121
|
+
}
|
|
122
|
+
return base;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// ===== Label map compression helpers =====
|
|
126
|
+
|
|
127
|
+
private static compressLabelMap(labelMap: { [key: string]: string }): { [key: string]: string } {
|
|
128
|
+
const map: { [key: string]: string } = {};
|
|
129
|
+
for (const [k, v] of Object.entries(labelMap)) {
|
|
130
|
+
const c14nMatch = k.match(/^c14n(\d+)$/);
|
|
131
|
+
const bMatch = v.match(/^b(\d+)$/);
|
|
132
|
+
if (!c14nMatch || !bMatch) {
|
|
133
|
+
throw new Error(`Invalid label map entry: ${k} -> ${v}`);
|
|
134
|
+
}
|
|
135
|
+
const key = parseInt(c14nMatch[1], 10);
|
|
136
|
+
const value = parseInt(bMatch[1], 10);
|
|
137
|
+
map[key] = value.toString();
|
|
138
|
+
}
|
|
139
|
+
return map;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
private static decompressLabelMap(compressed: { [key: string]: string }): { [key: string]: string } {
|
|
143
|
+
const map: { [key: string]: string } = {};
|
|
144
|
+
for (const [k, v] of Object.entries(compressed)) {
|
|
145
|
+
map[`c14n${k}`] = `b${v}`;
|
|
146
|
+
}
|
|
147
|
+
return map;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// ===== Derived proof (serialize/parse) =====
|
|
151
|
+
|
|
152
|
+
static serializeDerivedProofValue(
|
|
153
|
+
bbsProof: Uint8Array,
|
|
154
|
+
labelMap: { [key: string]: string },
|
|
155
|
+
mandatoryIndexes: number[],
|
|
156
|
+
selectiveIndexes: number[],
|
|
157
|
+
presentationHeader: Uint8Array,
|
|
158
|
+
featureOption: 'baseline' | 'anonymous_holder_binding' | 'pseudonym',
|
|
159
|
+
pseudonym?: string,
|
|
160
|
+
lengthBBSMessages?: number
|
|
161
|
+
): string {
|
|
162
|
+
const compressedLabelMap = this.compressLabelMap(labelMap);
|
|
163
|
+
|
|
164
|
+
let headerBytes: Uint8Array;
|
|
165
|
+
let components: (Uint8Array | { [key: string]: string } | number[] | number | string)[];
|
|
166
|
+
|
|
167
|
+
switch (featureOption) {
|
|
168
|
+
case 'baseline':
|
|
169
|
+
headerBytes = new Uint8Array([0xd9, 0x5d, 0x03]);
|
|
170
|
+
components = [
|
|
171
|
+
bbsProof,
|
|
172
|
+
compressedLabelMap,
|
|
173
|
+
mandatoryIndexes,
|
|
174
|
+
selectiveIndexes,
|
|
175
|
+
presentationHeader
|
|
176
|
+
];
|
|
177
|
+
break;
|
|
178
|
+
case 'anonymous_holder_binding':
|
|
179
|
+
if (typeof lengthBBSMessages !== 'number') {
|
|
180
|
+
throw new Error('lengthBBSMessages is required for anonymous_holder_binding');
|
|
181
|
+
}
|
|
182
|
+
headerBytes = new Uint8Array([0xd9, 0x5d, 0x05]);
|
|
183
|
+
components = [
|
|
184
|
+
bbsProof,
|
|
185
|
+
compressedLabelMap,
|
|
186
|
+
mandatoryIndexes,
|
|
187
|
+
selectiveIndexes,
|
|
188
|
+
presentationHeader,
|
|
189
|
+
lengthBBSMessages
|
|
190
|
+
];
|
|
191
|
+
break;
|
|
192
|
+
case 'pseudonym':
|
|
193
|
+
if (!pseudonym || typeof lengthBBSMessages !== 'number') {
|
|
194
|
+
throw new Error('pseudonym and lengthBBSMessages are required for pseudonym features');
|
|
195
|
+
}
|
|
196
|
+
headerBytes = new Uint8Array([0xd9, 0x5d, 0x07]);
|
|
197
|
+
components = [
|
|
198
|
+
bbsProof,
|
|
199
|
+
compressedLabelMap,
|
|
200
|
+
mandatoryIndexes,
|
|
201
|
+
selectiveIndexes,
|
|
202
|
+
presentationHeader,
|
|
203
|
+
pseudonym,
|
|
204
|
+
lengthBBSMessages
|
|
205
|
+
];
|
|
206
|
+
break;
|
|
207
|
+
default:
|
|
208
|
+
throw new Error(`Unsupported feature option: ${featureOption}`);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
const encodedComponents = cbor.encode(components);
|
|
212
|
+
const proofBytes = this.concatBytes(headerBytes, new Uint8Array(encodedComponents));
|
|
213
|
+
return this.encodeBase64urlNoPad(proofBytes);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
static parseDerivedProofValue(proofValue: string): {
|
|
217
|
+
bbsProof: Uint8Array;
|
|
218
|
+
labelMap: { [key: string]: string };
|
|
219
|
+
mandatoryIndexes: number[];
|
|
220
|
+
selectiveIndexes: number[];
|
|
221
|
+
presentationHeader: Uint8Array;
|
|
222
|
+
featureOption: 'baseline' | 'anonymous_holder_binding' | 'pseudonym';
|
|
223
|
+
pseudonym?: string;
|
|
224
|
+
lengthBBSMessages?: number;
|
|
225
|
+
} {
|
|
226
|
+
const decoded = this.decodeBase64urlNoPad(proofValue);
|
|
227
|
+
const header = decoded.slice(0, 3);
|
|
228
|
+
let featureOption: 'baseline' | 'anonymous_holder_binding' | 'pseudonym';
|
|
229
|
+
if (this.compareBytes(header, [0xd9, 0x5d, 0x03])) featureOption = 'baseline';
|
|
230
|
+
else if (this.compareBytes(header, [0xd9, 0x5d, 0x05])) featureOption = 'anonymous_holder_binding';
|
|
231
|
+
else if (this.compareBytes(header, [0xd9, 0x5d, 0x07])) featureOption = 'pseudonym';
|
|
232
|
+
else throw new Error('Invalid BBS derived proof header');
|
|
233
|
+
|
|
234
|
+
const components: any[] = cbor.decode(decoded.slice(3).buffer) as any[];
|
|
235
|
+
const decompressedLabelMap = this.decompressLabelMap(components[1]);
|
|
236
|
+
const result: any = {
|
|
237
|
+
bbsProof: components[0],
|
|
238
|
+
labelMap: decompressedLabelMap,
|
|
239
|
+
mandatoryIndexes: components[2],
|
|
240
|
+
selectiveIndexes: components[3],
|
|
241
|
+
presentationHeader: components[4],
|
|
242
|
+
featureOption
|
|
243
|
+
};
|
|
244
|
+
if (featureOption === 'anonymous_holder_binding') {
|
|
245
|
+
result.lengthBBSMessages = components[5];
|
|
246
|
+
} else if (featureOption === 'pseudonym') {
|
|
247
|
+
result.pseudonym = components[5];
|
|
248
|
+
result.lengthBBSMessages = components[6];
|
|
249
|
+
}
|
|
250
|
+
return result;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { sha256 } from '@noble/hashes/sha2.js';
|
|
2
|
+
|
|
3
|
+
export type BbsKeyPair = {
|
|
4
|
+
publicKey: Uint8Array;
|
|
5
|
+
privateKey: Uint8Array;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export class BbsSimple {
|
|
9
|
+
static readonly CIPHERSUITE = 'BLS12-381-SHA-256';
|
|
10
|
+
|
|
11
|
+
static async sign(messages: Uint8Array[], keypair: BbsKeyPair, header?: Uint8Array): Promise<Uint8Array> {
|
|
12
|
+
const headerBytes = header ?? new Uint8Array(sha256(new Uint8Array(0)));
|
|
13
|
+
throw new Error('BbsSimple.sign is not implemented');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
static async verify(messages: Uint8Array[], signature: Uint8Array, publicKey: Uint8Array, header?: Uint8Array): Promise<boolean> {
|
|
17
|
+
const headerBytes = header ?? new Uint8Array(sha256(new Uint8Array(0)));
|
|
18
|
+
throw new Error('BbsSimple.verify is not implemented');
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { base58 } from '@scure/base';
|
|
2
|
+
import * as ed25519 from '@noble/ed25519';
|
|
3
|
+
import { canonize, canonizeProof } from '../utils/jsonld';
|
|
4
|
+
import { multikey } from '../../crypto/Multikey';
|
|
5
|
+
import { sha256Bytes } from '../../utils/hash';
|
|
6
|
+
|
|
7
|
+
export interface DataIntegrityProof {
|
|
8
|
+
type: 'DataIntegrityProof';
|
|
9
|
+
cryptosuite: string;
|
|
10
|
+
created?: string;
|
|
11
|
+
verificationMethod: string;
|
|
12
|
+
proofPurpose: string;
|
|
13
|
+
proofValue: string;
|
|
14
|
+
id?: string;
|
|
15
|
+
previousProof?: string | string[];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface VerificationResult {
|
|
19
|
+
verified: boolean;
|
|
20
|
+
errors?: string[];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export class EdDSACryptosuiteManager {
|
|
24
|
+
|
|
25
|
+
static async createProof(document: any, options: any): Promise<DataIntegrityProof> {
|
|
26
|
+
const proofConfig = await this.createProofConfiguration(options);
|
|
27
|
+
const transformedData = await this.transform(document, options);
|
|
28
|
+
const hashData = await this.hash(transformedData, proofConfig, options);
|
|
29
|
+
let privateKey: Uint8Array;
|
|
30
|
+
if (typeof options.privateKey === 'string') {
|
|
31
|
+
const dec = multikey.decodePrivateKey(options.privateKey);
|
|
32
|
+
if (dec.type !== 'Ed25519') throw new Error('Invalid key type for EdDSA');
|
|
33
|
+
privateKey = dec.key;
|
|
34
|
+
} else if (options.privateKey instanceof Uint8Array) {
|
|
35
|
+
privateKey = options.privateKey;
|
|
36
|
+
} else {
|
|
37
|
+
throw new Error('Invalid private key format');
|
|
38
|
+
}
|
|
39
|
+
const proofValueBytes = await this.sign({ data: hashData, privateKey });
|
|
40
|
+
delete (proofConfig as any)['@context'];
|
|
41
|
+
return { ...proofConfig, proofValue: base58.encode(proofValueBytes) } as DataIntegrityProof;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
static async verifyProof(document: any, proof: DataIntegrityProof, options: any): Promise<VerificationResult> {
|
|
45
|
+
try {
|
|
46
|
+
const documentToVerify = { ...document };
|
|
47
|
+
delete (documentToVerify as any).proof;
|
|
48
|
+
const transformedData = await this.transform(documentToVerify, options);
|
|
49
|
+
const hashData = await this.hash(transformedData, { '@context': document['@context'], ...proof }, options);
|
|
50
|
+
const vmDoc = await options.documentLoader(proof.verificationMethod);
|
|
51
|
+
const pk = vmDoc.document.publicKeyMultibase as string;
|
|
52
|
+
const dec = multikey.decodePublicKey(pk);
|
|
53
|
+
if (dec.type !== 'Ed25519') throw new Error('Invalid key type for EdDSA');
|
|
54
|
+
const signature = base58.decode(proof.proofValue);
|
|
55
|
+
const verified = await this.verify({ data: hashData, signature, publicKey: dec.key });
|
|
56
|
+
return verified ? { verified: true } : { verified: false, errors: ['Proof verification failed'] };
|
|
57
|
+
} catch (e: any) {
|
|
58
|
+
return { verified: false, errors: [e?.message ?? 'Unknown verification error'] };
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
private static async createProofConfiguration(options: any): Promise<any> {
|
|
63
|
+
return {
|
|
64
|
+
'@context': 'https://w3id.org/security/data-integrity/v2',
|
|
65
|
+
type: 'DataIntegrityProof',
|
|
66
|
+
cryptosuite: 'eddsa-rdfc-2022',
|
|
67
|
+
created: new Date().toISOString(),
|
|
68
|
+
verificationMethod: options.verificationMethod,
|
|
69
|
+
proofPurpose: options.proofPurpose || 'assertionMethod',
|
|
70
|
+
...(options.challenge && { challenge: options.challenge }),
|
|
71
|
+
...(options.domain && { domain: options.domain })
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
private static async transform(document: any, options: any): Promise<string> {
|
|
76
|
+
return await canonize(document, { documentLoader: options.documentLoader });
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
private static async hash(transformedData: string, proofConfig: any, options: any): Promise<Uint8Array> {
|
|
80
|
+
const canonicalProofConfig = await canonizeProof(proofConfig, { documentLoader: options.documentLoader });
|
|
81
|
+
const proofConfigHash = await sha256Bytes(canonicalProofConfig);
|
|
82
|
+
const documentHash = await sha256Bytes(transformedData);
|
|
83
|
+
return new Uint8Array([...proofConfigHash, ...documentHash]);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
static async sign({ data, privateKey }: { data: Uint8Array; privateKey: Uint8Array }): Promise<Uint8Array> {
|
|
87
|
+
if (privateKey.length !== 32) {
|
|
88
|
+
if (privateKey.length === 64) privateKey = privateKey.slice(32);
|
|
89
|
+
else throw new Error('Invalid private key length');
|
|
90
|
+
}
|
|
91
|
+
const signature = await ed25519.signAsync(Buffer.from(data).toString('hex'), Buffer.from(privateKey).toString('hex'));
|
|
92
|
+
return signature;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
static async verify({ data, signature, publicKey }: { data: Uint8Array; signature: Uint8Array; publicKey: Uint8Array }): Promise<boolean> {
|
|
96
|
+
return await ed25519.verifyAsync(Buffer.from(signature).toString('hex'), Buffer.from(data).toString('hex'), Buffer.from(publicKey).toString('hex'));
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { DIDManager } from '../did/DIDManager';
|
|
2
|
+
|
|
3
|
+
type LoadedDocument = { document: unknown; documentUrl: string; contextUrl: string | null };
|
|
4
|
+
|
|
5
|
+
interface ContextDocument {
|
|
6
|
+
'@context': {
|
|
7
|
+
'@version': number;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const CONTEXTS: Record<string, ContextDocument> = {
|
|
12
|
+
// Provide 1.1-compatible stubs for jsonld canonize
|
|
13
|
+
'https://www.w3.org/ns/credentials/v2': { '@context': { '@version': 1.1 } },
|
|
14
|
+
'https://w3id.org/security/data-integrity/v2': { '@context': { '@version': 1.1 } }
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export class DocumentLoader {
|
|
18
|
+
constructor(private didManager: DIDManager) {}
|
|
19
|
+
|
|
20
|
+
async load(iri: string): Promise<LoadedDocument> {
|
|
21
|
+
if (iri.startsWith('did:')) {
|
|
22
|
+
return this.resolveDID(iri);
|
|
23
|
+
}
|
|
24
|
+
const doc = CONTEXTS[iri];
|
|
25
|
+
if (doc) {
|
|
26
|
+
return { document: doc, documentUrl: iri, contextUrl: null };
|
|
27
|
+
}
|
|
28
|
+
throw new Error(`Document not found: ${iri}`);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
private async resolveDID(didUrl: string): Promise<LoadedDocument> {
|
|
32
|
+
const [did, fragment] = didUrl.split('#');
|
|
33
|
+
const didDoc = await this.didManager.resolveDID(did);
|
|
34
|
+
if (!didDoc) {
|
|
35
|
+
throw new Error(`DID not resolved: ${did}`);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
interface DIDDocWithContext {
|
|
39
|
+
'@context'?: unknown;
|
|
40
|
+
verificationMethod?: Array<{ id?: string }>;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const didDocTyped = didDoc as DIDDocWithContext;
|
|
44
|
+
|
|
45
|
+
if (fragment) {
|
|
46
|
+
// If a VM was registered explicitly, prefer it
|
|
47
|
+
const cached = verificationMethodRegistry.get(didUrl);
|
|
48
|
+
if (cached) {
|
|
49
|
+
return {
|
|
50
|
+
document: { '@context': didDocTyped['@context'], ...cached },
|
|
51
|
+
documentUrl: didUrl,
|
|
52
|
+
contextUrl: null
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
const vms = didDocTyped.verificationMethod;
|
|
56
|
+
const vm = vms?.find((m) => m.id === didUrl);
|
|
57
|
+
if (vm) {
|
|
58
|
+
return {
|
|
59
|
+
document: { '@context': didDocTyped['@context'], ...vm },
|
|
60
|
+
documentUrl: didUrl,
|
|
61
|
+
contextUrl: null
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
document: { '@context': didDocTyped['@context'], id: didUrl },
|
|
66
|
+
documentUrl: didUrl,
|
|
67
|
+
contextUrl: null
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
return { document: didDoc, documentUrl: didUrl, contextUrl: null };
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export const createDocumentLoader = (didManager: DIDManager) =>
|
|
75
|
+
(iri: string) => new DocumentLoader(didManager).load(iri);
|
|
76
|
+
|
|
77
|
+
export const verificationMethodRegistry: Map<string, Record<string, unknown>> = new Map();
|
|
78
|
+
export function registerVerificationMethod(vm: Record<string, unknown> & { id?: string }): void {
|
|
79
|
+
if (vm?.id) verificationMethodRegistry.set(vm.id, vm);
|
|
80
|
+
}
|
|
81
|
+
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { EdDSACryptosuiteManager, type DataIntegrityProof } from '../cryptosuites/eddsa';
|
|
2
|
+
|
|
3
|
+
export interface VerificationResult { verified: boolean; errors?: string[] }
|
|
4
|
+
|
|
5
|
+
export interface ProofOptions {
|
|
6
|
+
verificationMethod: string;
|
|
7
|
+
proofPurpose: string;
|
|
8
|
+
privateKey?: Uint8Array | string;
|
|
9
|
+
type: 'DataIntegrityProof';
|
|
10
|
+
created?: string;
|
|
11
|
+
cryptosuite: string;
|
|
12
|
+
documentLoader?: (url: string) => Promise<any>;
|
|
13
|
+
previousProof?: string | string[];
|
|
14
|
+
challenge?: string;
|
|
15
|
+
domain?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export class DataIntegrityProofManager {
|
|
19
|
+
static async createProof(document: any, options: ProofOptions): Promise<DataIntegrityProof> {
|
|
20
|
+
if (options.cryptosuite !== 'eddsa-rdfc-2022') {
|
|
21
|
+
throw new Error(`Unsupported cryptosuite: ${options.cryptosuite}`);
|
|
22
|
+
}
|
|
23
|
+
return await EdDSACryptosuiteManager.createProof(document, options);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
static async verifyProof(document: any, proof: DataIntegrityProof, options: any): Promise<VerificationResult> {
|
|
27
|
+
if (proof.cryptosuite !== 'eddsa-rdfc-2022') {
|
|
28
|
+
return { verified: false, errors: [`Unsupported cryptosuite: ${proof.cryptosuite}`] };
|
|
29
|
+
}
|
|
30
|
+
return await EdDSACryptosuiteManager.verifyProof(document, proof, options);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import jsonld from 'jsonld';
|
|
2
|
+
|
|
3
|
+
export async function canonize(input: any, { documentLoader }: any): Promise<string> {
|
|
4
|
+
return await jsonld.canonize(input, {
|
|
5
|
+
algorithm: 'URDNA2015',
|
|
6
|
+
format: 'application/n-quads',
|
|
7
|
+
documentLoader,
|
|
8
|
+
safe: false,
|
|
9
|
+
useNative: false,
|
|
10
|
+
rdfDirection: 'i18n-datatype'
|
|
11
|
+
} as any);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export async function canonizeProof(proof: any, { documentLoader }: any): Promise<string> {
|
|
15
|
+
const { jws, signatureValue, proofValue, ...rest } = proof;
|
|
16
|
+
return await canonize(rest, { documentLoader });
|
|
17
|
+
}
|
|
18
|
+
|