chains

package
v0.0.1-gowrapper-test Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DerEncodeCompressedSecp256k1PublicKey

func DerEncodeCompressedSecp256k1PublicKey(pubkey []byte) ([]byte, error)

DerEncodeCompressedSecp256k1PublicKey encodes a compressed secp256k1 public key (33 bytes) into DER

func DerEncodeSecp256k1PublicKey

func DerEncodeSecp256k1PublicKey(pubkey []byte) ([]byte, error)

DerEncodeSecp256k1PublicKey encodes an uncompressed secp256k1 public key (65 bytes) into DER

func DeriveICPSenderPrincipalFromUncompressedPubKey

func DeriveICPSenderPrincipalFromUncompressedPubKey(pubkey []byte) ([]byte, error)

DeriveICPSenderPrincipalFromUncompressedPubKey derives the ICP principal from an uncompressed secp256k1 public key

func EncodeCBOR

func EncodeCBOR(transaction *Transaction) ([]byte, error)

EncodeCBOR encodes an ICP transaction to CBOR format

func ExtractICPSignatures

func ExtractICPSignatures(signedTx []byte) (updateSig, readStateSig, updatePubKey, readStatePubKey []byte, err error)

ExtractICPSignatures extracts the update and read_state signatures and public keys from a CBOR-encoded ICP transaction.

func GenerateNonce

func GenerateNonce() []byte

GenerateNonce creates a unique nonce for ICP requests

func GenerateRequestID

func GenerateRequestID(request interface{}) []byte

GenerateRequestID computes the representation-independent hash for an ICP request

func GenerateSignatureData

func GenerateSignatureData(requestID []byte) []byte

GenerateSignatureData computes the signature data from a request ID (with domain separation)

func HashArray

func HashArray(elements []RawHttpRequestVal) []byte

HashArray computes hash of array elements

func HashBytes

func HashBytes(value []byte) []byte

HashBytes computes SHA256 of bytes

func HashKeyVal

func HashKeyVal(key string, val RawHttpRequestVal) []byte

HashKeyVal computes H(field_name) · H(field_value)

func HashOfMap

func HashOfMap(content map[string]interface{}) []byte

HashOfMap computes the representation-independent hash exactly like the Rust core

func HashString

func HashString(value string) []byte

HashString computes SHA256 of a string

func HashU64

func HashU64(value uint64) []byte

HashU64 computes SHA256 of LEB128-encoded u64

func HashVal

func HashVal(val RawHttpRequestVal) []byte

HashVal computes hash of a value

func VerifySignature

func VerifySignature(signature, data, publicKey []byte) bool

VerifySignature verifies an ECDSA signature

Types

type Envelope

type Envelope struct {
	Content      interface{} `cbor:"content"`
	SenderPubkey []byte      `cbor:"sender_pubkey"`
	SenderSig    []byte      `cbor:"sender_sig"`
}

Envelope represents an ICP envelope structure

type ICPChain

type ICPChain struct {
	*chain_abstraction.BaseChain
}

ICPChain implements the Chain interface for Internet Computer Protocol

Methods inherited from BaseChain: - GetCoinType() core.CoinType - GetName() string - GetSymbol() string - GetDecimals() int - CreateWallet(mnemonic string) (*chain_abstraction.Wallet, error) - CreateWalletWithPrivateKey(privateKey string) (*chain_abstraction.Wallet, error) - ValidateAddress(address string) bool - GetPublicKeyFromPrivateKey(privateKey []byte) ([]byte, error)

Methods reimplemented for ICP-specific handling: - GetTransactionHash(encodedTx []byte) (string, error)

func NewICPChain

func NewICPChain() *ICPChain

NewICPChain creates a new ICP chain instance

func (*ICPChain) CompileTransaction

func (i *ICPChain) CompileTransaction(
	input *chain_abstraction.TransactionInput,
	signatures [][]byte,
	publicKeys [][]byte,
) ([]byte, error)

CompileTransaction compiles an ICP transaction with signatures

func (*ICPChain) CreateAndSignTransaction

func (i *ICPChain) CreateAndSignTransaction(input interface{}, privateKey []byte) ([]byte, error)

CreateAndSignTransaction creates and signs an ICP transaction

func (*ICPChain) GetPreimageHash

func (i *ICPChain) GetPreimageHash(input *chain_abstraction.TransactionInput) ([]byte, []byte, error)

GetPreimageHash gets the preimage hash for external signing

func (*ICPChain) GetTransactionHash

func (i *ICPChain) GetTransactionHash(encodedTx []byte) (string, error)

GetTransactionHash gets the transaction hash for ICP (reimplemented for ICP-specific handling)

func (*ICPChain) PrepareTransaction

func (i *ICPChain) PrepareTransaction(input interface{}) (*chain_abstraction.TransactionInput, error)

PrepareTransaction prepares an ICP transaction for external signing

func (*ICPChain) Sign

func (i *ICPChain) Sign(preimage []byte, privateKey []byte) ([]byte, error)

Sign signs a preimage with the given private key

func (*ICPChain) ValidateTransactionInput

func (i *ICPChain) ValidateTransactionInput(input interface{}) error

ValidateTransactionInput validates ICP transaction input

type RawHttpRequestVal

type RawHttpRequestVal struct {
	Type  string
	Bytes []byte
	Str   string
	U64   uint64
	Array []RawHttpRequestVal
}

RawHttpRequestVal represents the different types of values supported in ICP requests

type ReadStateRequest

type ReadStateRequest struct {
	IngressExpiry uint64     `cbor:"ingress_expiry"`
	Paths         [][][]byte `cbor:"paths"`
	RequestType   string     `cbor:"request_type"`
	Sender        []byte     `cbor:"sender"`
}

ReadStateRequest represents an ICP read_state request structure

type Request

type Request struct {
	Arg           []byte     `cbor:"arg"`
	CanisterID    *[]byte    `cbor:"canister_id,omitempty"`
	IngressExpiry uint64     `cbor:"ingress_expiry"`
	MethodName    string     `cbor:"method_name"`
	Nonce         *[]byte    `cbor:"nonce,omitempty"`
	Paths         [][][]byte `cbor:"paths,omitempty"`
	RequestType   uint32     `cbor:"request_type"`
	Sender        []byte     `cbor:"sender"`
}

Request represents an ICP request structure

type Transaction

type Transaction struct {
	ReadState *Envelope `cbor:"read_state"`
	Update    *Envelope `cbor:"update"`
}

Transaction represents an ICP transaction structure

type TransferArgs

type TransferArgs struct {
	Amount         *big.Int `cbor:"amount"`
	Fee            *big.Int `cbor:"fee"`
	FromSubaccount []byte   `cbor:"from_subaccount"`
	Memo           uint64   `cbor:"memo"`
	To             []byte   `cbor:"to"`
}

TransferArgs represents ICP transfer arguments

type UpdateRequest

type UpdateRequest struct {
	Arg           []byte `cbor:"arg"`
	CanisterID    []byte `cbor:"canister_id"`
	IngressExpiry uint64 `cbor:"ingress_expiry"`
	MethodName    string `cbor:"method_name"`
	RequestType   string `cbor:"request_type"`
	Sender        []byte `cbor:"sender"`
}

UpdateRequest represents an ICP update (call) request structure

Jump to

Keyboard shortcuts

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