config

package
v0.0.0-...-ae747ca Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const EncodedConfigVersion = 1
View Source
const SharedSecretSize = 16 // A 128-bit symmetric key

Variables

This section is empty.

Functions

func ConfigDigest

func ConfigDigest(
	contractAddress common.Address,
	configCount uint64,
	oracles []common.Address,
	transmitters []common.Address,
	threshold uint8,
	encodedConfigVersion uint64,
	config []byte,
) types.ConfigDigest

func XXXContractSetConfigArgsFromSharedConfig

func XXXContractSetConfigArgsFromSharedConfig(
	c SharedConfig,
	sharedSecretEncryptionPublicKeys []types.SharedSecretEncryptionPublicKey,
) (
	signers []common.Address,
	transmitters []common.Address,
	threshold uint8,
	encodedConfigVersion uint64,
	encodedConfig []byte,
	err error,
)

Types

type OracleIdentity

type OracleIdentity struct {
	PeerID                string
	OffchainPublicKey     types.OffchainPublicKey
	OnChainSigningAddress types.OnChainSigningAddress
	TransmitAddress       common.Address
}

type PublicConfig

type PublicConfig struct {
	DeltaProgress    time.Duration
	DeltaResend      time.Duration
	DeltaRound       time.Duration
	DeltaGrace       time.Duration
	DeltaC           time.Duration
	AlphaPPB         uint64
	DeltaStage       time.Duration
	RMax             uint8
	S                []int
	OracleIdentities []OracleIdentity

	F            int
	ConfigDigest types.ConfigDigest
}

PublicConfig is the configuration disseminated through the smart contract It's public, because anybody can read it from the blockchain

func PublicConfigFromContractConfig

func PublicConfigFromContractConfig(chainID *big.Int, skipChainSpecificChecks bool, change types.ContractConfig) (PublicConfig, error)

func (*PublicConfig) CheckParameterBounds

func (c *PublicConfig) CheckParameterBounds() error

func (*PublicConfig) N

func (c *PublicConfig) N() int

N is the number of oracles participating in the protocol

type SharedConfig

type SharedConfig struct {
	PublicConfig
	SharedSecret *[SharedSecretSize]byte
}

SharedConfig is the configuration shared by all oracles running an instance of the protocol. It's disseminated through the smart contract, but parts of it are encrypted so that only oracles can access them.

func SharedConfigFromContractConfig

func SharedConfigFromContractConfig(
	chainID *big.Int,
	skipChainSpecificChecks bool,
	change types.ContractConfig,
	privateKeys types.PrivateKeys,
	peerID string,
	transmitAddress common.Address,
) (SharedConfig, commontypes.OracleID, error)

func (*SharedConfig) LeaderSelectionKey

func (c *SharedConfig) LeaderSelectionKey() [16]byte

func (*SharedConfig) TransmissionOrderKey

func (c *SharedConfig) TransmissionOrderKey() [16]byte

type SharedSecretEncryptions

type SharedSecretEncryptions struct {
	// (secret key chosen by dealer) * g, X25519 point
	DiffieHellmanPoint [curve25519.PointSize]byte

	// keccak256 of plaintext sharedSecret.
	//
	// Since SharedSecretEncryptions are shared through a smart contract, each
	// oracle will see the same SharedSecretHash. After decryption, oracles can
	// check their sharedSecret against SharedSecretHash to prevent the dealer
	// from equivocating
	SharedSecretHash common.Hash

	// Encryptions of the shared secret with one entry for each oracle. The
	// i-th oracle can recover the key as follows:
	//
	// 1. key := Keccak256(DH(DiffieHellmanPoint, process' secret key))[:16]
	// 2. sharedSecret := AES128DecryptBlock(key, Encryptions[i])
	//
	// See Decrypt for details.
	Encryptions []encryptedSharedSecret
}

SharedSecretEncryptions is the encryptions of SharedConfig.SharedSecret, using each oracle's SharedSecretEncryptionPublicKey.

We use a custom encryption scheme to be more space-efficient (compared to standard AEAD schemes, nacl crypto_box, etc...), which saves gas in transmission to the OffchainAggregator.

func XXXEncryptSharedSecret

func XXXEncryptSharedSecret(
	keys []types.SharedSecretEncryptionPublicKey,
	sharedSecret *[SharedSecretSize]byte,
	rand io.Reader,
) SharedSecretEncryptions

XXXEncryptSharedSecret constructs a SharedSecretEncryptions from a set of SharedSecretEncryptionPublicKeys, the sharedSecret, and a cryptographic randomness source

func XXXEncryptSharedSecretInternal

func XXXEncryptSharedSecretInternal(
	publicKeys []types.SharedSecretEncryptionPublicKey,
	sharedSecret *[SharedSecretSize]byte,
	sk *[32]byte,
) SharedSecretEncryptions

XXXEncryptSharedSecretInternal constructs a SharedSecretEncryptions from a set of SharedSecretEncryptionPublicKeys, the sharedSecret, and an ephemeral secret key sk

func (SharedSecretEncryptions) Decrypt

Decrypt returns the sharedSecret

func (SharedSecretEncryptions) Equal

Jump to

Keyboard shortcuts

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