trie_kzg_bn256

package
v0.0.0-...-bfb0b02 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2024 License: MIT Imports: 12 Imported by: 0

README

Package trie_kzg_bn256

Package contain implementation of commitment model for the 256+ trie based on KZG (Kate) polynomial commitments. The underlying math can be found in Formulas for polynomial KZG commitments in Lagrange basis.

Documentation

Index

Constants

View Source
const FACTOR = 5743

factor of order-1

Variables

View Source
var Model = New()

Model is a singleton

Functions

func GenRootOfUnityQuasiPrimitive

func GenRootOfUnityQuasiPrimitive(suite *bn256.Suite, d uint16) (kyber.Scalar, []kyber.Scalar)

GenRootOfUnityQuasiPrimitive generates random roots of unity based on FACTOR until all its powers up to D-1 are long enough thus excluding also 1. Note that the generated root of unity may not be primitive wrt FACTOR

func GetTrustedSetupBin

func GetTrustedSetupBin() []byte

Types

type CommitmentModel

type CommitmentModel struct {
	TrustedSetup
}

CommitmentModel implements 256+ trie based on blake2b hashing

func New

func New() *CommitmentModel

func (*CommitmentModel) AlwaysStoreTerminalWithNode

func (m *CommitmentModel) AlwaysStoreTerminalWithNode() bool

func (*CommitmentModel) CalcNodeCommitment

func (m *CommitmentModel) CalcNodeCommitment(data *common.NodeData, nodePath []byte) common.VCommitment

func (*CommitmentModel) CommitToData

func (m *CommitmentModel) CommitToData(data []byte) common.TCommitment

func (*CommitmentModel) Description

func (m *CommitmentModel) Description() string

func (*CommitmentModel) EqualCommitments

func (m *CommitmentModel) EqualCommitments(c1, c2 common.Serializable) bool

func (*CommitmentModel) ExtractDataFromTCommitment

func (m *CommitmentModel) ExtractDataFromTCommitment(c common.TCommitment) ([]byte, bool)

func (*CommitmentModel) ForceStoreTerminalWithNode

func (m *CommitmentModel) ForceStoreTerminalWithNode(_ common.TCommitment) bool

func (*CommitmentModel) NewTerminalCommitment

func (m *CommitmentModel) NewTerminalCommitment() common.TCommitment

func (*CommitmentModel) NewVectorCommitment

func (m *CommitmentModel) NewVectorCommitment() common.VCommitment

func (*CommitmentModel) PathArity

func (m *CommitmentModel) PathArity() common.PathArity

func (*CommitmentModel) ShortName

func (m *CommitmentModel) ShortName() string

func (*CommitmentModel) UpdateNodeCommitment

func (m *CommitmentModel) UpdateNodeCommitment(mutate *common.NodeData, childUpdates map[byte]common.VCommitment, terminal common.TCommitment, pathFragment, nodePath []byte, calcDelta bool)

UpdateNodeCommitment updates mutated part of node's data and, optionaly, upper

func (*CommitmentModel) UpdateVCommitment

func (m *CommitmentModel) UpdateVCommitment(c *common.VCommitment, delta common.VCommitment)

type TrustedSetup

type TrustedSetup struct {
	Suite         *bn256.Suite
	D             uint16
	Omega         kyber.Scalar  // persistent
	LagrangeBasis []kyber.Point // persistent. TLi = [l<i>(secret)]1
	Diff2         []kyber.Point // persistent
	// auxiliary, precalculated values
	Domain        []kyber.Scalar // non-persistent. if omega != 0, domain_i =  omega^i, otherwise domain_i = i.
	AprimeDomainI []kyber.Scalar // A'(i)

	ZeroG1 kyber.Scalar // aux
	OneG1  kyber.Scalar // aux
	// contains filtered or unexported fields
}

TrustedSetup is a trusted setup for KZG calculations with degree D. The domain of Lagrange polynomials is either defined by powers of omega, assuming omega^i != 1 for any 0<=i<D or, of omega == 0, it is 0, 1, 2, ..., D-1 The secret itself must be destroyed immediately after trusted setup is generated. The trusted setup is a public value stored for examples in a file. It is impossible to restore secret from the trusted setup [x]1 means a projection of scalar x to the G1 curve. [x]1 = xG, where G is the generating element [x]2 means a projection of scalar x to the G2 curve. [x]2 = xH, where H is the generating element

func TrustedSetupFromBytes

func TrustedSetupFromBytes(suite *bn256.Suite, data []byte) (*TrustedSetup, error)

TrustedSetupFromBytes unmarshals trusted setup from binary representation

func TrustedSetupFromFile

func TrustedSetupFromFile(suite *bn256.Suite, fname string) (*TrustedSetup, error)

TrustedSetupFromFile restores trusted setup from file

func TrustedSetupFromSecretNaturalDomain

func TrustedSetupFromSecretNaturalDomain(suite *bn256.Suite, d uint16, secret kyber.Scalar) (*TrustedSetup, error)

TrustedSetupFromSecretNaturalDomain uses 0,1,2,.. domain instead of omega

func TrustedSetupFromSecretPowers

func TrustedSetupFromSecretPowers(suite *bn256.Suite, d uint16, omega, secret kyber.Scalar) (*TrustedSetup, error)

TrustedSetupFromSecretPowers calculates TrustedSetup from secret and omega It uses powers of the omega as a domain for Lagrange basis Only used once after what secret must be destroyed

func TrustedSetupFromSeed

func TrustedSetupFromSeed(suite *bn256.Suite, d uint16, seed []byte) (*TrustedSetup, error)

TrustedSetupFromSeed for testing only

func (*TrustedSetup) Bytes

func (sd *TrustedSetup) Bytes() []byte

Bytes marshals the trusted setup

Directories

Path Synopsis
the program kzg_setup generates new trusted setup for the KZG calculations from the secret entered from the keyboard and saves generated setup into the file Usage: kzg_setup <file name>
the program kzg_setup generates new trusted setup for the KZG calculations from the secret entered from the keyboard and saves generated setup into the file Usage: kzg_setup <file name>

Jump to

Keyboard shortcuts

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