osm15

package module
v0.2.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 19, 2026 License: MIT Imports: 15 Imported by: 1

README

Octra Sign Message Standards - OSM-15

Network Protocol Team Coverage Status

A high-performance Go library implementing the OSM-15 (Octra Structured Message) standard. Designed for secure, recursive, and domain-isolated data signing in the Octra ecosystem.

🚀 Key Functions for Developers

1. Identity & Address

Convert Ed25519 public keys into the official Octra address format.

// Convert public key bytes to "oct..." address
address := osm15.PublicKeyToAddress(publicKeyBytes)
2. Signing Structured Data

Sign complex messages with recursive type support.

data := osm15.TypedData{
    Domain: osm15.TypedDomain{Name: "OctraPay", Version: "1", ChainID: 1},
    Types: map[string][]osm15.TypedMember{
        "Transaction": {
            {Name: "amount", Type: "uint256"},
            {Name: "to", Type: "address"},
        },
    },
    PrimaryType: "Transaction",
    Message: map[string]interface{}{
        "amount": 5000,
        "to": "oct1abc...",
    },
}

// Returns Base64 signature
signature, err := osm15.SignTypedData(data, privateKeyBase64)
3. Verification & Signer Recovery

Verify if a signature is valid and recover the signer's address.

// Boolean verification
isValid, err := osm15.VerifyTypedData(data, signature, publicKeyBase64)

// Get signer's Octra address directly from signature
address, err := osm15.GetSignerAddress(data, signature, publicKeyBase64)
4. JSON Export & Import

Easily export the signed payload to JSON or verify directly from a JSON file.

// Export to formatted JSON
jsonBytes, err := osm15.ExportToJSON(data, signature)

// Verify directly from JSON payload
isValid, err := osm15.VerifyFromJSON(jsonBytes, publicKeyBase64)
5. Debugging Signing Text

Get the raw string that is being hashed and signed (for debugging or hardware wallet display).

rawText, err := osm15.GetSigningText(data)
fmt.Println(rawText)

⚙️ Technical Specifications

  • Hashing: Recursive SHA-256 (EIP-712 Style)
  • Signature: Ed25519
  • Prefix: \x19Octra Typed Data:
  • Encoding: Base64 (Signature & Keys) / Base58 (Address)

🛠 Installation

go get [github.com/dayuwidayadi57/osm15](https://github.com/dayuwidayadi57/osm15)

💡 Why OSM-15?

If you are familiar with Ethereum's EIP-712, you will feel at home. OSM-15 brings:

  • Human-readable signing: Users see exactly what they sign.
  • EIP-712 Style: Familiar domain separation and recursive hashing.
  • Enhanced Security: Optimized for Ed25519 and SHA-256 (Octra Native). cat < README.md

OSM15

Octra Go SDK Standardized Protocol

Professional Open Source Contributor Mode.

Versioning

  • Version: v0.2.2
  • Status: Stable
  • Date: 2026-01-19

📜 License

(c) 2026 QiubitLabs Team. Licensed under the MIT License.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecryptKey

func DecryptKey(keystoreJSON []byte, password string) (string, error)

func EncryptKey

func EncryptKey(privateKeyB64 string, password string) ([]byte, error)

func ExportToJSON

func ExportToJSON(data TypedData, signature string) ([]byte, error)

func GenerateKeypair

func GenerateKeypair() (string, string, error)

func GetSignerAddress

func GetSignerAddress(data TypedData, signatureB64 string, publicKeyB64 string) (string, error)

func GetSigningText

func GetSigningText(data TypedData) (string, error)

func HashTypedData

func HashTypedData(data TypedData) ([]byte, error)

func PublicKeyToAddress

func PublicKeyToAddress(publicKey []byte) string

func SignTypedData

func SignTypedData(data TypedData, privateKeyB64 string) (string, error)

func VerifyFromJSON

func VerifyFromJSON(payloadJSON []byte, publicKeyB64 string) (bool, error)

func VerifyTypedData

func VerifyTypedData(data TypedData, signatureB64 string, publicKeyB64 string) (bool, error)

Types

type Crypto

type Crypto struct {
	Cipher       string `json:"cipher"`
	CipherText   string `json:"ciphertext"`
	CipherParams struct {
		IV string `json:"iv"`
	} `json:"cipherparams"`
	Kdf       string `json:"kdf"`
	KdfParams struct {
		N    int    `json:"n"`
		R    int    `json:"r"`
		P    int    `json:"p"`
		Salt string `json:"salt"`
	} `json:"kdfparams"`
}

type Keystore

type Keystore struct {
	Address string `json:"address"`
	Crypto  Crypto `json:"crypto"`
}

type SignedPayload

type SignedPayload struct {
	Data      TypedData `json:"data"`
	Signature string    `json:"signature"`
}

type TypedData

type TypedData struct {
	Domain      TypedDomain              `json:"domain"`
	Types       map[string][]TypedMember `json:"types"`
	PrimaryType string                   `json:"primaryType"`
	Message     map[string]interface{}   `json:"message"`
}

type TypedDomain

type TypedDomain struct {
	Name    string `json:"name"`
	Version string `json:"version"`
	ChainID int    `json:"chainId"`
}

func (TypedDomain) ToMap

func (d TypedDomain) ToMap() map[string]interface{}

type TypedMember

type TypedMember struct {
	Name string `json:"name"`
	Type string `json:"type"`
}

Directories

Path Synopsis
cmd
osm15 command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL