Documentation ¶
Index ¶
- Constants
- Variables
- func GetRuntimePublicKey(chainID uint64) (*x25519.PublicKey, uint64, error)
- func PackCall(msg ethereum.CallMsg, cipher Cipher) (*ethereum.CallMsg, error)
- func PackSignedCall(msg ethereum.CallMsg, cipher Cipher, sign SignerFn, chainID big.Int, ...) (*ethereum.CallMsg, error)
- func PackTx(tx *types.Transaction, cipher Cipher) (*types.Transaction, error)
- func WrapClient(c *ethclient.Client, sign SignerFn) (bind.ContractBackend, error)
- type CallDataPublicKey
- type Cipher
- type Curve25519KeyPair
- type Error
- type Kind
- type NetworkParams
- type PlainCipher
- func (c PlainCipher) CallFormat() types.CallFormat
- func (c PlainCipher) Decrypt(_ []byte, ciphertext []byte) (plaintext []byte, err error)
- func (c PlainCipher) DecryptCallResult(response []byte) ([]byte, error)
- func (c PlainCipher) DecryptEncoded(response []byte) ([]byte, error)
- func (c PlainCipher) Encrypt(plaintext []byte) (ciphertext []byte, nonce []byte)
- func (c PlainCipher) EncryptEncode(plaintext []byte) []byte
- func (c PlainCipher) EncryptEnvelope(plaintext []byte) *types.Call
- type Request
- type Response
- type SignerFn
- type WrappedBackend
- func (b WrappedBackend) CallContract(ctx context.Context, call ethereum.CallMsg, blockNumber *big.Int) ([]byte, error)
- func (b WrappedBackend) CodeAt(ctx context.Context, contract common.Address, blockNumber *big.Int) ([]byte, error)
- func (b WrappedBackend) EstimateGas(ctx context.Context, call ethereum.CallMsg) (gas uint64, err error)
- func (b WrappedBackend) FilterLogs(ctx context.Context, query ethereum.FilterQuery) ([]types.Log, error)
- func (b WrappedBackend) HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)
- func (b WrappedBackend) PendingCodeAt(ctx context.Context, account common.Address) ([]byte, error)
- func (b WrappedBackend) PendingNonceAt(ctx context.Context, account common.Address) (uint64, error)
- func (b WrappedBackend) SendTransaction(ctx context.Context, tx *types.Transaction) error
- func (b WrappedBackend) SubscribeFilterLogs(ctx context.Context, query ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error)
- func (b WrappedBackend) SuggestGasPrice(ctx context.Context) (*big.Int, error)
- func (b WrappedBackend) SuggestGasTipCap(ctx context.Context) (*big.Int, error)
- func (b WrappedBackend) Transactor(from common.Address) *bind.TransactOpts
- type X25519DeoxysIICipher
- func (c X25519DeoxysIICipher) CallFormat() types.CallFormat
- func (c X25519DeoxysIICipher) Decrypt(nonce []byte, ciphertext []byte) ([]byte, error)
- func (c X25519DeoxysIICipher) DecryptCallResult(response []byte) ([]byte, error)
- func (c X25519DeoxysIICipher) DecryptEncoded(response []byte) ([]byte, error)
- func (c X25519DeoxysIICipher) Encrypt(plaintext []byte) (ciphertext []byte, nonce []byte)
- func (c X25519DeoxysIICipher) EncryptEncode(plaintext []byte) []byte
- func (c X25519DeoxysIICipher) EncryptEnvelope(plaintext []byte) *types.Call
Constants ¶
const ( DefaultGasPrice = 100_000_000_000 DefaultGasLimit = 30_000_000 DefaultBlockRange = 15 )
Variables ¶
var ( ErrCallFailed = errors.New("call failed in module") ErrCallResultDecode = errors.New("could not decode call result") )
var Networks = map[uint64]NetworkParams{ 0x5aff: { Name: "testnet", ChainID: *big.NewInt(0x5aff), DefaultGateway: "https://testnet.sapphire.oasis.io", RuntimeID: "0x000000000000000000000000000000000000000000000000a6d1e3ebf60dff6c", }, 0x5afe: { Name: "mainnet", ChainID: *big.NewInt(0x5afe), DefaultGateway: "https://sapphire.oasis.io", RuntimeID: "0x000000000000000000000000000000000000000000000000f80306c9858e7279", }, 0x5afd: { Name: "localnet", ChainID: *big.NewInt(0x5afd), DefaultGateway: "http://localhost:8545", RuntimeID: "0x8000000000000000000000000000000000000000000000000000000000000000", }, }
Functions ¶
func GetRuntimePublicKey ¶
GetRuntimePublicKey fetches the runtime calldata public key from the default Sapphire gateway.
func PackCall ¶
PackCall prepares `msg` for being sent to Sapphire. The call will be end-to-end encrypted, but the `from` address will be zero.
func PackSignedCall ¶
func PackSignedCall(msg ethereum.CallMsg, cipher Cipher, sign SignerFn, chainID big.Int, leash *evm.Leash) (*ethereum.CallMsg, error)
PackSignedCall prepares `msg` in-place for being sent to Sapphire. The call will be end-to-end encrypted and a signature will be used to authenticate the `from` address.
func PackTx ¶
func PackTx(tx *types.Transaction, cipher Cipher) (*types.Transaction, error)
PackTx prepares a regular Eth transaction for Sapphire. The transaction returned from this function is what must be signed.
func WrapClient ¶
WrapClient wraps an ethclient.Client so that it can talk to Sapphire.
Types ¶
type CallDataPublicKey ¶ added in v0.10.0
type CallDataPublicKey struct { // PublicKey is the requested public key. PublicKey hexutil.Bytes `json:"key"` // Checksum is the checksum of the key manager state. Checksum hexutil.Bytes `json:"checksum"` // Signature is the Sign(sk, (key || checksum)) from the key manager. Signature hexutil.Bytes `json:"signature"` // Epoch is the epoch of the ephemeral runtime key. Epoch uint64 `json:"epoch,omitempty"` }
CallDataPublicKey is the public key alongside the key manager's signature. See Web3 gateway repository for more information https://github.com/oasisprotocol/oasis-web3-gateway/blob/d29efdafe4e07a9f0f9a0fd13379c58eb5b89723/rpc/oasis/api.go#L21-L33 This is a flattened `core.CallDataPublicKeyResponse` with hex-encoded bytes for easy consumption by Web3 clients.
type Cipher ¶
type Cipher interface { CallFormat() types.CallFormat Encrypt(plaintext []byte) (ciphertext []byte, nonce []byte) Decrypt(nonce []byte, ciphertext []byte) (plaintext []byte, err error) EncryptEncode(plaintext []byte) []byte EncryptEnvelope(plaintext []byte) *types.Call DecryptEncoded(result []byte) ([]byte, error) DecryptCallResult(result []byte) ([]byte, error) }
type Curve25519KeyPair ¶
type Curve25519KeyPair struct { PublicKey x25519.PublicKey SecretKey x25519.PrivateKey }
func NewCurve25519KeyPair ¶
func NewCurve25519KeyPair() (*Curve25519KeyPair, error)
NewCurve25519KeyPair generates a random keypair suitable for use with the X25519DeoxysII cipher.
type NetworkParams ¶
type PlainCipher ¶
type PlainCipher struct{}
func NewPlainCipher ¶
func NewPlainCipher() PlainCipher
NewPlainCipher creates a cipher instance without encryption support.
func (PlainCipher) CallFormat ¶ added in v0.11.0
func (c PlainCipher) CallFormat() types.CallFormat
func (PlainCipher) Decrypt ¶
func (c PlainCipher) Decrypt(_ []byte, ciphertext []byte) (plaintext []byte, err error)
func (PlainCipher) DecryptCallResult ¶
func (c PlainCipher) DecryptCallResult(response []byte) ([]byte, error)
func (PlainCipher) DecryptEncoded ¶
func (c PlainCipher) DecryptEncoded(response []byte) ([]byte, error)
func (PlainCipher) Encrypt ¶
func (c PlainCipher) Encrypt(plaintext []byte) (ciphertext []byte, nonce []byte)
func (PlainCipher) EncryptEncode ¶
func (c PlainCipher) EncryptEncode(plaintext []byte) []byte
func (PlainCipher) EncryptEnvelope ¶
func (c PlainCipher) EncryptEnvelope(plaintext []byte) *types.Call
type Response ¶
type Response struct { Error *Error `json:"error"` ID int `json:"id"` Result json.RawMessage `json:"result,omitempty"` }
type WrappedBackend ¶
type WrappedBackend struct {
// contains filtered or unexported fields
}
WrappedBackend implements bind.ContractBackend.
func NewWrappedBackend ¶
func NewWrappedBackend(backend bind.ContractBackend, chainID big.Int, cipher Cipher, sign SignerFn) WrappedBackend
func (WrappedBackend) CallContract ¶
func (b WrappedBackend) CallContract(ctx context.Context, call ethereum.CallMsg, blockNumber *big.Int) ([]byte, error)
CallContract implements ContractCaller.
func (WrappedBackend) CodeAt ¶
func (b WrappedBackend) CodeAt(ctx context.Context, contract common.Address, blockNumber *big.Int) ([]byte, error)
CodeAt implements ContractCaller.
func (WrappedBackend) EstimateGas ¶
func (b WrappedBackend) EstimateGas(ctx context.Context, call ethereum.CallMsg) (gas uint64, err error)
EstimateGas implements ContractTransactor.
func (WrappedBackend) FilterLogs ¶
func (b WrappedBackend) FilterLogs(ctx context.Context, query ethereum.FilterQuery) ([]types.Log, error)
FilterLogs implements ContractFilterer.
func (WrappedBackend) HeaderByNumber ¶
HeaderByNumber implements ContractTransactor.
func (WrappedBackend) PendingCodeAt ¶
PendingCodeAt implements ContractTransactor.
func (WrappedBackend) PendingNonceAt ¶
PendingNonceAt implements ContractTransactor.
func (WrappedBackend) SendTransaction ¶
func (b WrappedBackend) SendTransaction(ctx context.Context, tx *types.Transaction) error
SendTransaction implements ContractTransactor.
func (WrappedBackend) SubscribeFilterLogs ¶
func (b WrappedBackend) SubscribeFilterLogs(ctx context.Context, query ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error)
SubscribeFilterLogs implements ContractFilterer.
func (WrappedBackend) SuggestGasPrice ¶
SuggestGasPrice implements ContractTransactor.
func (WrappedBackend) SuggestGasTipCap ¶
SuggestGasTipCap implements ContractTransactor.
func (WrappedBackend) Transactor ¶
func (b WrappedBackend) Transactor(from common.Address) *bind.TransactOpts
Transactor returns a TransactOpts that can be used with Sapphire.
type X25519DeoxysIICipher ¶
type X25519DeoxysIICipher struct {
// contains filtered or unexported fields
}
X25519DeoxysIICipher is the default cipher that does what it says on the tin.
func NewX25519DeoxysIICipher ¶
func NewX25519DeoxysIICipher(keypair *Curve25519KeyPair, peerPublicKey *x25519.PublicKey, epoch uint64) (*X25519DeoxysIICipher, error)
NewX25519DeoxysIICipher creates a new cipher instance with encryption support.
func (X25519DeoxysIICipher) CallFormat ¶ added in v0.11.0
func (c X25519DeoxysIICipher) CallFormat() types.CallFormat
func (X25519DeoxysIICipher) Decrypt ¶
func (c X25519DeoxysIICipher) Decrypt(nonce []byte, ciphertext []byte) ([]byte, error)
func (X25519DeoxysIICipher) DecryptCallResult ¶
func (c X25519DeoxysIICipher) DecryptCallResult(response []byte) ([]byte, error)
func (X25519DeoxysIICipher) DecryptEncoded ¶
func (c X25519DeoxysIICipher) DecryptEncoded(response []byte) ([]byte, error)
func (X25519DeoxysIICipher) Encrypt ¶
func (c X25519DeoxysIICipher) Encrypt(plaintext []byte) (ciphertext []byte, nonce []byte)
func (X25519DeoxysIICipher) EncryptEncode ¶
func (c X25519DeoxysIICipher) EncryptEncode(plaintext []byte) []byte
func (X25519DeoxysIICipher) EncryptEnvelope ¶
func (c X25519DeoxysIICipher) EncryptEnvelope(plaintext []byte) *types.Call