common

package
v0.0.0-...-c6a2155 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2025 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

anything related to accounts like signing, wallets, and serialization used by config, server, and sdk

Index

Constants

View Source
const ClientIPKey contextKey = "client-ip"
View Source
const OAPNamespace = "OAP"

Variables

This section is empty.

Functions

func BytesToHex

func BytesToHex(bytes []byte) string

func CORS

func CORS() echo.MiddlewareFunc

func CreateAddress

func CreateAddress(txhash []byte, chainId string, blockHeight int64, txindex int64, discriminator string) string

CreateAddress deterministically generates a content address from a txhash and txindex. The returned address is the last 20 bytes of keccak256 hash, Ethereum-style. Using txhash instead of protobuf marshaling ensures stability across schema evolution. The txindex ensures uniqueness even if identical messages are submitted in the same block. The discriminator parameter can be used to create different addresses for sub-objects within the same transaction (e.g., "party:0", "resource:1", etc.)

func CreateDealAddress

func CreateDealAddress(txhash []byte, chainId string, blockHeight int64, txindex int64, dealReference string) string

CreateDealAddress creates a deterministic address for a Deal entity

func CreateDeterministicCreateRewardData

func CreateDeterministicCreateRewardData(createReward *corev1.CreateReward) string

CreateDeterministicCreateRewardData creates deterministic hex data for signing CreateReward

func CreateDeterministicDeleteRewardData

func CreateDeterministicDeleteRewardData(deleteReward *corev1.DeleteReward) string

CreateDeterministicDeleteRewardData creates deterministic hex data for signing DeleteReward

func CreateDirIfNotExist

func CreateDirIfNotExist(dir string) error

func CreateERNAddress

func CreateERNAddress(txhash []byte, chainId string, blockHeight int64, txindex int64, messageID string) string

CreateERNAddress creates a deterministic address for an ERN entity

func CreatePartyAddress

func CreatePartyAddress(txhash []byte, chainId string, blockHeight int64, txindex int64, partyReference string) string

CreatePartyAddress creates a deterministic address for a Party entity

func CreateReleaseAddress

func CreateReleaseAddress(txhash []byte, chainId string, blockHeight int64, txindex int64, releaseReference string) string

CreateReleaseAddress creates a deterministic address for a Release entity

func CreateResourceAddress

func CreateResourceAddress(txhash []byte, chainId string, blockHeight int64, txindex int64, resourceReference string) string

CreateResourceAddress creates a deterministic address for a Resource entity

func Deobfuscate

func Deobfuscate(s string) (string, error)

func EthRecover

func EthRecover(signatureStr string, data []byte) (*ecdsa.PublicKey, string, error)

func EthSign

func EthSign(pkey *ecdsa.PrivateKey, data []byte) (string, error)

func EthToCometKey

func EthToCometKey(privateKey *ecdsa.PrivateKey) (*ed25519.PrivKey, error)

func EthToEthKey

func EthToEthKey(privKey string) (*ecdsa.PrivateKey, error)

func FileExists

func FileExists(filePath string) bool

func GeneratePlaySignature

func GeneratePlaySignature(privKey *ecdsa.PrivateKey, data *storagev1.StreamTrackSignatureData) (signatureHex string, dataHash []byte, err error)

func GetAttestorRendezvous

func GetAttestorRendezvous(validatorAddresses []string, key []byte, size int) map[string]bool

Returns the first `size` number of addresses from a list of all validators sorted by a hashing function. The hashing is seeded according to the given key.

func GetClientIP

func GetClientIP(ctx context.Context) string

func HexToBytes

func HexToBytes(addr string) ([]byte, error)

func HexToUtf8

func HexToUtf8(hex [32]byte) string

reverse of Utf8ToHex

func InjectRealIP

func InjectRealIP() echo.MiddlewareFunc

func IsProgrammableDistributionEnabled

func IsProgrammableDistributionEnabled(env string) bool

func LoadPrivateKey

