Documentation ¶
Index ¶
- Constants
- Variables
- func UseLogger(sLogger btclog.Logger)
- type AeadEnvelope
- type Body
- type CallDataPublicKey
- type CallResult
- type Cipher
- type Curve25519KeyPair
- type Data
- type DataEnvelope
- type EncryptedBodyEnvelope
- type Error
- type Failure
- type Inner
- type Kind
- type Leash
- type Request
- type Response
- type SignedCallDataPack
- type SignerFn
- type WrappedBackend
- func (b *WrappedBackend) CallContract(ctx context.Context, call ethereum.CallMsg, blockNumber *big.Int) ([]byte, error)
- func (b *WrappedBackend) EstimateGas(ctx context.Context, call ethereum.CallMsg) (gas uint64, err error)
- func (b *WrappedBackend) SetClientSigningKey(privateKey []byte)
- func (b *WrappedBackend) Transactor(from common.Address) *bind.TransactOpts
- type X25519DeoxysIICipher
- 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) *EncryptedBodyEnvelope
- func (c X25519DeoxysIICipher) Kind() uint64
Constants ¶
const ( Plain = iota X25519DeoxysII = 1 )
const ( DefaultGasPrice = 100_000_000_000 // DefaultGasLimit is set on all transactions without explicit gas limit to avoid being set on signed queries by the web3 gateway. DefaultGasLimit = 30_000_000 DefaultBlockRange = 15 )
const ZeroAddress = "0x0000000000000000000000000000000000000000"
Variables ¶
var ( ErrCallFailed = errors.New("call failed in module") ErrCallResultDecode = errors.New("could not decode call result") )
Functions ¶
Types ¶
type AeadEnvelope ¶
type CallDataPublicKey ¶
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"` }
CallDataPublicKey is the public key alongside the key manager's signature.
type CallResult ¶
type CallResult struct { Fail *Failure `json:"failure,omitempty"` OK []byte `json:"ok,omitempty"` Unknown *AeadEnvelope `json:"unknown,omitempty"` }
type Cipher ¶
type Cipher interface { Kind() uint64 Encrypt(plaintext []byte) (ciphertext []byte, nonce []byte) Decrypt(nonce []byte, ciphertext []byte) (plaintext []byte, err error) EncryptEncode(plaintext []byte) []byte DecryptEncoded(result []byte) ([]byte, error) DecryptCallResult(result []byte) ([]byte, error) }
type Curve25519KeyPair ¶
type Curve25519KeyPair struct { PublicKey [curve25519.PointSize]byte SecretKey [curve25519.ScalarSize]byte }
func NewCurve25519KeyPair ¶
func NewCurve25519KeyPair() (*Curve25519KeyPair, error)
NewCurve25519KeyPair generates a random keypair suitable for use with the X25519DeoxysII cipher.
type DataEnvelope ¶
type DataEnvelope struct { Body []byte `json:"body"` Format uint64 `json:"format,omitempty"` // reuse for now, TODO swap later }
DataEnvelope is an oasis-sdk `Call` without optional fields.
type EncryptedBodyEnvelope ¶
EncryptedBodyEnvelope is an oasis-sdk `Call` with optional fields.
type Leash ¶
type Response ¶
type Response struct { Error *Error `json:"error"` ID int `json:"id"` Result json.RawMessage `json:"result,omitempty"` }
type SignedCallDataPack ¶
type SignedCallDataPack struct { Data Data `json:"data"` Leash Leash `json:"leash"` Signature []byte `json:"signature"` }
SignedCallDataPack defines a signed call.
It should be encoded and sent in the `data` field of an Ethereum call.
func NewDataPack ¶
func NewDataPack(sign SignerFn, privateKey []byte, chainID uint64, caller, callee []byte, gasLimit uint64, gasPrice, value *big.Int, data []byte, leash Leash) (*SignedCallDataPack, error)
NewDataPack returns a SignedCallDataPack.
This method does not encrypt `data`, so that should be done afterwards.
func (SignedCallDataPack) Encode ¶
func (p SignedCallDataPack) Encode() []byte
func (SignedCallDataPack) EncryptEncode ¶
func (p SignedCallDataPack) EncryptEncode(cipher Cipher) []byte
type WrappedBackend ¶
type WrappedBackend struct { bind.ContractBackend // contains filtered or unexported fields }
func WrapClient ¶
func WrapClient(ctx context.Context, c bind.ContractBackend, net utils.NetworkType, sign SignerFn) (*WrappedBackend, error)
WrapClient wraps an ethclient.Client so that it can talk to Sapphire.
func (*WrappedBackend) CallContract ¶
func (b *WrappedBackend) CallContract(ctx context.Context, call ethereum.CallMsg, blockNumber *big.Int) ([]byte, error)
CallContract executes a Sapphire paratime contract call with the specified data as the input. CallContract implements ContractCaller.
func (*WrappedBackend) EstimateGas ¶
func (b *WrappedBackend) EstimateGas(ctx context.Context, call ethereum.CallMsg) (gas uint64, err error)
EstimateGas implements ContractTransactor.
func (*WrappedBackend) SetClientSigningKey ¶
func (b *WrappedBackend) SetClientSigningKey(privateKey []byte)
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 [curve25519.PointSize]byte) (*X25519DeoxysIICipher, error)
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) *EncryptedBodyEnvelope
func (X25519DeoxysIICipher) Kind ¶
func (c X25519DeoxysIICipher) Kind() uint64