entanglement

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package entanglement implements the cryptographic binding for kMOSAIC.

Index

Constants

View Source
const (
	DomainShare  = "kmosaic-share-v1"
	DomainCommit = "kmosaic-commit-v1"
	DomainBind   = "kmosaic-bind-v1"
	DomainNIZK   = "kmosaic-nizk-v1"
)

Variables

This section is empty.

Functions

func ComputeBinding

func ComputeBinding(slssBytes, tddBytes, egrwBytes []byte) []byte

ComputeBinding computes the cross-component binding hash. It binds the public keys of the three components (SLSS, TDD, EGRW) together. Uses three-layer binding with per-component domain separation for defense-in-depth.

func DeserializeNIZKProof

func DeserializeNIZKProof(data []byte) []byte

DeserializeNIZKProof returns the proof bytes; no parsing here (verification parses structure).

func GenerateNIZKProof

func GenerateNIZKProof(secret []byte, shares [][]byte, ciphertextHashes [][]byte, seed []byte) []byte

GenerateNIZKProof generates a Non-Interactive Zero-Knowledge proof of correct construction. In this simplified implementation, it acts as a binding of all inputs. A full implementation would use a Sigma protocol with Fiat-Shamir transform.

func SecretReconstruct

func SecretReconstruct(shares [][]byte) ([]byte, error)

SecretReconstruct reconstructs a secret from n shares. It computes the XOR sum of all shares.

func SecretShare

func SecretShare(secret []byte, n int) ([][]byte, error)

SecretShare splits a secret into n shares using XOR-based n-of-n sharing. The first n-1 shares are random, and the last share is computed such that the XOR sum of all shares equals the secret.

func SecretShareDeterministic

func SecretShareDeterministic(secret []byte, n int, seed []byte) ([][]byte, error)

SecretShareDeterministic creates deterministic shares from a seed. This is used in the KEM to ensure that the encapsulation is deterministic given the randomness.

func SerializeNIZKProof

func SerializeNIZKProof(proof []byte) []byte

SerializeNIZKProof returns the serialized proof as-is.

func VerifyCommitment

func VerifyCommitment(data, commitment, opening []byte) bool

VerifyCommitment verifies a binding commitment. It checks if H(data || opening) matches the commitment.

func VerifyNIZKProof

func VerifyNIZKProof(proof []byte, ciphertextHashes [][]byte, message []byte) bool

VerifyNIZKProof verifies a NIZK proof. It verifies the proof is correctly bound to the ciphertext hashes and binding.

Types

type BindingCommitment

type BindingCommitment struct {
	Commitment []byte
	Opening    []byte
}

BindingCommitment represents a commitment with its opening.

func CreateCommitment

func CreateCommitment(data []byte) (*BindingCommitment, error)

CreateCommitment creates a binding commitment to data. It returns the commitment hash and the opening (randomness).

type NIZKProof

type NIZKProof struct {
	Commitments [][]byte
	Responses   [][]byte
	Challenge   []byte
}

NIZKProof represents a non-interactive zero-knowledge proof.

Jump to

Keyboard shortcuts

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