Verification API

Message Hash Verification Specification

This specification describes how to recreate and verify the message hash from a notarization response. The process follows the EIP-191 standard for message hashing, which is commonly used in Ethereum for message signing.

Prerequisites

  • A programming language of your choice
  • A library that supports EIP-191 message hashing
  • A library for hex encoding

Steps to Recreate Message Hash

  1. Get the Message Response
  • The notarization response contains a message property
  • This message needs to be converted to a string
  1. Hash the Message
  • Use an EIP-191 message hashing function to hash the message string
  • This follows the EIP-191 standard for message hashing
  1. Format the Hash
  • Convert the hash to a hex string
  • Prefix with "0x" to create the final message hash

Example Code (Rust)

use alloy_primitives::utils::eip191_hash_message;
use hex;

// 1. Convert the JSON to a string
let message = serde_json::to_string(&result.message).unwrap_or_default();

// 2. Hash the message using EIP-191
let message_hash = eip191_hash_message(message);

// 3. Format the hash with 0x prefix
let message_hash_hex = format!("0x{}", hex::encode(message_hash));

If using Rust, add these to your Cargo.toml:

[dependencies]
alloy-primitives = "1.2.0"  # Use the latest version
hex = "0.4.3"              # Use the latest version

Using the API

The resulting message_hash_hex can be compared to the message-hash field from the notary response, they should match exactly. Also it can be used to verify the signature using the verifier API:

curl -k -X POST https://verifier.opacity.network/api/verify \
  -H "Content-Type: application/json" \
  -d '{
    "signature": "<signature_from_response>",
    "message": "<message_hash_hex>"
  }'

Notes

  • The message hash is created using the EIP-191 standard, which is commonly used in Ethereum for message signing
  • The message string must be exactly as received from the notarization response
  • The resulting hash will be a 32-byte value encoded as a hex string with "0x" prefix
  • You can use any programming language and library that supports EIP-191 message hashing to implement this process
Previous
Flutter