fhe

package
v1.22.78 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2026 License: BSD-3-Clause Imports: 21 Imported by: 0

Documentation

Overview

Package fhe provides Fully Homomorphic Encryption primitives for the Lux blockchain. It uses the native luxfi/lattice library (CKKS scheme) with threshold decryption support.

This implementation uses Lux's own pure-Go lattice cryptography library, providing permissively-licensed FHE operations.

Index

Constants

View Source
const (
	// ProtocolFHE is the protocol identifier for FHE operations
	ProtocolFHE = "fhe"

	// ProtocolFHEThreshold is the protocol for threshold FHE decryption
	ProtocolFHEThreshold = "fhe-threshold"
)

Protocol constants

Variables

This section is empty.

Functions

This section is empty.

Types

type Ciphertext

type Ciphertext struct {
	// Type is the encrypted value type
	Type EncryptedType

	// Handle is a unique identifier for this ciphertext in the FHE store
	Handle [32]byte

	// Ct is the underlying RLWE ciphertext
	Ct *rlwe.Ciphertext

	// Level is the current multiplicative depth level
	Level int

	// Scale is the encoding scale (for CKKS)
	Scale float64
}

Ciphertext wraps an RLWE ciphertext with metadata

func NewCiphertext

func NewCiphertext(t EncryptedType, ct *rlwe.Ciphertext, handle [32]byte) *Ciphertext

NewCiphertext creates a new Ciphertext wrapper

func (*Ciphertext) Deserialize

func (c *Ciphertext) Deserialize(data []byte, params rlwe.ParameterProvider) error

Deserialize reconstructs a ciphertext from bytes

func (*Ciphertext) Serialize

func (c *Ciphertext) Serialize() ([]byte, error)

Serialize converts the ciphertext to bytes for storage/transmission

type Config

type Config struct {
	// LogN is the ring degree (log2). Higher = more security but slower.
	// Recommended: 14 (16384 slots) for 128-bit security
	LogN int `json:"logN"`

	// LogQ is the ciphertext modulus chain (bits per level)
	LogQ []int `json:"logQ"`

	// LogP is the special modulus for key-switching
	LogP []int `json:"logP"`

	// LogDefaultScale is the default encoding scale
	LogDefaultScale int `json:"logDefaultScale"`

	// Threshold is t in t-out-of-n threshold scheme
	Threshold int `json:"threshold"`

	// MaxOperations is the maximum multiplicative depth before refresh needed
	MaxOperations int `json:"maxOperations"`
}

Config holds FHE processor configuration

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns a default FHE configuration for DeFi applications 128-bit security, suitable for financial computations

type Coprocessor

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

Coprocessor is the FHE computation coprocessor It receives tasks from C-Chain, computes on Z-Chain, and returns results

func NewCoprocessor

func NewCoprocessor(processor *Processor, logger log.Logger, maxQueueSize, workerCount int) *Coprocessor

NewCoprocessor creates a new FHE coprocessor

func (*Coprocessor) CreateTask

func (c *Coprocessor) CreateTask(op OpCode, inputs [][32]byte, scalars []uint64, resultType EncryptedType) *Task

CreateTask creates a new task with a unique ID

func (*Coprocessor) GetTaskResult

func (c *Coprocessor) GetTaskResult(taskID [32]byte) (*Task, error)

GetTaskResult retrieves a completed task result

func (*Coprocessor) HandleCrossChainRequest

func (c *Coprocessor) HandleCrossChainRequest(req *TaskRequest) *TaskResponse

HandleCrossChainRequest processes a task request from C-Chain

func (*Coprocessor) SetWarpCallback

func (c *Coprocessor) SetWarpCallback(callback *WarpCallback)

SetWarpCallback sets the Warp callback handler for sending results

func (*Coprocessor) Start

func (c *Coprocessor) Start()

Start starts the coprocessor workers

func (*Coprocessor) Stats

func (c *Coprocessor) Stats() (processed, completed, failed uint64, queueLen int)

Stats returns coprocessor statistics

func (*Coprocessor) Stop

func (c *Coprocessor) Stop()

Stop stops the coprocessor

func (*Coprocessor) SubmitTask

func (c *Coprocessor) SubmitTask(task *Task) error

SubmitTask submits a task for processing

type DecryptionRequest

