vcs

package
v0.0.0-...-2aa9d22 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

All the functionalities when only pruned proof and pruned UPK tree is available. UPKs are technically not sent around as a tree, as UPK is fixed prefetching all UPKs for all indices of interest saves the time to fetch UPK from its tree. Same trick does not work for proof trees as we need to update them often.

Index

Constants

View Source
const MAX_AGG_SIZE = 1 << 19
View Source
const SEP = "\n========================================================================================"

Variables

View Source
var NCORES uint8
View Source
var NFILES uint8
View Source
var PRKNAME string
View Source
var TRAPDOORNAME string
View Source
var UPKNAME string
View Source
var VRKNAME string

Functions

func BoundsPrint

func BoundsPrint(start, stop uint64) string

func FindTreeGPS

func FindTreeGPS(k uint64, L int) []uint64

Index at each level of the proof tree. Ex: 33 will be [0:0, 1:0, 2:0, 3:1, 4:2, 5:4, 6:8, 7:16]

func GenerateVector

func GenerateVector(N uint64) []mcl.Fr

func GetFrByteSize

func GetFrByteSize() int

func GetG1ByteSize

func GetG1ByteSize() int

func GetG2ByteSize

func GetG2ByteSize() int

func GetGTByteSize

func GetGTByteSize() int

func GetProofVecFromDb

func GetProofVecFromDb(proofs_db map[uint64][]mcl.G1, indexVec []uint64) [][]mcl.G1

Export the proofs in the 2D format for the VCS API

func IndexInTheLevel

func IndexInTheLevel(n uint64) (uint8, uint64)

Converts 1D to 2D n = 7 the it corresponds to a value in [lg][start] in the tree. Say, when indexed from 0, [10] element in a 1D array is same as [3][3]

func IsEqual

func IsEqual(a, b *VCS) bool

func LoadVector

func LoadVector(N uint64, folderPath string) []mcl.Fr

func ReverseSliceBool

func ReverseSliceBool(a []bool) []bool

func ReverseSliceUint64

func ReverseSliceUint64(a []uint64) []uint64

func SaveVector

func SaveVector(N uint64, aFr []mcl.Fr)

func SliceIsEqual

func SliceIsEqual(a, b []mcl.G1) bool

func ToBinary

func ToBinary(index uint64, L uint8) []bool

Some global variables. Used in vcs.go LSB first 6 -> 0 1 1

Types

type TreeGPS

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

type VCS

type VCS struct {
	PRK          []mcl.G1   // PRK is technically not needed for our experiments
	UPK          [][]mcl.G1 // UPK forms a tree. The UPK API in code is different from the paper.
	VRK          []mcl.G2
	VRKSubOne    []mcl.G2 // h^(1-s_1)
	VRKSubOneRev []mcl.G2 // h^(s_1 - 1)

	N uint64
	L uint8
	G mcl.G1 //Generator
	H mcl.G2 //Generator

	ProofTree [][]mcl.G1 // Figure 2 from the paper is illustrative of how the ProofTree is saved.

	// GIPA Stuff
	MN uint64 // Power of 2 which is nearest to TxnLimit * L. In GIPA notation let M = L, n = TxnLimit = 1024

	TxnLimit uint64 // Number of txns in a block that needs to be aggregated

	DISCARD_PRK bool // We do not use: g, g^{s_1}, g^{s_2}, g^{s_1}{s_2}, g^{s_3}.....
	// Thus, PRK is discarded by default
	// UPK tree is enough for the prover
	PARAM_TOO_LARGE bool
	// contains filtered or unexported fields
}

func (*VCS) AggProve

func (vcs *VCS) AggProve(indexVec []uint64, proofVec [][]mcl.G1) batch.Proof

func (*VCS) AggVerify

func (vcs *VCS) AggVerify(proof batch.Proof, digest mcl.G1, indexVec []uint64, a_i []mcl.Fr) bool

func (*VCS) Commit

func (vcs *VCS) Commit(a []mcl.Fr, L uint64) mcl.G1

Do not remove L from the parameters. I am using it OpenAll

func (*VCS) GenAggGipa

func (vcs *VCS) GenAggGipa()

func (*VCS) GenProofsTreeFake

func (vcs *VCS) GenProofsTreeFake(count uint64) (mcl.G1, []uint64, []mcl.Fr, map[uint64][]mcl.G1, [][]mcl.G1, []map[uint64]mcl.G1)

Goal is to generate a proof tree using trapdoors

func (*VCS) GenUpkFake

func (vcs *VCS) GenUpkFake(index uint64) []mcl.G1

Given an index in the vector, get its upk. This goes from top of the tree to leaf.

func (*VCS) GetProofPath

func (vcs *VCS) GetProofPath(index uint64) []mcl.G1

Proof 1...l Index 0 has one 0-variables, index L - 1 has L-1 variable

func (*VCS) GetProofPathDB

func (vcs *VCS) GetProofPathDB(proofTree []map[uint64]mcl.G1, index uint64) []mcl.G1

Proof 1...l Index 0 has one 0-variables, index L - 1 has L-1 variable

func (*VCS) GetUpk

func (vcs *VCS) GetUpk(i uint64) []mcl.G1

g^{(1-s_1)}, g^{(1-s_2)(1-s_1)}, g^{(1-s_3)(1-s_2)(1-s_1)}

func (*VCS) Init

func (vcs *VCS) Init(L uint8, folder string, txnLimit uint64)

Instantiate a new vector commitment instance Space for UPK and PRK will be created when keys are created and saved. This reduces the memory footprint.

func (*VCS) KeyGen

func (vcs *VCS) KeyGen(ncores uint8, L uint8, folder string, txnLimit uint64)

