Documentation
¶
Index ¶
- func DerEncodeCompressedSecp256k1PublicKey(pubkey []byte) ([]byte, error)
- func DerEncodeSecp256k1PublicKey(pubkey []byte) ([]byte, error)
- func DeriveICPSenderPrincipalFromUncompressedPubKey(pubkey []byte) ([]byte, error)
- func EncodeCBOR(transaction *Transaction) ([]byte, error)
- func ExtractICPSignatures(signedTx []byte) (updateSig, readStateSig, updatePubKey, readStatePubKey []byte, err error)
- func GenerateNonce() []byte
- func GenerateRequestID(request interface{}) []byte
- func GenerateSignatureData(requestID []byte) []byte
- func HashArray(elements []RawHttpRequestVal) []byte
- func HashBytes(value []byte) []byte
- func HashKeyVal(key string, val RawHttpRequestVal) []byte
- func HashOfMap(content map[string]interface{}) []byte
- func HashString(value string) []byte
- func HashU64(value uint64) []byte
- func HashVal(val RawHttpRequestVal) []byte
- func VerifySignature(signature, data, publicKey []byte) bool
- type Envelope
- type ICPChain
- func (i *ICPChain) CompileTransaction(input *chain_abstraction.TransactionInput, signatures [][]byte, ...) ([]byte, error)
- func (i *ICPChain) CreateAndSignTransaction(input interface{}, privateKey []byte) ([]byte, error)
- func (i *ICPChain) GetPreimageHash(input *chain_abstraction.TransactionInput) ([]byte, []byte, error)
- func (i *ICPChain) GetTransactionHash(encodedTx []byte) (string, error)
- func (i *ICPChain) PrepareTransaction(input interface{}) (*chain_abstraction.TransactionInput, error)
- func (i *ICPChain) Sign(preimage []byte, privateKey []byte) ([]byte, error)
- func (i *ICPChain) ValidateTransactionInput(input interface{}) error
- type RawHttpRequestVal
- type ReadStateRequest
- type Request
- type Transaction
- type TransferArgs
- type UpdateRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DerEncodeCompressedSecp256k1PublicKey ¶
DerEncodeCompressedSecp256k1PublicKey encodes a compressed secp256k1 public key (33 bytes) into DER
func DerEncodeSecp256k1PublicKey ¶
DerEncodeSecp256k1PublicKey encodes an uncompressed secp256k1 public key (65 bytes) into DER
func DeriveICPSenderPrincipalFromUncompressedPubKey ¶
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 ¶
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 HashKeyVal ¶
func HashKeyVal(key string, val RawHttpRequestVal) []byte
HashKeyVal computes H(field_name) · H(field_value)
func VerifySignature ¶
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 (*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 ¶
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 ¶
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) ValidateTransactionInput ¶
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