Beispiel #1
0
func DelElementArray(t PrefixTree, z *cf.Zp) (marray []*cf.Zp) {
	points := t.Points()
	marray = make([]*cf.Zp, len(points))
	for i := 0; i < len(points); i++ {
		marray[i] = cf.Z(z.P).Sub(points[i], z).Inv()
	}
	return
}
Beispiel #2
0
func (n *MemPrefixNode) updateSvalues(z *cf.Zp, marray []*cf.Zp) {
	if len(marray) != len(n.points) {
		panic("Inconsistent NumSamples size")
	}
	for i := 0; i < len(marray); i++ {
		n.svalues[i] = cf.Z(z.P).Mul(n.svalues[i], marray[i])
	}
}
Beispiel #3
0
func (n *prefixNode) updateSvalues(z *cf.Zp, marray []*cf.Zp) {
	if len(marray) != len(n.points) {
		panic("Inconsistent NumSamples size")
	}
	svalues := mustDecodeZZarray(n.NodeSValues)
	for i := 0; i < len(marray); i++ {
		svalues[i] = cf.Z(z.P).Mul(svalues[i], marray[i])
	}
	n.NodeSValues = mustEncodeZZarray(svalues)
}
Beispiel #4
0
func (p *Peer) solve(remoteSamples, localSamples []*cf.Zp, remoteSize, localSize int, points []*cf.Zp) (*cf.ZSet, *cf.ZSet, error) {
	var values []*cf.Zp
	for i, x := range remoteSamples {
		values = append(values, cf.Z(x.P).Div(x, localSamples[i]))
	}
	p.logFields(GOSSIP, log.Fields{
		"values":  values,
		"points":  points,
		"degDiff": remoteSize - localSize,
	}).Debug("reconcile")
	return cf.Reconcile(values, points, remoteSize-localSize)
}
Beispiel #5
0
func AddElementArray(t PrefixTree, z *cf.Zp) (marray []*cf.Zp, err error) {
	points := t.Points()
	marray = make([]*cf.Zp, len(points))
	for i := 0; i < len(points); i++ {
		marray[i] = cf.Z(z.P).Sub(points[i], z)
		if marray[i].IsZero() {
			err = ErrSamplePointElement
			return
		}
	}
	return
}