type DecryptionRequest struct {
	// RequestID is a unique identifier for this request
	RequestID [32]byte

	// Ciphertext is the value to decrypt
	Ciphertext *Ciphertext

	// Requester is the address authorized to receive the decryption
	Requester [20]byte

	// Callback is the contract address to call with the result
	Callback [20]byte

	// CallbackSelector is the function selector for the callback
	CallbackSelector [4]byte
}

DecryptionRequest represents a request for threshold decryption

type DecryptionResult

type DecryptionResult struct {
	// RequestID matches the original request
	RequestID [32]byte

	// Plaintext is the decrypted value (encoded based on Type)
	Plaintext []byte

	// Signature is the threshold signature proving correctness
	Signature []byte
}

DecryptionResult represents the final decryption result

type DecryptionSession

type DecryptionSession struct {
	// RequestID is the unique identifier for this decryption request
	RequestID [32]byte

	// Ciphertext being decrypted
	Ciphertext *Ciphertext

	// Shares collected from parties
	PublicShares  map[uint64]*multiparty.KeySwitchShare
	SecretShares  map[uint64]*multiparty.AdditiveShareBigint
	ActiveParties []multiparty.ShamirPublicPoint
	SharesMu      sync.RWMutex

	// Result when decryption is complete
	Result    []complex128
	Completed bool
	Error     error

	// Callbacks
	Callback func(result []complex128, err error)
}

DecryptionSession represents an active threshold decryption request

type DecryptionShare

type DecryptionShare struct {
	// PartyID identifies the party that created this share
	PartyID string

	// Share is the partial decryption share
	Share []byte

	// Signature proves the share is authentic
	Signature []byte
}

DecryptionShare represents a partial decryption from one threshold party

type DistributedKeyGen

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

DistributedKeyGen represents a distributed key generation protocol session

func NewDistributedKeyGen

func NewDistributedKeyGen(params ckks.Parameters, threshold, totalParties int, partyID uint64, crs []byte) (*DistributedKeyGen, error)

NewDistributedKeyGen creates a new distributed key generation session

func (*DistributedKeyGen) GenerateLocalKey

func (dkg *DistributedKeyGen) GenerateLocalKey() (*rlwe.SecretKey, error)

GenerateLocalKey generates this party's local secret key contribution

func (*DistributedKeyGen) GetLocalSecretShare

func (dkg *DistributedKeyGen) GetLocalSecretShare() *rlwe.SecretKey

GetLocalSecretShare returns the local secret key share

func (*DistributedKeyGen) GetLocalShamirShare

func (dkg *DistributedKeyGen) GetLocalShamirShare() *multiparty.ShamirSecretShare

GetLocalShamirShare returns the local Shamir share

type EncryptedInput

type EncryptedInput struct {
	// Ciphertext is the encrypted value
	Ciphertext *Ciphertext

	// Proof is a zero-knowledge proof of correct encryption (zkPoK)
	// This proves the encryptor knows the plaintext without revealing it
	Proof []byte

	// Sender is the address of the sender (for access control)
	Sender [20]byte
}

EncryptedInput represents an encrypted input with proof of correct encryption

type EncryptedType

type EncryptedType uint8

EncryptedType represents the type of encrypted value

const (
	// EBool represents an encrypted boolean
	EBool EncryptedType = iota
	// EUint8 represents an encrypted 8-bit unsigned integer
	EUint8
	// EUint16 represents an encrypted 16-bit unsigned integer
	EUint16
	// EUint32 represents an encrypted 32-bit unsigned integer
	EUint32
	// EUint64 represents an encrypted 64-bit unsigned integer
	EUint64
	// EUint128 represents an encrypted 128-bit unsigned integer
	EUint128
	// EUint256 represents an encrypted 256-bit unsigned integer
	EUint256
	// EAddress represents an encrypted 20-byte Ethereum address
	EAddress
)

func (EncryptedType) BitSize

func (t EncryptedType) BitSize() int

BitSize returns the bit size of the encrypted type

func (EncryptedType) MaxValue

func (t EncryptedType) MaxValue() uint64

MaxValue returns the maximum value for the encrypted type

func (EncryptedType) String

func (t EncryptedType) String() string

String returns the string representation of the encrypted type

type FHEKeyShare

type FHEKeyShare struct {
	PublicKeyBytes    []byte
	SecretKeyShare    *rlwe.SecretKey
	ShamirSecretShare *multiparty.ShamirSecretShare
	PartyIdentity     uint64
	ThresholdValue    int
	TotalPartiesValue int
	GenerationValue   uint64
}

