swisstronik_go_sdk

package module
v0.0.0-...-6092fe7 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2024 License: MIT Imports: 11 Imported by: 0

README

Swisstronik SDK Go

Test

This package provides a thin wrapper for Deoxys-II-256-128 (and maybe other things in the future) for usage v/ Swisstronik chain.

Currently, it exposes the following functions:

  • EncryptState/DecryptState for smart contract enc/dec
  • EncryptECDH/DecryptECDH for arbitrary data enc/dec with user's private key and node public key
  • EncryptECDHWithRPCURL/DecryptECDHWithRPCURL - convenience encryption with pre-fetching node public key
  • FetchNodePublicKey - for fetching node public key via JSON-RPC
  • GetCurve25519PublicKey - for getting public key from private key
  • DeriveEncryptionKey - for deriving a new master key using the other one and salt

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecryptECDH

func DecryptECDH(privateKey, nodePublicKey, encryptedData []byte) ([]byte, error)

func DecryptECDHWithRPCURL

func DecryptECDHWithRPCURL(privateKey []byte, rpcUrl string, encryptedData []byte) ([]byte, error)

DecryptECDHWithRPCURL fetched node public key from rpcURL and decrypts provided value using provided encryption key

func DecryptState

func DecryptState(masterKey, contractAddress, value []byte) ([]byte, error)

func DeriveEncryptionKey

func DeriveEncryptionKey(masterKey, salt []byte) []byte

DeriveEncryptionKey derives encryption key using master key and salt

func EncryptECDH

func EncryptECDH(privateKey, nodePublicKey, data []byte) ([]byte, error)

EncryptECDH encrypts provided value using encryption key, derived from user private key and node public key.

func EncryptECDHWithRPCURL

func EncryptECDHWithRPCURL(privateKey []byte, rpcUrl string, data []byte) ([]byte, error)

EncryptECDHWithRPCURL fetched node public key from rpcURL and encrypts provided value using encryption key, derived from user private key

func EncryptState

func EncryptState(masterKey, contractAddress, value []byte) ([]byte, error)

EncryptState encrypts smart contract state using simmetric key derived from master key only for specific contract. That allows us to improve cryptographic strength of our encryption scheme.

As an output, this function returns vector which contains 15 bytes nonce and ciphertext.

func FetchNodePublicKey

func FetchNodePublicKey(rpcUrl string) ([]byte, error)

func GetCurve25519PublicKey

func GetCurve25519PublicKey(privateKey [32]byte) [32]byte

Types

type PublicKeyFetchResponse

type PublicKeyFetchResponse struct {
	ID      int    `json:"id"`
	Jsonrpc string `json:"jsonrpc"`
	Result  string `json:"result"`
}

Jump to

Keyboard shortcuts

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