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 ¶
- type Accumulator
- func (acc *Accumulator) Add(key *SecretKey, e Element) (*Accumulator, error)
- func (acc *Accumulator) AddElements(key *SecretKey, m []Element) (*Accumulator, error)
- func (acc Accumulator) MarshalBinary() ([]byte, error)
- func (acc *Accumulator) New(curve *curves.PairingCurve) (*Accumulator, error)
- func (acc *Accumulator) Remove(key *SecretKey, e Element) (*Accumulator, error)
- func (acc *Accumulator) UnmarshalBinary(data []byte) error
- func (acc *Accumulator) Update(key *SecretKey, additions []Element, deletions []Element) (*Accumulator, []Coefficient, error)
- func (acc *Accumulator) WithElements(curve *curves.PairingCurve, key *SecretKey, m []Element) (*Accumulator, error)
- type Coefficient
- type Delta
- type Element
- type MembershipProof
- type MembershipProofCommitting
- func (mpc *MembershipProofCommitting) GenProof(c curves.Scalar) *MembershipProof
- func (mpc MembershipProofCommitting) GetChallengeBytes() []byte
- func (mpc *MembershipProofCommitting) New(witness *MembershipWitness, acc *Accumulator, pp *ProofParams, pk *PublicKey) (*MembershipProofCommitting, error)
- type MembershipProofFinal
- type MembershipWitness
- func (mw *MembershipWitness) ApplyDelta(delta *Delta) (*MembershipWitness, error)
- func (mw *MembershipWitness) BatchUpdate(additions []Element, deletions []Element, coefficients []Coefficient) (*MembershipWitness, error)
- func (mw MembershipWitness) MarshalBinary() ([]byte, error)
- func (mw *MembershipWitness) MultiBatchUpdate(A [][]Element, D [][]Element, C [][]Coefficient) (*MembershipWitness, error)
- func (mw *MembershipWitness) New(y Element, acc *Accumulator, sk *SecretKey) (*MembershipWitness, error)
- func (mw *MembershipWitness) UnmarshalBinary(data []byte) error
- func (mw MembershipWitness) Verify(pk *PublicKey, acc *Accumulator) error
- type ProofParams
- type PublicKey
- type SecretKey
- func (sk SecretKey) BatchAdditions(additions []Element) (Element, error)
- func (sk SecretKey) BatchDeletions(deletions []Element) (Element, error)
- func (sk SecretKey) CreateCoefficients(additions []Element, deletions []Element) ([]Element, error)
- func (sk SecretKey) GetPublicKey(curve *curves.PairingCurve) (*PublicKey, error)
- func (sk SecretKey) MarshalBinary() ([]byte, error)
- func (sk *SecretKey) New(curve *curves.PairingCurve, seed []byte) (*SecretKey, error)
- func (sk *SecretKey) UnmarshalBinary(data []byte) error
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 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 ¶
MarshalBinary converts Delta into bytes
func (*Delta) UnmarshalBinary ¶
UnmarshalBinary converts data into Delta
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 ¶
func (mpc *MembershipProofCommitting) GenProof(c curves.Scalar) *MembershipProof
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 ¶
func (mpc *MembershipProofCommitting) New( witness *MembershipWitness, acc *Accumulator, pp *ProofParams, pk *PublicKey, ) (*MembershipProofCommitting, error)
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 ¶
func (mw *MembershipWitness) New(y Element, acc *Accumulator, sk *SecretKey) (*MembershipWitness, error)
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 ¶
MarshalBinary converts PublicKey to bytes
func (*PublicKey) UnmarshalBinary ¶
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 ¶
BatchAdditions computes product(y + sk) for y in additions and output the product
func (SecretKey) BatchDeletions ¶
BatchDeletions computes 1/product(y + sk) for y in deletions and output it
func (SecretKey) CreateCoefficients ¶
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 ¶
MarshalBinary converts SecretKey to bytes
func (*SecretKey) UnmarshalBinary ¶
UnmarshalBinary sets SecretKey from bytes