accumulator

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

README

Cryptographic Accumulators

This package cryptographic accumulators. At the moment, it contains an implementation of Dynamic Universal Accumulator with Batch Update over Bilinear Groups

Documentation

Overview

Package accumulator implements the cryptographic accumulator as described in https://eprint.iacr.org/2020/777.pdf It also implements the zero knowledge proof of knowledge protocol described in section 7 of the paper. Note: the paper only describes for non-membership witness case, but we don't use non-membership witness. We only implement the membership witness case.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Accumulator

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

Accumulator is a point

func (*Accumulator) Add

func (acc *Accumulator) Add(key *SecretKey, e Element) (*Accumulator, error)

Add accumulates a single element into the accumulator V' = (y + alpha) * V

func (*Accumulator) AddElements

func (acc *Accumulator) AddElements(key *SecretKey, m []Element) (*Accumulator, error)

AddElements accumulates a set of elements into the accumulator.

func (Accumulator) MarshalBinary

func (acc Accumulator) MarshalBinary() ([]byte, error)

MarshalBinary converts Accumulator to bytes

func (*Accumulator) New

func (acc *Accumulator) New(curve *curves.PairingCurve) (*Accumulator, error)

New creates a new accumulator.

func (*Accumulator) Remove

func (acc *Accumulator) Remove(key *SecretKey, e Element) (*Accumulator, error)

Remove removes a single element from accumulator if it exists V' = 1/(y+alpha) * V

func (*Accumulator) UnmarshalBinary

func (acc *Accumulator) UnmarshalBinary(data []byte) error

UnmarshalBinary sets Accumulator from bytes

func (*Accumulator) Update

func (acc *Accumulator) Update(key *SecretKey, additions []Element, deletions []Element) (*Accumulator, []Coefficient, error)

Update performs a batch addition and deletion as described on page 7, section 3 in https://eprint.iacr.org/2020/777.pdf

func (*Accumulator) WithElements

func (acc *Accumulator) WithElements(curve *curves.PairingCurve, key *SecretKey, m []Element) (*Accumulator, error)

WithElements initializes a new accumulator prefilled with entries Each member is assumed to be hashed V = prod(y + α) * V0, for all y∈ Y_V

type Coefficient

type Coefficient curves.Point

Coefficient is a point

type Delta

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

Delta contains values d and p, where d should be the division dA(y)/dD(y) on some value y p should be equal to 1/dD * <Gamma_y, Omega>

func (*Delta) MarshalBinary

func (d *Delta) MarshalBinary() ([]byte, error)

MarshalBinary converts Delta into bytes

func (*Delta) UnmarshalBinary

func (d *Delta) UnmarshalBinary(data []byte) error

UnmarshalBinary converts data into Delta

type Element

type Element curves.Scalar

type MembershipProof

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

MembershipProof contains values in the proof to be verified

func (*MembershipProof) Finalize

func (mp *MembershipProof) Finalize(acc *Accumulator, pp *ProofParams, pk *PublicKey, challenge curves.Scalar) (*MembershipProofFinal, error)

Finalize computes values in the proof to be verified.

func (MembershipProof) MarshalBinary

func (mp MembershipProof) MarshalBinary() ([]byte, error)

MarshalBinary converts MembershipProof to bytes

func (*MembershipProof) UnmarshalBinary

func (mp *MembershipProof) UnmarshalBinary(data []byte) error

UnmarshalBinary converts bytes to MembershipProof

type MembershipProofCommitting

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

MembershipProofCommitting contains value computed in Proof of knowledge and Blinding phases as described in section 7 of https://eprint.iacr.org/2020/777.pdf

func (*MembershipProofCommitting) GenProof

GenProof computes the s values for Fiat-Shamir and return the actual proof to be sent to the verifier given the challenge c.

func (MembershipProofCommitting) GetChallengeBytes

func (mpc MembershipProofCommitting) GetChallengeBytes() []byte

GetChallenge returns bytes that need to be hashed for generating challenge. V || Ec || T_sigma || T_rho || R_E || R_sigma || R_rho || R_delta_sigma || R_delta_rho

func (*MembershipProofCommitting) New

New initiates values of MembershipProofCommitting

type MembershipProofFinal

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

MembershipProofFinal contains values that are input to Fiat-Shamir Heuristic

func (MembershipProofFinal) GetChallenge

