Documentation ¶
Index ¶
- Constants
- Variables
- func CalculateUserID(publicKeyBytes []byte) []byte
- func CalculateUserIDHex(publicKeyBytes []byte) string
- func CheckSignature(encryptionToken []byte, signature []byte, chainID int64, ...) (*gethcommon.Address, error)
- func CheckSignatureAndReturnAccountAddress(hashBytes []byte, signature []byte) (*gethcommon.Address, error)
- func GenerateMessage(encryptionToken []byte, chainID int64, version int, ...) ([]byte, error)
- func GetMessageHash(message []byte, signatureType SignatureType) ([]byte, error)
- func GetSignatureTypeString(expectedSignatureType SignatureType) string
- type EIP712Checker
- type EIP712MessageGenerator
- type EIP712MessageHash
- type MessageGenerator
- type MessageHash
- type PersonalMessageGenerator
- type PersonalMessageHash
- type PersonalSignChecker
- type RPCSignedViewingKey
- type SignatureChecker
- type SignatureType
- type ViewingKey
Constants ¶
const ( EIP712Domain = "EIP712Domain" EIP712Type = "Authentication" EIP712DomainName = "name" EIP712DomainVersion = "version" EIP712DomainChainID = "chainId" EIP712EncryptionToken = "Encryption Token" EIP712DomainNameValue = "Ten" EIP712DomainVersionValue = "1.0" UserIDLength = 20 PersonalSignMessageFormat = "Token: %s on chain: %d version: %d" PersonalSignVersion = 1 )
Variables ¶
var SignatureTypeMap = map[string]SignatureType{ "EIP712": EIP712Signature, "Personal": PersonalSign, }
Functions ¶
func CalculateUserID ¶
CalculateUserID calculates userID from a public key (we truncate it, because we want it to have length 20)
func CalculateUserIDHex ¶
CalculateUserIDHex CalculateUserID calculates userID from a public key (we truncate it, because we want it to have length 20) and encode to hex strings
func CheckSignature ¶ added in v0.24.0
func CheckSignature(encryptionToken []byte, signature []byte, chainID int64, signatureType SignatureType) (*gethcommon.Address, error)
CheckSignature checks if signature is valid for provided encryptionToken and chainID and return address or nil if not valid
func CheckSignatureAndReturnAccountAddress ¶ added in v0.22.0
func CheckSignatureAndReturnAccountAddress(hashBytes []byte, signature []byte) (*gethcommon.Address, error)
CheckSignatureAndReturnAccountAddress checks if the signature is valid for hash of the message and checks if signer is an address provided to the function. It returns an address if the signature is valid and nil otherwise
func GenerateMessage ¶ added in v0.24.0
func GenerateMessage(encryptionToken []byte, chainID int64, version int, signatureType SignatureType) ([]byte, error)
GenerateMessage generates a message for the given encryptionToken, chainID, version and signatureType
func GetMessageHash ¶ added in v0.24.0
func GetMessageHash(message []byte, signatureType SignatureType) ([]byte, error)
GetMessageHash returns the hash of the message based on the signature type
func GetSignatureTypeString ¶ added in v0.24.0
func GetSignatureTypeString(expectedSignatureType SignatureType) string
Types ¶
type EIP712Checker ¶ added in v0.24.0
type EIP712Checker struct{}
func (EIP712Checker) CheckSignature ¶ added in v0.24.0
func (e EIP712Checker) CheckSignature(encryptionToken []byte, signature []byte, chainID int64) (*gethcommon.Address, error)
type EIP712MessageGenerator ¶ added in v0.24.0
type EIP712MessageGenerator struct{}
type EIP712MessageHash ¶ added in v0.24.0
type EIP712MessageHash struct{}
type MessageGenerator ¶ added in v0.24.0
type MessageGenerator interface {
// contains filtered or unexported methods
}
type MessageHash ¶ added in v0.24.0
type MessageHash interface {
// contains filtered or unexported methods
}
MessageHash is an interface for getting the hash of the message
type PersonalMessageGenerator ¶ added in v0.24.0
type PersonalMessageGenerator struct{}
type PersonalMessageHash ¶ added in v0.24.0
type PersonalMessageHash struct{}
type PersonalSignChecker ¶ added in v0.24.0
type PersonalSignChecker struct{}
func (PersonalSignChecker) CheckSignature ¶ added in v0.24.0
func (psc PersonalSignChecker) CheckSignature(encryptionToken []byte, signature []byte, chainID int64) (*gethcommon.Address, error)
CheckSignature checks if signature is valid for provided encryptionToken and chainID and return address or nil if not valid
type RPCSignedViewingKey ¶ added in v0.22.0
type RPCSignedViewingKey struct { PublicKey []byte SignatureWithAccountKey []byte SignatureType SignatureType }
RPCSignedViewingKey - used for transporting a minimalist viewing key via every RPC request to a sensitive method, including Log subscriptions. only the public key and the signature are required the account address is sent as well to aid validation
func (RPCSignedViewingKey) Validate ¶ added in v0.23.4
func (vk RPCSignedViewingKey) Validate() error
type SignatureChecker ¶ added in v0.24.0
type SignatureChecker interface {
CheckSignature(encryptionToken []byte, signature []byte, chainID int64) (*gethcommon.Address, error)
}
SignatureChecker is an interface for checking if signature is valid for provided encryptionToken and chainID and return singing address or nil if not valid
type SignatureType ¶ added in v0.24.0
type SignatureType uint8
SignatureType is used to differentiate between different signature types (string is used, because int is not RLP-serializable)
const ( EIP712Signature SignatureType = 0 PersonalSign SignatureType = 1 )
func GetBestFormat ¶ added in v0.24.0
func GetBestFormat(formatsSlice []string) SignatureType
GetBestFormat returns the best format for a message based on available formats that are supported by the user
type ViewingKey ¶
type ViewingKey struct { Account *gethcommon.Address // Account address that this Viewing Key is bound to - Users Pubkey address PrivateKey *ecies.PrivateKey // ViewingKey private key to encrypt data to the enclave PublicKey []byte // ViewingKey public key in decrypt data from the enclave SignatureWithAccountKey []byte // ViewingKey public key signed by the Accounts Private key - Allows to retrieve the Account address SignatureType SignatureType // Type of signature used to sign the public key }
ViewingKey encapsulates the signed viewing key for an account for use in encrypted communication with an enclave. It is the client-side perspective of the viewing key used for decrypting incoming traffic.
func GenerateViewingKeyForWallet ¶
func GenerateViewingKeyForWallet(wal wallet.Wallet) (*ViewingKey, error)
GenerateViewingKeyForWallet takes an account wallet, generates a viewing key and signs the key with the acc's private key