FHEKeyShare wraps FHE key material to implement the KeyShare interface

func (*FHEKeyShare) Generation

func (s *FHEKeyShare) Generation() uint64

func (*FHEKeyShare) PartyID

func (s *FHEKeyShare) PartyID() uint64

func (*FHEKeyShare) Protocol

func (s *FHEKeyShare) Protocol() string

func (*FHEKeyShare) PublicKey

func (s *FHEKeyShare) PublicKey() []byte

func (*FHEKeyShare) Serialize

func (s *FHEKeyShare) Serialize() ([]byte, error)

func (*FHEKeyShare) Threshold

func (s *FHEKeyShare) Threshold() int

func (*FHEKeyShare) TotalParties

func (s *FHEKeyShare) TotalParties() int

type FHEMessage

type FHEMessage struct {
	Type      FHEMessageType
	SessionID [32]byte
	PartyID   uint64
	Payload   []byte
}

FHEMessage represents a message for FHE protocol communication

type FHEMessageType

type FHEMessageType uint8

FHEMessageType represents the type of FHE protocol message

const (
	MsgDecryptRequest FHEMessageType = iota
	MsgDecryptShare
	MsgDecryptResult
	MsgKeygenRound1
	MsgKeygenRound2
	MsgKeygenComplete
	MsgReshareRequest
	MsgReshareShare
	MsgRefreshRequest
	MsgRefreshShare
)

type FHEProtocolHandler

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

FHEProtocolHandler implements threshold FHE operations for ThresholdVM integration

func NewFHEProtocolHandler

func NewFHEProtocolHandler(params ckks.Parameters, threshold, total int, partyID uint64) (*FHEProtocolHandler, error)

NewFHEProtocolHandler creates a new FHE protocol handler

func (*FHEProtocolHandler) CleanupSession

func (h *FHEProtocolHandler) CleanupSession(sessionID [32]byte)

CleanupSession removes a completed session

func (*FHEProtocolHandler) CreateDecryptShareMessage

func (h *FHEProtocolHandler) CreateDecryptShareMessage(sessionID [32]byte, share []byte) *FHEMessage

CreateDecryptShareMessage creates a message containing our decryption share

func (*FHEProtocolHandler) GenerateDecryptionShare

func (h *FHEProtocolHandler) GenerateDecryptionShare(ct *Ciphertext) ([]byte, error)

GenerateDecryptionShare creates this party's decryption share for a ciphertext

func (*FHEProtocolHandler) GetDecryptionResult

func (h *FHEProtocolHandler) GetDecryptionResult(sessionID [32]byte) ([]byte, error)

GetDecryptionResult returns the decryption result if available

func (*FHEProtocolHandler) GetSessionStatus

func (h *FHEProtocolHandler) GetSessionStatus(sessionID [32]byte) (*FHESession, error)

GetSessionStatus returns the status of a session

func (*FHEProtocolHandler) HandleMessage

func (h *FHEProtocolHandler) HandleMessage(msg *FHEMessage) error

HandleMessage processes an incoming FHE protocol message

func (*FHEProtocolHandler) Name

func (h *FHEProtocolHandler) Name() string

Name returns the protocol name

func (*FHEProtocolHandler) SetEvaluationKeys

func (h *FHEProtocolHandler) SetEvaluationKeys(relin *rlwe.RelinearizationKey, galois *rlwe.GaloisKey)

SetEvaluationKeys sets the evaluation keys (relinearization, galois)

func (*FHEProtocolHandler) SetKeys

SetKeys sets the FHE key material

func (*FHEProtocolHandler) StartDecryption

func (h *FHEProtocolHandler) StartDecryption(
	ctx context.Context,
	ct *Ciphertext,
	requester [20]byte,
) ([32]byte, error)

StartDecryption initiates a threshold decryption session

func (*FHEProtocolHandler) SubmitDecryptionShare

func (h *FHEProtocolHandler) SubmitDecryptionShare(
	sessionID [32]byte,
	partyID uint64,
	share []byte,
) error

SubmitDecryptionShare processes a decryption share from another party

func (*FHEProtocolHandler) SupportedOperations

func (h *FHEProtocolHandler) SupportedOperations() []string

SupportedOperations returns supported FHE operations

type FHESession

