WeTEE Docs
WeTEE Docs
  • OVERVIEW
  • MINNER INSTALLATION GUIDES
    • Supported Devices
    • Host Operating System
    • Install SGX driver in all nodes in the cluster
    • Install k3s cluster on linux
    • Install wetee chain node in cluster
    • Install Intel SGX/TDX PCCS service in cluster
    • Install Confidential wetee worker operator in cluster
    • Install NVIDIA Container Runtime Support(Optional)
    • Staking ant mint
  • DEVELOPMENT GUIDES
    • Blockchain validation node
    • Run TEE miner
    • Run TEE DKG
  • PRODUCTS
    • Confidential Service
    • Confidential Task
    • GPU Compute service
  • For golang developer
    • Golang TEE introduction
    • Libos ego sdk
    • Deploy TEE program on the cloud
    • Deploy TEE program on WeTEE
    • Deploy program docker image on WeTEE
  • Mint
    • Blockchain mint
    • TEE computing mint
Powered by GitBook
On this page
  • import package
  • Update to the latest dependencies
  1. For golang developer

Libos ego sdk

import package

github.com/wetee-dao/libos-entry/entry/ego
  • ego.Fs.Encrypt Use TEE to encrypt data

  • ego.Fs.Decrypt Use TEE to decrypt data

  • ego.Fs.WriteFile Write file with TEE

  • ego.Fs.ReadFile Read file with TEE

Update to the latest dependencies

go get github.com/wetee-dao/libos-entry@v0.1.1

Example:

package main

import (
	"fmt"
	"net/http"

	"github.com/wetee-dao/libos-entry/entry/ego"
)

func main() {
	err := ego.InitLocalEgo()
	if err != nil {
		panic(err)
	}

	/// Use TEE to encrypt data
	v, err := ego.Fs.Encrypt([]byte("hello world"))
	if err != nil {
		panic(err)
	}

	/// Use TEE to decrypt data
	text, err := ego.Fs.Decrypt(v)
	if err != nil {
		panic(err)
	}
	fmt.Println(string(text))

	/// Write data with TEE
	err = ego.Fs.WriteFile("hello.txt", []byte("test"), 0644)
	if err != nil {
		panic(err)
	}

	/// Read data with TEE
	text, err = ego.Fs.ReadFile("hello.txt")
	if err != nil {
		panic(err)
	}

	http.HandleFunc("/", resourceHandler)
	err = http.ListenAndServe(":8999", nil)
	if err != nil {
		panic(err)
	}
}

func resourceHandler(w http.ResponseWriter, req *http.Request) {
	w.WriteHeader(http.StatusOK)
	w.Write([]byte("hello world"))
}
PreviousGolang TEE introductionNextDeploy TEE program on the cloud

Last updated 7 months ago