Skip to content

Introducing Crossmark: Expanding Dhali’s Web3 Ecosystem

We are excited to announce the integration of Crossmark into the Dhali ecosystem. This integration extends all of Dhali's functionality to Crossmark users, bringing the power of next generation API payments to a broader audience. Here’s a closer look at what this means for our users and the innovative approaches we've taken to make this integration seamless.

Extending Dhali’s Functionality to Crossmark Users

With Crossmark, users gain full access to Dhali’s comprehensive API ownership and key generation features, available through our platform at app.dhali.io. Crossmark users can also generate API keys using Dhali's secure payment terminal at pay.dhali.io, ensuring a smooth and secure transaction process for API users.

Fast

A Browser-Based Wallet with Local Signing for Enhanced Security

One of the features of Crossmark is its purely browser-based architecture. To authenticate users, we provide a message that they sign locally, ensuring their private keys never leave their devices. This signed message contains both the user's wallet address and a unique nonce, which we then verify on our backend.

Here’s the message structure used for authentication:

{
  "address": "<address>",
  "nonce": "<nonce>"
}

Re-Implementing Payment Channel Authorization

Payment Channel Authorization presented a unique challenge during the integration, as it is not strictly an XRPL transaction and therefore isn’t natively supported by Crossmark. However, this feature will be coming to Crossmark soon. To overcome this, we took a first principles approach by re-implementing the ripple payment channel authorization process.

By diving deep into the XRPL's source code, specifically the ripple::doChannelAuthorize function from the rippled codebase here, we recreated the necessary signing logic to handle payment channel authorizations within Crossmark.

Below is a code block where you can view our re-implementation:

const int HASH_PREFIX_PAYMENT_CHANNEL_CLAIM = 0x434C4D00;
Uint8List serializePayChanAuthorization(Uint8List channelIdBytes, int drops) {
  final builder = BytesBuilder();

  // Add 32-bit hash prefix
  final prefixData = ByteData(4);
  prefixData.setUint32(0, HASH_PREFIX_PAYMENT_CHANNEL_CLAIM, Endian.big);
  builder.add(prefixData.buffer.asUint8List());

  // Add channelId (32 bytes)
  builder.add(channelIdBytes);

  // Split the 64-bit drops amount into high and low 32-bit integers
  final amountData = ByteData(8);
  final high = (drops ~/ 0x100000000) & 0xFFFFFFFF; // High 32 bits
  final low = drops & 0xFFFFFFFF; // Low 32 bits
  amountData.setUint32(0, high, Endian.big);
  amountData.setUint32(4, low, Endian.big);
  builder.add(amountData.buffer.asUint8List());

  return builder.toBytes();
}

Bridging Crossmark with Flutter

Because our front-end is built using Flutter, a cross-platform framework, we faced the additional task of creating bindings between Crossmark and Dart (the language used by Flutter), which can be found at this repository.

Conclusion

The integration of Crossmark into the Dhali ecosystem marks a significant step forward in our mission to support next generation payment technology for API monetisation. By leveraging a browser-based wallet with local signing, re-implementing critical payment channel authorization, and building Flutter bindings, we’ve ensured that Crossmark users can fully benefit from the powerful tools Dhali offers.

Stay tuned for more updates as we continue to innovate and expand the capabilities of the Dhali platform.