type FHESession struct {
	ID        [32]byte
	Type      FHESessionType
	Status    FHESessionStatus
	Requester [20]byte // Contract address

	// For decryption
	Ciphertext *Ciphertext

	// For keygen
	KeygenRound int

	// Collected shares
	Shares     map[uint64][]byte
	ShareCount int

	// Result
	Result []byte
	Error  error
	// contains filtered or unexported fields
}

FHESession represents an active FHE protocol session

type FHESessionStatus

type FHESessionStatus uint8

FHESessionStatus represents the status of an FHE session

const (
	StatusPending FHESessionStatus = iota
	StatusCollecting
	StatusProcessing
	StatusCompleted
	StatusFailed
)

type FHESessionType

type FHESessionType uint8

FHESessionType represents the type of FHE protocol session

const (
	SessionDecrypt FHESessionType = iota
	SessionKeygen
	SessionReshare
	SessionRefresh
)

type OpCode

type OpCode uint8

OpCode represents an FHE operation code

const (
	OpAdd OpCode = iota
	OpSub
	OpMul
	OpNeg
	OpLt
	OpGt
	OpLte
	OpGte
	OpEq
	OpNe
	OpNot
	OpAnd
	OpOr
	OpXor
	OpSelect
	OpMin
	OpMax
	OpShl
	OpShr
	OpEncrypt
	OpDecrypt
	OpVerifyInput
)

func (OpCode) String

func (op OpCode) String() string

String returns the operation name

type Processor

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

Processor is the main FHE computation engine

func NewProcessor

func NewProcessor(config Config, logger log.Logger) (*Processor, error)

NewProcessor creates a new FHE processor with the given configuration

func (*Processor) Add

func (p *Processor) Add(a, b *Ciphertext) (*Ciphertext, error)

Add performs homomorphic addition: result = a + b

func (*Processor) AddPlain

func (p *Processor) AddPlain(a *Ciphertext, scalar uint64) (*Ciphertext, error)

AddPlain performs homomorphic addition with plaintext: result = a + scalar

func (*Processor) And

func (p *Processor) And(a, b *Ciphertext) (*Ciphertext, error)

And performs homomorphic AND: result = a * b (for boolean)

func (*Processor) Decrypt

func (p *Processor) Decrypt(ct *Ciphertext) (interface{}, error)

Decrypt decrypts a ciphertext (for testing only - use threshold in production)

func (*Processor) Encrypt

func (p *Processor) Encrypt(value interface{}, t EncryptedType) (*Ciphertext, error)

Encrypt encrypts a value and returns a handle

func (*Processor) EncryptBool

func (p *Processor) EncryptBool(value bool) (*Ciphertext, error)

EncryptBool encrypts a boolean value

func (*Processor) EncryptUint64

func (p *Processor) EncryptUint64(value uint64, t EncryptedType) (*Ciphertext, error)

EncryptUint64 encrypts a uint64 value

func (*Processor) Eq

func (p *Processor) Eq(a, b *Ciphertext) (*Ciphertext, error)

Eq performs homomorphic equality: result = (a == b) ? 1 : 0

func (*Processor) GenerateKeys

func (p *Processor) GenerateKeys() error

GenerateKeys generates a new FHE key pair In production, the secret key is immediately split into threshold shares

func (*Processor) GenerateThresholdShares

func (p *Processor) GenerateThresholdShares(partyPoints []multiparty.ShamirPublicPoint) ([]multiparty.ShamirSecretShare, error)

GenerateThresholdShares splits the secret key into threshold shares These shares should be distributed to T-Chain signers

func (*Processor) GetCiphertext

func (p *Processor) GetCiphertext(handle [32]byte) (*Ciphertext, error)

GetCiphertext retrieves a ciphertext by handle

func (*Processor) GetEncoder

func (p *Processor) GetEncoder() *ckks.Encoder

GetEncoder returns the encoder for external use

func (*Processor) GetParams

func (p *Processor) GetParams() ckks.Parameters

GetParams returns the CKKS parameters

func (*Processor) GetPublicKey

func (p *Processor) GetPublicKey() *rlwe.PublicKey

GetPublicKey returns the public key for external encryption

func (*Processor) Gt

func (p *Processor) Gt(a, b *Ciphertext) (*Ciphertext, error)

Gt performs homomorphic greater-than: result = (a > b) ? 1 : 0

func (*Processor) Gte

func (p *Processor) Gte(a, b *Ciphertext) (*Ciphertext, error)

