MetaMUI Cross-Language Compatibility Specification

Version: 2.0.0
Last Updated: 2025-06-16
Status: Deprecated - Native implementations preferred
Signed-off-by: Phantom(phantom@metamui.id)

Important Notice

As of v2.0.0, this specification is deprecated. Each language now provides idiomatic, native implementations optimized for their respective platforms. The cross-language compatibility wrappers have been removed in favor of better performance and security.

For new projects: Use the native APIs provided by each language implementation.

Migration Guide

From Compatibility API to Native APIs

Kotlin (Old Compatibility → New Native)

// Old (Compatibility API)
val compat = Sr25519Compat()
val keypair = compat.generateKeypair()

// New (Native API)
val keypair = KeyPair.generate()

Swift (Old Compatibility → New Native)

// Old (Compatibility API)
let compat = Sr25519Compat()
let keypair = try await compat.generateKeypair()

// New (Native API)
let keypair = try SwiftSchnorrkel.generateKeyPair()

Python (Old Compatibility → New Native)

# Old (Compatibility API)
compat = Sr25519Compat()
keypair = await compat.generateKeypair()

# New (Native API)
keypair = sr25519.generate_keypair()

TypeScript (Old Compatibility → New Native)

// Old (Compatibility API)
const compat = new Sr25519Compat();
const keypair = await compat.generateKeypair();

// New (Native API)
const sr25519 = new MetaMUISr25519();
const keypair = await sr25519.generateKeypair();

Why Native APIs?

  1. Performance: No cross-language call overhead
  2. Security: No cross-language marshaling vulnerabilities
  3. Idiomatic: APIs follow language conventions
  4. Type Safety: Better compile-time guarantees
  5. Smaller Size: No compatibility layer overhead

Native API Documentation

For current API documentation, see:


Legacy Specification (v1.0.0)

The following specification is preserved for historical reference and projects still using v1.x.

Core Principles (v1.0.0)

  1. Consistent Naming: All implementations use camelCase for methods and types
  2. Binary Data: All binary data is represented as platform-native byte arrays
  3. Hex Encoding: Hex strings are lowercase without “0x” prefix unless specified
  4. Async Pattern: All potentially blocking operations are async/Promise-based
  5. Error Handling: Consistent error types with descriptive messages

Common Types (v1.0.0)

interface KeyPair {
    publicKey: Uint8Array    // 32 bytes
    privateKey: Uint8Array   // 32 or 64 bytes depending on algorithm
    algorithm: string        // "ed25519" | "sr25519" | "x25519"
}

interface Signature {
    signature: Uint8Array    // 64 bytes
    algorithm: string        // "ed25519" | "sr25519"
}

interface MnemonicResult {
    mnemonic: string        // Space-separated words
    wordCount: number       // 12 | 15 | 18 | 21 | 24
}

Compatibility Layer Methods (v1.0.0)

The compatibility layer provided these standardized methods across all languages:


Note: This specification is maintained for reference only. New implementations should use native APIs for better performance and security.