Skip to content

CosmosStealthService

SIP Protocol API Reference v0.7.0


SIP Protocol API Reference / CosmosStealthService

Defined in: @sip-protocol/sdk/dist/index-BYZbDjal.d.ts:2898

Cosmos Stealth Address Service

Provides stealth address generation and key derivation for Cosmos chains. Reuses secp256k1 logic from core stealth module, adding Cosmos-specific address formatting.

new CosmosStealthService(): CosmosStealthService

CosmosStealthService

generateStealthMetaAddress(chain, label?): object

Defined in: @sip-protocol/sdk/dist/index-BYZbDjal.d.ts:2914

Generate a stealth meta-address for a Cosmos chain

CosmosChainId

Cosmos chain identifier

string

Optional human-readable label

object

Stealth meta-address and private keys

metaAddress: StealthMetaAddress

spendingPrivateKey: `0x${string}`

viewingPrivateKey: `0x${string}`

If chain is invalid

const service = new CosmosStealthService()
const { metaAddress, spendingPrivateKey, viewingPrivateKey } =
service.generateStealthMetaAddress('cosmos', 'My Cosmos Wallet')

generateStealthAddress(spendingPubKey, viewingPubKey, chain): CosmosStealthResult

Defined in: @sip-protocol/sdk/dist/index-BYZbDjal.d.ts:2939

Generate a one-time stealth address for a Cosmos chain

Uint8Array

Recipient’s spending public key (33-byte compressed)

Uint8Array

Recipient’s viewing public key (33-byte compressed)

CosmosChainId

Cosmos chain identifier

CosmosStealthResult

Cosmos stealth address with bech32 encoding

If keys or chain are invalid

const service = new CosmosStealthService()
const result = service.generateStealthAddress(
spendingKey,
viewingKey,
'osmosis'
)
console.log(result.stealthAddress) // "osmo1..."

generateStealthAddressFromMeta(recipientMetaAddress, chain): CosmosStealthResult

Defined in: @sip-protocol/sdk/dist/index-BYZbDjal.d.ts:2956

Generate stealth address from StealthMetaAddress

Convenience method that accepts a StealthMetaAddress directly.

StealthMetaAddress

Recipient’s stealth meta-address

CosmosChainId

Cosmos chain identifier

CosmosStealthResult

Cosmos stealth address with bech32 encoding

If meta-address or chain are invalid

const service = new CosmosStealthService()
const result = service.generateStealthAddressFromMeta(metaAddress, 'cosmos')

stealthKeyToCosmosAddress(publicKey, prefix): string

Defined in: @sip-protocol/sdk/dist/index-BYZbDjal.d.ts:2977

Convert stealth public key to Cosmos bech32 address

Algorithm:

  1. SHA256 hash of compressed public key
  2. RIPEMD160 hash of SHA256 hash
  3. Bech32 encode with chain prefix

Uint8Array

Compressed secp256k1 public key (33 bytes)

string

Bech32 address prefix (e.g., “cosmos”, “osmo”)

string

Bech32-encoded address

If public key is invalid

const service = new CosmosStealthService()
const address = service.stealthKeyToCosmosAddress(pubKey, 'cosmos')
// Returns: "cosmos1abc..."

deriveStealthPrivateKey(stealthAddress, spendingPrivateKey, viewingPrivateKey): StealthAddressRecovery

Defined in: @sip-protocol/sdk/dist/index-BYZbDjal.d.ts:2998

Derive stealth private key for recipient to claim funds

StealthAddress

The stealth address to recover (as StealthAddress)

`0x${string}`

Recipient’s spending private key

`0x${string}`

Recipient’s viewing private key

StealthAddressRecovery

Recovery data with derived private key

If any input is invalid

const service = new CosmosStealthService()
const recovery = service.deriveStealthPrivateKey(
stealthAddress,
spendingPrivKey,
viewingPrivKey
)
// Use recovery.privateKey to spend funds

decodeBech32Address(address): object

Defined in: @sip-protocol/sdk/dist/index-BYZbDjal.d.ts:3016

Decode a Cosmos bech32 address to raw hash

string

Bech32-encoded address

object

Decoded address hash (20 bytes)

prefix: string

hash: Uint8Array

If address is invalid

const service = new CosmosStealthService()
const { prefix, hash } = service.decodeBech32Address('cosmos1abc...')

isValidCosmosAddress(address, expectedChain?): boolean

Defined in: @sip-protocol/sdk/dist/index-BYZbDjal.d.ts:3034

Validate a Cosmos bech32 address format

string

Address to validate

CosmosChainId

Optional chain to validate prefix against

boolean

true if valid, false otherwise

const service = new CosmosStealthService()
service.isValidCosmosAddress('cosmos1abc...', 'cosmos') // true
service.isValidCosmosAddress('osmo1xyz...', 'cosmos') // false (wrong prefix)

getChainFromAddress(address): CosmosChainId | null

Defined in: @sip-protocol/sdk/dist/index-BYZbDjal.d.ts:3048

Get the chain ID from a bech32 address prefix

string

Bech32-encoded address

CosmosChainId | null

Chain ID or null if unknown prefix

const service = new CosmosStealthService()
service.getChainFromAddress('cosmos1abc...') // 'cosmos'
service.getChainFromAddress('osmo1xyz...') // 'osmosis'