Gte performs homomorphic greater-than-or-equal: result = (a >= b) ? 1 : 0

func (*Processor) Lt

func (p *Processor) Lt(a, b *Ciphertext) (*Ciphertext, error)

Lt performs homomorphic less-than: result = (a < b) ? 1 : 0

func (*Processor) Lte

func (p *Processor) Lte(a, b *Ciphertext) (*Ciphertext, error)

Lte performs homomorphic less-than-or-equal: result = (a <= b) ? 1 : 0

func (*Processor) Max

func (p *Processor) Max(a, b *Ciphertext) (*Ciphertext, error)

Max returns the maximum of two encrypted values

func (*Processor) Min

func (p *Processor) Min(a, b *Ciphertext) (*Ciphertext, error)

Min returns the minimum of two encrypted values

func (*Processor) Mul

func (p *Processor) Mul(a, b *Ciphertext) (*Ciphertext, error)

Mul performs homomorphic multiplication: result = a * b Note: Consumes one multiplicative level

func (*Processor) MulPlain

func (p *Processor) MulPlain(a *Ciphertext, scalar uint64) (*Ciphertext, error)

MulPlain performs homomorphic multiplication with plaintext: result = a * scalar

func (*Processor) Ne

func (p *Processor) Ne(a, b *Ciphertext) (*Ciphertext, error)

Ne performs homomorphic not-equal: result = (a != b) ? 1 : 0

func (*Processor) Neg

func (p *Processor) Neg(a *Ciphertext) (*Ciphertext, error)

Neg performs homomorphic negation: result = -a

func (*Processor) Not

func (p *Processor) Not(a *Ciphertext) (*Ciphertext, error)

Not performs homomorphic NOT: result = 1 - a (for boolean)

func (*Processor) OpCount

func (p *Processor) OpCount() uint64

OpCount returns the number of operations performed

func (*Processor) Or

func (p *Processor) Or(a, b *Ciphertext) (*Ciphertext, error)

Or performs homomorphic OR: result = a + b - a*b (for boolean)

func (*Processor) Select

func (p *Processor) Select(condition, ifTrue, ifFalse *Ciphertext) (*Ciphertext, error)

Select performs conditional selection: result = condition ? ifTrue : ifFalse This is the key operation for private DeFi (e.g., "if balance >= amount then transfer")

func (*Processor) Shl

func (p *Processor) Shl(a *Ciphertext, bits uint) (*Ciphertext, error)

Shl performs left shift by a constant: result = a << bits

func (*Processor) Shr

func (p *Processor) Shr(a *Ciphertext, bits uint) (*Ciphertext, error)

Shr performs right shift by a constant: result = a >> bits Note: This is approximate due to CKKS arithmetic

func (*Processor) StoreCiphertext

func (p *Processor) StoreCiphertext(ct *Ciphertext) [32]byte

StoreCiphertext stores a ciphertext and returns its handle

func (*Processor) Sub

func (p *Processor) Sub(a, b *Ciphertext) (*Ciphertext, error)

Sub performs homomorphic subtraction: result = a - b

func (*Processor) Xor

func (p *Processor) Xor(a, b *Ciphertext) (*Ciphertext, error)

Xor performs homomorphic XOR: result = a + b - 2*a*b (for boolean)

type Task

type Task struct {
	// ID is a unique task identifier
	ID [32]byte

	// Op is the operation to perform
	Op OpCode

	// Inputs are handles to input ciphertexts
	Inputs [][32]byte

	// ScalarInputs are plaintext scalar inputs (for mul_plain, shl, etc.)
	ScalarInputs []uint64

	// ResultType is the expected result type
	ResultType EncryptedType

	// Requester is the C-Chain contract that submitted this task
	Requester [20]byte

	// SourceChain is the chain that submitted this task
	SourceChain ids.ID

	// Callback is the function to call with the result
	Callback         [20]byte
	CallbackSelector [4]byte

	// Submitted is when the task was created
	Submitted time.Time

	// Status is the current task status
	Status TaskStatus

	// Result is the output handle (set when completed)
	Result [32]byte

	// Error is set if the task failed
	Error string
}

Task represents an FHE computation task submitted to the coprocessor

type TaskRequest