func (m MembershipProofFinal) GetChallenge(curve *curves.PairingCurve) curves.Scalar

GetChallenge computes Fiat-Shamir Heuristic taking input values of MembershipProofFinal

type MembershipWitness

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

MembershipWitness contains the witness c and the value y respect to the accumulator state.

func (*MembershipWitness) ApplyDelta

func (mw *MembershipWitness) ApplyDelta(delta *Delta) (*MembershipWitness, error)

ApplyDelta returns C' = dA(y)/dD(y)*C + 1/dD(y) * <Gamma_y, Omega> according to the witness update protocol described in section 4 of https://eprint.iacr.org/2020/777.pdf

func (*MembershipWitness) BatchUpdate

func (mw *MembershipWitness) BatchUpdate(additions []Element, deletions []Element, coefficients []Coefficient) (*MembershipWitness, error)

BatchUpdate performs batch update as described in section 4

func (MembershipWitness) MarshalBinary

func (mw MembershipWitness) MarshalBinary() ([]byte, error)

MarshalBinary converts a membership witness to bytes

func (*MembershipWitness) MultiBatchUpdate

func (mw *MembershipWitness) MultiBatchUpdate(A [][]Element, D [][]Element, C [][]Coefficient) (*MembershipWitness, error)

MultiBatchUpdate performs multi-batch update using epoch as described in section 4.2

func (*MembershipWitness) New

New creates a new membership witness

func (*MembershipWitness) UnmarshalBinary

func (mw *MembershipWitness) UnmarshalBinary(data []byte) error

UnmarshalBinary converts bytes into MembershipWitness

func (MembershipWitness) Verify

func (mw MembershipWitness) Verify(pk *PublicKey, acc *Accumulator) error

Verify the MembershipWitness mw is a valid witness as per section 4 in <https://eprint.iacr.org/2020/777>

type ProofParams

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

ProofParams contains four distinct public generators of G1 - X, Y, Z

func (*ProofParams) MarshalBinary

func (p *ProofParams) MarshalBinary() ([]byte, error)

MarshalBinary converts ProofParams to bytes

func (*ProofParams) New

func (p *ProofParams) New(curve *curves.PairingCurve, pk *PublicKey, entropy []byte) (*ProofParams, error)

New samples X, Y, Z, K

func (*ProofParams) UnmarshalBinary

func (p *ProofParams) UnmarshalBinary(data []byte) error

UnmarshalBinary converts bytes to ProofParams

type PublicKey

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

PublicKey is the public key of accumulator, it should be sk * generator of G2

func (PublicKey) MarshalBinary

func (pk PublicKey) MarshalBinary() ([]byte, error)

MarshalBinary converts PublicKey to bytes

func (*PublicKey) UnmarshalBinary

func (pk *PublicKey) UnmarshalBinary(data []byte) error

UnmarshalBinary sets PublicKey from bytes

type SecretKey

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

SecretKey is the secret alpha only held by the accumulator manager.

func (SecretKey) BatchAdditions

func (sk SecretKey) BatchAdditions(additions []Element) (Element, error)

BatchAdditions computes product(y + sk) for y in additions and output the product

func (SecretKey) BatchDeletions

func (sk SecretKey) BatchDeletions(deletions []Element) (Element, error)

BatchDeletions computes 1/product(y + sk) for y in deletions and output it

func (SecretKey) CreateCoefficients

func (sk SecretKey) CreateCoefficients(additions []Element, deletions []Element) ([]Element, error)

CreateCoefficients creates the Batch Polynomial coefficients See page 7 of https://eprint.iacr.org/2020/777.pdf

func (SecretKey) GetPublicKey

func (sk SecretKey) GetPublicKey(curve *curves.PairingCurve) (*PublicKey, error)

GetPublicKey creates a public key from SecretKey sk

func (SecretKey) MarshalBinary

func (sk SecretKey) MarshalBinary() ([]byte, error)

MarshalBinary converts SecretKey to bytes

func (*SecretKey) New

func (sk *SecretKey) New(curve *curves.PairingCurve, seed []byte) (*SecretKey, error)

New creates a new secret key from the seed.

func (*SecretKey) UnmarshalBinary

func (sk *SecretKey) UnmarshalBinary(data []byte) error

UnmarshalBinary sets SecretKey from bytes

Jump to

Keyboard shortcuts

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