aries / net.globalid.aries.decorators.signature / SignatureUtils

SignatureUtils

object SignatureUtils

This is an utility for:

  1. signing data
  2. verifying signature and getting the data back from it

The corresponding Aries RFC is RFC 0234: Signature Decorator.

Functions

createSignature

Creates a signature for any data. The data is serialized to JSON and converted to a byte array using UTF-8 charset. Per the RFC, the message to sign should be a 64-bit integer representing UNIX time and the serialized data from before. Currently, only the ed25519sha256_single signature scheme is supported: we must sign the data using our public key (i.e. verification key). This scheme requires:

fun createSignature(agent: Agent, signerVerKey: String, data: Any): Single<SignatureDecorator>

verifySignature

Verifies a signature from a given SignatureDecorator and returns the plaintext data. By the signature schema, we base64 URL-safe decode the signer (to get the plaintext public key), the message (to get the byte array) and the signature (to get the byte array). If the signature is valid, we base64 URL-safe decode the signature data, skipping the first 8 bytes (the first byte contains the UNIX time). The remaining bytes represent the object of type T.

fun <T : Any> verifySignature(decorator: SignatureDecorator, type: Class<T>): Single<T>

See SignatureUtils.verifySignature.

fun <T : Any> verifySignature(decorator: SignatureDecorator): Single<T>