type TaskRequest struct {
	// SourceChain is the chain that submitted the request
	SourceChain ids.ID

	// RequestID is unique within the source chain
	RequestID uint64

	// Op is the FHE operation
	Op OpCode

	// InputHandles are ciphertext handles
	InputHandles [][32]byte

	// ScalarInputs for operations that need them
	ScalarInputs []uint64

	// ResultType is the expected output type
	ResultType EncryptedType

	// Callback information
	CallbackContract [20]byte
	CallbackSelector [4]byte
}

TaskRequest is the cross-chain message format for submitting tasks

type TaskResponse

type TaskResponse struct {
	// RequestID matches the original request
	RequestID uint64

	// Success indicates if the operation succeeded
	Success bool

	// ResultHandle is the ciphertext handle (if success)
	ResultHandle [32]byte

	// Error message (if not success)
	Error string
}

TaskResponse is the cross-chain response format

type TaskStatus

type TaskStatus uint8

TaskStatus represents the status of a task

const (
	TaskPending TaskStatus = iota
	TaskProcessing
	TaskCompleted
	TaskFailed
)

type ThresholdConfig

type ThresholdConfig struct {
	// Threshold is the minimum number of parties required (t)
	Threshold int

	// TotalParties is the total number of parties (n)
	TotalParties int

	// PartyID is this node's unique identifier
	PartyID uint64

	// NoiseFlooding is the noise parameter for security
	NoiseFlooding float64
}

ThresholdConfig contains configuration for threshold decryption

func DefaultThresholdConfig

func DefaultThresholdConfig() ThresholdConfig

DefaultThresholdConfig returns default threshold configuration

type ThresholdDecryptor

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

ThresholdDecryptor manages threshold FHE decryption using luxfi/lattice. It implements t-out-of-n threshold access structure where at least t parties must participate to decrypt a ciphertext.

func NewThresholdDecryptor

func NewThresholdDecryptor(params ckks.Parameters, config ThresholdConfig) (*ThresholdDecryptor, error)

NewThresholdDecryptor creates a new threshold decryptor instance

func (*ThresholdDecryptor) CleanupSession

func (td *ThresholdDecryptor) CleanupSession(requestID [32]byte)

CleanupSession removes a completed session

func (*ThresholdDecryptor) GetSession

func (td *ThresholdDecryptor) GetSession(requestID [32]byte) (*DecryptionSession, error)

GetSession returns the status of a decryption session

func (*ThresholdDecryptor) RequestDecryption

func (td *ThresholdDecryptor) RequestDecryption(
	ctx context.Context,
	ct *Ciphertext,
	callback func(result []complex128, err error),
) ([32]byte, error)

RequestDecryption initiates a threshold decryption request

func (*ThresholdDecryptor) SetKeyShare

func (td *ThresholdDecryptor) SetKeyShare(sk *rlwe.SecretKey)

SetKeyShare sets the party's secret key share (from distributed keygen)

func (*ThresholdDecryptor) SetShamirShare

func (td *ThresholdDecryptor) SetShamirShare(share *multiparty.ShamirSecretShare)

SetShamirShare sets the party's Shamir secret share

func (*ThresholdDecryptor) SubmitShare

func (td *ThresholdDecryptor) SubmitShare(
	requestID [32]byte,
	partyID uint64,
	publicShare *multiparty.KeySwitchShare,
	secretShare *multiparty.AdditiveShareBigint,
) error

SubmitShare processes a decryption share from another party

type ThresholdKeyGen

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

ThresholdKeyGen generates distributed key shares for threshold FHE

func NewThresholdKeyGen

func NewThresholdKeyGen(params ckks.Parameters, threshold, totalParties int) *ThresholdKeyGen

NewThresholdKeyGen creates a new threshold key generator

func (*ThresholdKeyGen) GenerateShares

func (tkg *ThresholdKeyGen) GenerateShares(secretKey *rlwe.SecretKey) (map[uint64]*multiparty.ShamirSecretShare, error)

GenerateShares generates Shamir secret shares for all parties

type WarpCallback

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

WarpCallback handles sending results back via Warp messaging

func NewWarpCallback

func NewWarpCallback(
	logger log.Logger,
	networkID uint32,
	chainID ids.ID,
	signer warp.Signer,
	onMessage func(context.Context, *warp.Message) error,
) *WarpCallback

NewWarpCallback creates a new Warp callback handler

func (*WarpCallback) SendTaskResult

func (w *WarpCallback) SendTaskResult(ctx context.Context, task *Task) error

SendTaskResult sends a task result back to the source chain

Jump to

Keyboard shortcuts

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