Optional
computeOptional method that mathetmatically derives the public key in JWK format from a given private key.
The parameters for public key computation.
A Promise resolving to the public key in JWK format.
Generates a hash digest of the provided data.
The parameters for the digest operation.
A Promise which will be fulfilled with the hash digest.
The digest()
method of the Hasher
interface generates a hash digest of the
input data.
A digest is the output of the hash function. It's a fixed-size string of bytes that uniquely represents the data input into the hash function. The digest is often used for data integrity checks, as any alteration in the input data results in a significantly different digest.
It typically takes the data to digest as input and returns the digest of the data.
Generates a cryptographic key based on the provided parameters.
Optional
params: GenerateKeyInputOptional parameters for the key generation process, specific to the chosen algorithm.
A Promise resolving to the generated private key in the specified output format.
The generateKey()
method of the KeyGenerator
interface generates
private keys suitable for various cryptographic operations. This method can adapt to different
key generation algorithms and input parameters.
The parameters for getting the key URI.
The key URI.
Extracts the public key portion from the given public key in JWK format.
The parameters for public key retrieval.
A Promise resolving to the public key in JWK format.
Unlike computePublicKey()
, the getPublicKey()
method does not mathematically validate the
private key, nor does it derive the public key from the private key. It simply extracts
existing public key properties from the private key JWK object. This makes it suitable for
scenarios where speed is critical and the private key's integrity is already assured.
Signs the provided data.
The parameters for the signing operation.
A Promise resolving to the digital signature as a Uint8Array
.
The sign()
method of the Signer
interface generates a digital signature
for the given data using a cryptographic key. This signature can be used to verify the data's
authenticity and integrity.
Verifies a digital signature associated the provided data.
The parameters for the verification operation.
A Promise resolving to a boolean indicating whether the signature is valid.
The verify()
method of the Signer
interface checks the validity of a
digital signature against the original data and a cryptographic key. It confirms whether the
signature was created by the holder of the corresponding private key and that the data has not
been tampered with.
The
CryptoApi
interface integrates key generation, hashing, and signing functionalities, designed for use with a Key Management System (KMS). It extendsAsymmetricKeyGenerator
for generating asymmetric keys,Hasher
for hash digest computations, andSigner
for signing and verifying operations.Concrete implementations of this interface are intended to be used with a KMS, which is responsible for generating and storing cryptographic keys. The KMS is also responsible for performing cryptographic operations using the keys it manages. The KMS is typically a cloud service, but it can also be a hardware device or software application.
Guidelines for implementing this interface:
KeyIdentifier
. Implementations can use any string as the key identifier (e.g. JWK thumbprint, UUID generated by hosted KMS, etc.).CryptoApi
interface can be passed as an argument to the public API methods of Web5 libraries that involve key material (e.g., DID creation, VC signing, arbitrary data signing/verification, etc.).