/// import DidPublicKeyModel from '../models/DidPublicKeyModel'; import KeyUsage from '../KeyUsage'; import { PrivateKey } from 'did-auth-jose-kenhuang'; /** * Class containing reusable cryptographic operations. */ export default class Cryptography { /** * SHA256 hash function. */ static sha256hash(value: Buffer): Buffer; /** * Generates a random pair of SECP256K1 public-private key-pair in JWK format. * NOTE: The public key returned is wrapped as a DidPublicKeyModel for convenient usage. * @returns Public key, followed by private key. */ static generateKeyPairJwk(keyId: string, usage: KeyUsage): Promise<[DidPublicKeyModel, PrivateKey]>; /** * Generates a random pair of SECP256K1 public-private key-pair in HEX format. * @returns Public key, followed by private key. */ static generateKeyPairHex(keyId: string, usage: KeyUsage): Promise<[DidPublicKeyModel, string]>; /** * Signs the given content using the given private key. * @param content Content to be signed. * @param privateKey A SECP256K1 private-key either in HEX string format or JWK format. */ static sign(content: string, privateKey: string | PrivateKey): Promise; /** * Verifies that the given signature matches the given content being signed. * @param content Content signed. * @param encodedSignature Encoded signature. * @param publicKey The public key to be used for verification. * @returns true if signature is successfully verified, false otherwise. */ static verifySignature(content: string, encodedSignature: string, publicKey: DidPublicKeyModel): Promise; }