cm

package
v0.0.0-...-63bedb4 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: Apache-2.0 Imports: 7 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CkFold

func CkFold(result *Ck, x mcl.Fr, xInv mcl.Fr, ck *Ck)

CkFold computes the new Ck for the next level of recursion. Given ck.V_L, ck.V_R, ck.W_L, ck.W_R computes ck' = (V', W') as follows: V' = xInv * V_R + V_L W' = x * W_R + W_L Parameters ---------- result: Pointer to Ck type. x : Fr, the exponent xInv : Fr, the exponent. x and xInv should be inverse of each other. ck: pointer to Ck object.

Returns ------- None. Call by reference, thus output is stored in variable result

func IPPSave

func IPPSave(ck *Ck, folderPath string)

Saves the commitment keys to a folder. Input: ck, folderPath Files are saved in folderPath/CK.data

func IPPSaveCmKzg

func IPPSaveCmKzg(ck *Ck, kzg1 *kzg.KZG1Settings, kzg2 *kzg.KZG2Settings, folderPath string)

Saves the commitment keys to a folder. Input: ck, kzg1, kzg2, folderPath Files are saved in folderPath/CK.data

Types

type Ck

type Ck struct {
	M uint64
	V []mcl.G2 // Ck_1
	W []mcl.G1 // Ck_2
}

Ck is a struct to hold LMR19 commitment keys. Note: Since ck_3 is 1_{\F_p}, it is ignored

func IPPCMLoad

func IPPCMLoad(M uint64, folderPath string) Ck

Loads the commitment keys from a folder. Input: M, folderPath Files are saved in folderPath/CK.data M needs to be a power of 2

func IPPCMLoadCmKzg

func IPPCMLoadCmKzg(M uint64, folderPath string) (Ck, kzg.KZG1Settings, kzg.KZG2Settings)

Loads the commitment keys and KZG keys from a folder. Input: M, folderPath Files are saved in folderPath/CK.data M needs to be a power of 2

func IPPSetup

func IPPSetup(m uint64, alpha mcl.Fr, beta mcl.Fr, g mcl.G1, h mcl.G2) *Ck

Computes the commitment keys V and W Squares the alpha and beta while generating the commitment keys

func IPPSetupKZG

func IPPSetupKZG(mn uint64, alpha mcl.Fr, beta mcl.Fr, g mcl.G1, h mcl.G2) (*Ck, *kzg.KZG1Settings, *kzg.KZG2Settings)

Computes the keys of size 2mn - 1 Computes the commitment keys V and W ck *Ck, kzg1 *kzg.KZG1Settings, kzg2 *kzg.KZG2Settings,

func LoadKeys

func LoadKeys(M uint64, folderPath string) (Ck, kzg.KZG1Settings, kzg.KZG2Settings)

func (*Ck) Clone

func (self *Ck) Clone(ck *Ck)

func (*Ck) New

func (ck *Ck) New(m uint64)

New is a constructor for the Ck struct. Assigns default values to the data members Parameters ---------- m: Size of the commitment keys

Size of the commitment key should be same as the size of the message
This code works only when the size if a power of 2

Returns ------- None

func (*Ck) Transform

func (ck *Ck) Transform(Ck1 *Ck, Ck2 *Ck)

Transform is a member of Ck. Given a ck of size m, it returns two m/2 sized ck which are cross-connected (illustrated below). Example: Given ck.V, ck.W Ck1 = (ck.V[:m/2], ck.W[m/2:]) Ck2 = (ck.V[m/2:], ck.W[:m/2]) TODO: Take in Ck1 and Ck1 as references in the function call to reduce overheads Parameters ---------- None

Returns ------- - Ck1 m/2 sized commitment key - Ck2 m/2 sized commitment key

type Com

type Com struct {
	Com [3]mcl.GT
}

Com is a struct to hold AFGHO16 commitments. This hold the commitment decribed in Page 14 of https://eprint.iacr.org/2019/1177/20200212:182642 com[0] holds the inner product of vector A and ck_1 aka \textbf{v} com[1] holds the inner product of vector B and ck_2 aka \textbf{w} com[2] holds the inner product of vector A and B

func ComFold

func ComFold(x mcl.Fr, xInv mcl.Fr, ComL *Com, C *Com, ComR *Com) Com

ComFold computes the new commitment for the next level of recursion. Given com, ComL, ComR computes com' = ComL^x * com * ComR^(x^-1)

Parameters ---------- result: Pointer to Com type. x : Fr, the exponent xInv : Fr, the exponent. x and xInv should be inverse of each other. ComL: Pointer to Com type. com: Pointer to Com type. ComR: Pointer to Com type.

Returns ------- None. Call by reference, thus output is stored in variable result

func IPPCM

func IPPCM(ck *Ck, A []mcl.G1, B []mcl.G2, Z mcl.GT) Com

Commit function Computes result = (A * ck.V, ck.W * B, Z) Z is returned as is.

func (*Com) IsEqual

func (self *Com) IsEqual(com *Com) bool

IsEqual is a member function of Com Checks if two commitments are the same

Parameters ---------- com: Com

Returns ------- bool, true if all the members self.com equals com

type KZGPk

type KZGPk struct {
	G []mcl.G1
	H []mcl.G2
}

G will be the Pk for KZG1 H will be the Pk for KZG2

type KZGVk

type KZGVk struct {
	G []mcl.G1
	H []mcl.G2
}

Jump to

Keyboard shortcuts

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