func LoadPrivateKey(path string) (*ecdsa.PrivateKey, error)

func Obfuscate

func Obfuscate(s string) string

func PrivKeyToAddress

func PrivKeyToAddress(privateKey *ecdsa.PrivateKey) string

func ProtoRecover

func ProtoRecover(msg proto.Message, signature string) (string, error)

ProtoTxRecover recovers the signer address from a protobuf message and signature WARNING: This should only be used when verifying transactions and not replaying them as it's not safe from protobuf evolution. The message structure could change between versions, making signatures invalid.

func ProtoSign

func ProtoSign(pkey *ecdsa.PrivateKey, msg proto.Message) (string, error)

ProtoTxSign signs a protobuf message for transaction purposes WARNING: This should only be used when sending transactions and not replaying them as it's not safe from protobuf evolution. The message structure could change between versions, making signatures invalid.

func RecoverPlaySignature

func RecoverPlaySignature(signatureHex string, data *storagev1.StreamTrackSignatureData) (pubKey *ecdsa.PublicKey, ethAddress string, err error)

func SerializePublicKeyHex

func SerializePublicKeyHex(pubKey *ecdsa.PublicKey) string

func SignCreateReward

func SignCreateReward(privateKey *ecdsa.PrivateKey, createReward *corev1.CreateReward) (string, error)

SignCreateReward signs a CreateReward message using deterministic data

func SignDeleteReward

func SignDeleteReward(privateKey *ecdsa.PrivateKey, deleteReward *corev1.DeleteReward) (string, error)

SignDeleteReward signs a DeleteReward message using deterministic data

func TxHashRecover

func TxHashRecover(txHash, signature string) (*ecdsa.PublicKey, string, error)

TxHashRecover recovers the signer address from a transaction hash and signature

func TxHashSign

func TxHashSign(pkey *ecdsa.PrivateKey, txHash string) (string, error)

TxHashSign signs a transaction hash with the given private key Validates that txHash is a proper hex-encoded hash

func Utf8ToHex

func Utf8ToHex(s string) [32]byte

for parity with the web3.js web3.utils.utf8ToHex() call

Types

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

func NewLogger

func NewLogger(opts *slog.HandlerOptions) *Logger

func (*Logger) Child

func (l *Logger) Child(serviceName string) *Logger

func (*Logger) Debug

func (l *Logger) Debug(msg string, keyvals ...interface{})

func (*Logger) Debugf

func (l *Logger) Debugf(msg string, keyvals ...interface{})

func (*Logger) Error

func (l *Logger) Error(msg string, keyvals ...interface{})

func (*Logger) Errorf

func (l *Logger) Errorf(msg string, keyvals ...interface{})

func (*Logger) Fatalf

func (l *Logger) Fatalf(format string, v ...interface{})

func (*Logger) Info

func (l *Logger) Info(msg string, keyvals ...interface{})

func (*Logger) Infof

func (l *Logger) Infof(msg string, keyvals ...interface{})

func (*Logger) Printf

func (l *Logger) Printf(format string, v ...interface{})

func (*Logger) Warn

func (l *Logger) Warn(msg string, keyvals ...interface{})

func (*Logger) Warningf

func (l *Logger) Warningf(msg string, keyvals ...interface{})

func (*Logger) With

func (l *Logger) With(keyvals ...interface{}) log.Logger

type NodeTuple

type NodeTuple struct {
	// contains filtered or unexported fields
}

type NodeTuples

type NodeTuples []NodeTuple

func (NodeTuples) Len

func (s NodeTuples) Len() int

func (NodeTuples) Less

func (s NodeTuples) Less(i, j int) bool

func (NodeTuples) Swap

func (s NodeTuples) Swap(i, j int)

type TxHash

type TxHash = string

func ToTxHashFromBytes

func ToTxHashFromBytes(txBytes []byte) TxHash

ToTxHashFromBytes creates a transaction hash from raw transaction bytes using CometBFT's hashing utilities for consistency with block sync

Jump to

Keyboard shortcuts

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