Generates PRK VRK UPK etc Use this only once to generate the parameters.

func (*VCS) KeyGenFake

func (vcs *VCS) KeyGenFake(ncores uint8, L uint8, folder string, txnLimit uint64)

Generate the trapdoors Generate the keys for aggregation PRK and UPK is generated only during runtime using GenUpkFake

func (*VCS) KeyGenLoad

func (vcs *VCS) KeyGenLoad(ncores uint8, L uint8, folder string, txnLimit uint64)

Defacto entry to VCS. Use this to load the files always

func (*VCS) KeyGenLoadFake

func (vcs *VCS) KeyGenLoadFake(ncores uint8, L uint8, folder string, txnLimit uint64)

func (*VCS) LoadAggGipa

func (self *VCS) LoadAggGipa()

func (*VCS) LoadTrapdoor

func (vcs *VCS) LoadTrapdoor(L uint8)

func (*VCS) MallocUpk

func (vcs *VCS) MallocUpk()

Allocate space for UPK. This is not done with Init, as UPK and PRK may not fit in memory together.

func (*VCS) OpenAll

func (vcs *VCS) OpenAll(a []mcl.Fr)

func (*VCS) OpenAllRec

func (vcs *VCS) OpenAllRec(a []mcl.Fr, start uint64, end uint64, L uint8)

func (*VCS) PrkGen

func (vcs *VCS) PrkGen(index uint8, start uint64, stop uint64, wg *sync.WaitGroup)

[start, stop)

func (*VCS) PrkGenDriver

func (vcs *VCS) PrkGenDriver()

func (*VCS) PrkLoad

func (vcs *VCS) PrkLoad(fileName string, index uint8, start uint64, stop uint64, wg *sync.WaitGroup)

func (*VCS) PrkLoadDriver

func (vcs *VCS) PrkLoadDriver()

func (*VCS) PrkUpkGen

func (vcs *VCS) PrkUpkGen()

func (*VCS) PrkUpkLoad

func (vcs *VCS) PrkUpkLoad()

func (*VCS) ResizeAgg

func (self *VCS) ResizeAgg(txnLimit uint64)

This resets the variable MN and txnLimit. Be sure to load the data from disk

func (*VCS) SaveTrapdoor

func (vcs *VCS) SaveTrapdoor()

func (*VCS) SelectPRK

func (vcs *VCS) SelectPRK(index uint64) mcl.Fr

Use selector function to compute the powers of g. 101 => (s_3 * s_1) It is a worker to compute g, g^{s_1}, g^{s_2}, g^{s_1 s_2}, g^{s_3}, , g^{s_3 s_1} ...

func (*VCS) SelectUPK

func (vcs *VCS) SelectUPK(L uint8, index uint64) mcl.Fr

Compute the UPK located in a specific coordinate of the tree Say 3, 3 => g^{}

func (*VCS) TrapdoorsGen

func (vcs *VCS) TrapdoorsGen()

Generate trapdoors for the VCS. Be sure to run this after ```Init```.

func (*VCS) UpdateCom

func (vcs *VCS) UpdateCom(digest mcl.G1, updateindex uint64, delta mcl.Fr) mcl.G1

func (*VCS) UpdateComVec

func (vcs *VCS) UpdateComVec(digest mcl.G1, updateindex []uint64, delta []mcl.Fr) mcl.G1

func (*VCS) UpdateComVecDB

func (vcs *VCS) UpdateComVecDB(upk_db map[uint64][]mcl.G1, digest mcl.G1, updateindex []uint64, delta []mcl.Fr) mcl.G1

func (*VCS) UpdateProof

func (vcs *VCS) UpdateProof(proof []mcl.G1, localindex uint64, updateindex uint64, delta mcl.Fr) []mcl.G1

func (*VCS) UpdateProofTree

func (vcs *VCS) UpdateProofTree(updateindex uint64, delta mcl.Fr)

func (*VCS) UpdateProofTreeBulk

func (vcs *VCS) UpdateProofTreeBulk(updateindexVec []uint64, deltaVec []mcl.Fr) int

func (*VCS) UpdateProofTreeBulkDB

func (vcs *VCS) UpdateProofTreeBulkDB(proofTree []map[uint64]mcl.G1, upk_db map[uint64][]mcl.G1, updateindexVec []uint64, deltaVec []mcl.Fr) ([]map[uint64]mcl.G1, int)

This is analogous to the UpdateProofTree. UpdateProofTree uses the struct variable ProofTree to import all updates. Where as this code updates a pruned Proof tree. For ell = 30, it is not possible to store the entire proof tree in memory. Thus a pruned proof tree is only stored in-memory.

func (*VCS) UpkGen

func (vcs *VCS) UpkGen(index uint8, start uint64, stop uint64, wg *sync.WaitGroup)

func (*VCS) UpkGenDriver

func (vcs *VCS) UpkGenDriver()

func (*VCS) UpkLoad

func (vcs *VCS) UpkLoad(fileName string, index uint8, start uint64, stop uint64, wg *sync.WaitGroup)

func (*VCS) UpkLoadDriver

func (vcs *VCS) UpkLoadDriver()

func (*VCS) Verify

func (vcs *VCS) Verify(digest mcl.G1, index uint64, a_i mcl.Fr, proof []mcl.G1) bool

func (*VCS) VerifyMemoized

func (vcs *VCS) VerifyMemoized(digest mcl.G1, indexVec []uint64, a_i []mcl.Fr, proofVec [][]mcl.G1) (bool, int)

func (*VCS) VerifyUPK

func (vcs *VCS) VerifyUPK(index uint64, upkProof []mcl.G1) bool

Jump to

Keyboard shortcuts

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