crypto

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2025 License: AGPL-3.0 Imports: 17 Imported by: 0

README

This package contains logic which implements the cryptographic requirements of TEN.

  1. Manage the shared secret of the network.(SS) - shared_secret_service
  2. Manage the "Ten RPC" encryption - which is the key used by all clients to communicate with the TEN network (key derived from SS) - rpc_key_service
  3. Manage the Data availability(DA) (Rollup and Batches) Encryption/Decryption ( key derived from SS). - da_enc_service
  4. Manage the enclave key signature/encryption/decryption/ id derivation. - enclave_key_service
  5. Manage entropy per batch and tx - evm_entropy_service

Documentation

Index

Constants

View Source
const (
	// GCMNonceLength is the nonce's length in bytes for encrypting and decrypting transactions.
	GCMNonceLength = 12
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DAEncryptionService added in v1.0.0

type DAEncryptionService struct {
	// contains filtered or unexported fields
}

DAEncryptionService - handles encryption/decryption of the data stored in the DA layer

func NewDAEncryptionService added in v1.0.0

func NewDAEncryptionService(sharedSecretService *SharedSecretService, logger gethlog.Logger) *DAEncryptionService

func (*DAEncryptionService) Decrypt added in v1.0.0

func (t *DAEncryptionService) Decrypt(blob []byte) ([]byte, error)

func (*DAEncryptionService) Encrypt added in v1.0.0

func (t *DAEncryptionService) Encrypt(blob []byte) ([]byte, error)

func (*DAEncryptionService) Initialise added in v1.0.0

func (t *DAEncryptionService) Initialise() error

type EnclaveAttestedKeyService added in v1.0.0

type EnclaveAttestedKeyService struct {
	// contains filtered or unexported fields
}

EnclaveAttestedKeyService manages the attestation key - including

func NewEnclaveAttestedKeyService added in v1.0.0

func NewEnclaveAttestedKeyService(logger gethlog.Logger) *EnclaveAttestedKeyService

func (*EnclaveAttestedKeyService) Decrypt added in v1.0.0

func (eks *EnclaveAttestedKeyService) Decrypt(encBytes []byte) ([]byte, error)

func (*EnclaveAttestedKeyService) EnclaveID added in v1.0.0

func (eks *EnclaveAttestedKeyService) EnclaveID() common.EnclaveID

func (*EnclaveAttestedKeyService) Encrypt added in v1.0.0

func (eks *EnclaveAttestedKeyService) Encrypt(encBytes []byte) ([]byte, error)

func (*EnclaveAttestedKeyService) GenerateEnclaveKey added in v1.0.0

func (eks *EnclaveAttestedKeyService) GenerateEnclaveKey() ([]byte, error)

func (*EnclaveAttestedKeyService) PublicKey added in v1.0.0

func (eks *EnclaveAttestedKeyService) PublicKey() *ecdsa.PublicKey

func (*EnclaveAttestedKeyService) PublicKeyBytes added in v1.0.0

func (eks *EnclaveAttestedKeyService) PublicKeyBytes() []byte

func (*EnclaveAttestedKeyService) SetEnclaveKey added in v1.0.0

func (eks *EnclaveAttestedKeyService) SetEnclaveKey(keyBytes []byte)

func (*EnclaveAttestedKeyService) Sign added in v1.0.0

func (eks *EnclaveAttestedKeyService) Sign(payload gethcommon.Hash) ([]byte, error)

type EvmEntropyService added in v1.0.0

type EvmEntropyService struct {
	// contains filtered or unexported fields
}

EvmEntropyService - generates the entropy that is injected into the EVM - unique for each transaction

func NewEvmEntropyService added in v1.0.0

func NewEvmEntropyService(sc *SharedSecretService, logger gethlog.Logger) *EvmEntropyService

func (*EvmEntropyService) BatchEntropy added in v1.0.0

func (ees *EvmEntropyService) BatchEntropy(batch *common.BatchHeader) gethcommon.Hash

BatchEntropy - calculates entropy per batch In Ten, we use a root entropy per batch, which is then used to calculate randomness exposed to individual transactions The RootBatchEntropy is calculated based on the shared secret, the batch height and the timestamp This ensures that sibling batches will naturally use the same root entropy so that transactions will have the same results

func (*EvmEntropyService) TxEntropy added in v1.0.0

func (ees *EvmEntropyService) TxEntropy(rootBatchEntropy []byte, tCount int) gethcommon.Hash

TxEntropy - calculates the randomness exposed to individual transactions In TEN, each tx has its own independent randomness, because otherwise a malicious transaction from the same batch could reveal information.

type RPCKeyService added in v1.0.0

type RPCKeyService struct {
	// contains filtered or unexported fields
}

RPCKeyService - manages the "TEN - RPC key" used by clients (like the TEN gateway) to make RPC requests

func NewRPCKeyService added in v1.0.0

func NewRPCKeyService(sharedSecretService *SharedSecretService, logger gethlog.Logger) *RPCKeyService

func (*RPCKeyService) DecryptRPCRequest added in v1.0.0

func (s *RPCKeyService) DecryptRPCRequest(bytes []byte) ([]byte, error)

func (*RPCKeyService) Initialise added in v1.0.0

func (s *RPCKeyService) Initialise() error

Initialise - called when the shared secret is available

func (*RPCKeyService) PublicKey added in v1.0.0

func (s *RPCKeyService) PublicKey() ([]byte, error)

type SharedEnclaveSecret

type SharedEnclaveSecret [sharedSecretLenInBytes]byte

SharedEnclaveSecret - the entropy

type SharedSecretService added in v1.0.0

type SharedSecretService struct {
	// contains filtered or unexported fields
}

SharedSecretService provides functionality to encapsulate, generate, extend, and encrypt the shared secret of the TEN network.

func NewSharedSecretService added in v1.0.0

func NewSharedSecretService(logger gethlog.Logger) *SharedSecretService

func (*SharedSecretService) EncryptSecretWithKey added in v1.0.0

func (sss *SharedSecretService) EncryptSecretWithKey(pubKey []byte) (common.EncryptedSharedEnclaveSecret, error)

func (*SharedSecretService) ExtendEntropy added in v1.0.0

func (sss *SharedSecretService) ExtendEntropy(extra []byte) []byte

ExtendEntropy derives more entropy from the shared secret

func (*SharedSecretService) GenerateSharedSecret added in v1.0.0

func (sss *SharedSecretService) GenerateSharedSecret()

GenerateSharedSecret - called only by the genesis

func (*SharedSecretService) IsGenesis added in v1.0.0

func (sss *SharedSecretService) IsGenesis() bool

func (*SharedSecretService) IsInitialised added in v1.0.0

func (sss *SharedSecretService) IsInitialised() bool

func (*SharedSecretService) Secret added in v1.0.0

Secret - should only be used before storing it

func (*SharedSecretService) SetSharedSecret added in v1.0.0

func (sss *SharedSecretService) SetSharedSecret(ss *SharedEnclaveSecret)

Jump to

Keyboard shortcuts

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