jsonld-signatures-merkleproof2019
Version:
A jsonld signature implementation to support MerkleProof2019 verification in Verifiable Credential context
113 lines (110 loc) • 3.56 kB
TypeScript
import { ExplorerAPI, IBlockchainObject, TransactionData } from '@blockcerts/explorer-lookup';
import { IDidDocumentPublicKey } from '@decentralized-identity/did-common-typescript';
export interface PathDefinition {
left?: string;
right?: string;
}
export interface VCProof {
type: string;
created: string;
proofValue?: string;
jws?: string;
proofPurpose: string;
verificationMethod: string;
chainedProofType?: string;
previousProof?: VCProof;
domain?: string;
challenge?: string;
}
export interface DecodedProof {
anchors: string[];
merkleRoot: string;
targetHash: string;
path: PathDefinition[];
}
export interface IVerificationMethod extends IDidDocumentPublicKey {
expires?: string;
revoked?: string;
}
declare const LinkedDataProof: any;
export interface MerkleProof2019Options {
explorerAPIs?: ExplorerAPI[];
executeStepMethod?: (step: string, action: () => any, verificationSuite?: string, type?: string) => Promise<any>;
}
export interface VCDocument {
proof: VCProof | VCProof[];
}
export interface MerkleProof2019API {
options?: MerkleProof2019Options;
issuer?: any;
verificationMethod?: IVerificationMethod;
document: VCDocument;
proof?: VCProof;
proofPurpose?: string;
domain?: string | string[];
challenge?: string;
}
export interface MerkleProof2019VerificationResult {
verified: boolean;
error?: string;
verificationMethod: IVerificationMethod;
}
export interface MerkleProof2019VerifyProofAPI {
documentLoader?: (url: string) => any;
verifyIdentity?: boolean;
}
export declare class LDMerkleProof2019 extends LinkedDataProof {
/**
* @param [issuer] {string} A key id URL to the paired public key.
* @param [verificationMethod] {string} A key id URL to the paired public key.
* @param [proof] {object} a JSON-LD document with options to use for
* the `proof` node (e.g. any other custom fields can be provided here
* using a context different from security-v2).
* @param [document] {document} document used and signed by the MerkleProof2019 signature
*/
challenge: string;
domain: string[];
type: string;
issuer: any;
verificationMethod: IVerificationMethod;
proof: VCProof;
proofValue: DecodedProof;
proofPurpose: string;
document: VCDocument;
explorerAPIs: ExplorerAPI[];
chain: IBlockchainObject;
txData: TransactionData;
localDocumentHash: string;
derivedIssuingAddress: string;
documentLoader: any;
proofVerificationProcess: string[];
identityVerificationProcess: string[];
private transactionId;
constructor({ issuer, verificationMethod, document, proof, options, proofPurpose, domain, challenge }: MerkleProof2019API);
static decodeMerkleProof2019(proof: VCProof): DecodedProof;
setProof(externalProof?: VCProof): void;
verifyProof({ documentLoader, verifyIdentity }?: MerkleProof2019VerifyProofAPI): Promise<MerkleProof2019VerificationResult>;
verifyIdentity(): Promise<void>;
getProofVerificationProcess(): string[];
getIdentityVerificationProcess(): string[];
getIssuerPublicKey(): string;
getIssuanceTime(): string;
getChain(): IBlockchainObject;
private getTxData;
private adaptProofVerificationProcessToMocknet;
private adaptIdentityVerificationProcessToMocknet;
private setOptions;
private executeStep;
private verifyProcess;
private assertProofValidity;
private checkMerkleRoot;
private compareHashes;
private computeLocalHash;
private checkReceipt;
private getTransactionId;
private fetchRemoteHash;
private deriveIssuingAddressFromPublicKey;
private ensureVerificationMethodValidity;
private compareIssuingAddress;
}
export {};