Documentation
¶
Index ¶
- Variables
- func BigToHash(in *big.Int) (*chainhash.Hash, error)
- func BigToLittleBytes(in *big.Int) []byte
- func DenominationToAmount(d Denomination) int64
- func DeserializeBigNum(b []byte) (*big.Int, error)
- func GetChecksum(b *big.Int) uint32
- func HashToBig(hash *chainhash.Hash) *big.Int
- func SerializeBigNum(b *big.Int) []byte
- type Accumulator
- type AccumulatorAndProofParams
- type AccumulatorMap
- func (a *AccumulatorMap) Accumulate(p PublicCoin) error
- func (a *AccumulatorMap) GetCheckpoint() *big.Int
- func (a *AccumulatorMap) Read(d Denomination) *big.Int
- func (a *AccumulatorMap) Reset() error
- func (a *AccumulatorMap) SetValue(d Denomination, i *big.Int)
- func (a *AccumulatorMap) SetZerocoinParams(params *Params)
- type AccumulatorWitness
- type Denomination
- type IntegerGroupParams
- type Params
- type PublicCoin
Constants ¶
This section is empty.
Variables ¶
var ZerocoinDenominations = [...]Denomination{ DenomOne, DenomFive, DenomTen, DenomFifty, DenomOneHundred, DenomFiveHundred, DenomOneThousand, DenomFiveThousand, }
ZerocoinDenominations are the valid denominations of Zerocoin
Functions ¶
func BigToLittleBytes ¶
BigToLittleBytes converts a big int to a little endian bytes
func DenominationToAmount ¶
func DenominationToAmount(d Denomination) int64
DenominationToAmount gets the denomination of an amount
func DeserializeBigNum ¶
DeserializeBigNum deserializes a big integer similar to OpenSSL with a big endian 32-bit length followed by a big endian representation of the number.
func GetChecksum ¶
GetChecksum calculates the checksum of a zerocoin accumulator value.
func HashToBig ¶
HashToBig converts a chainhash.Hash into a big.Int that can be used to perform math comparisons.
func SerializeBigNum ¶
SerializeBigNum serializes a big integer like openssl would
Types ¶
type Accumulator ¶
type Accumulator struct {
// contains filtered or unexported fields
}
Accumulator represents an RSA-based accumulator.
func NewAccumulator ¶
func NewAccumulator(params *AccumulatorAndProofParams, d Denomination) (*Accumulator, error)
NewAccumulator initializes a new empty accumulator with given parameters and denomination.
func NewAccumulatorWithValue ¶
func NewAccumulatorWithValue(params *AccumulatorAndProofParams, d Denomination, value *big.Int) (*Accumulator, error)
NewAccumulatorWithValue initializes an accumulator with given zerocoin params, denomination, and with a preset value.
func (Accumulator) Accumulate ¶
func (a Accumulator) Accumulate(coin *PublicCoin) error
Accumulate a given coin if it is valid and the denomination matches.
func (Accumulator) Increment ¶
func (a Accumulator) Increment(value *big.Int)
Increment adds a value to the accumulator
type AccumulatorAndProofParams ¶
type AccumulatorAndProofParams struct {
Initialized bool
AccumulatorModulus *big.Int
AccumulatorBase *big.Int
MinCoinValue *big.Int
MaxCoinValue *big.Int
AccumulatorPoKCommitmentGroup *IntegerGroupParams
AccumulatorQRNCommitmentGroup *IntegerGroupParams
// KPrime is the bit length of the challenges used in the accumulator
// proof-of-knowledge.
KPrime uint32
// KDPrime is the statistical zero-knowledgeness of the accumulator
// proof.
KDPrime uint32
}
AccumulatorAndProofParams are the parameters used for Zerocoin on the network.
func NewAccumulatorAndProofParams ¶
func NewAccumulatorAndProofParams() *AccumulatorAndProofParams
NewAccumulatorAndProofParams returns a new uninitialized version of accumulator and proof parameters.
type AccumulatorMap ¶
type AccumulatorMap struct {
// contains filtered or unexported fields
}
AccumulatorMap each denomination of accumulator.
func NewAccumulatorMap ¶
func NewAccumulatorMap(params *Params) (*AccumulatorMap, error)
NewAccumulatorMap creates a new map of
func (*AccumulatorMap) Accumulate ¶
func (a *AccumulatorMap) Accumulate(p PublicCoin) error
Accumulate adds a zerocoin to the accumulator of its denomination
func (*AccumulatorMap) GetCheckpoint ¶
func (a *AccumulatorMap) GetCheckpoint() *big.Int
GetCheckpoint gets the checksum of all of the accumulators contained in the map.
func (*AccumulatorMap) Read ¶
func (a *AccumulatorMap) Read(d Denomination) *big.Int
Read reads the accumulator value for a certain denomination
func (*AccumulatorMap) Reset ¶
func (a *AccumulatorMap) Reset() error
Reset resets the accumulators to their default values.
func (*AccumulatorMap) SetValue ¶
func (a *AccumulatorMap) SetValue(d Denomination, i *big.Int)
SetValue sets the value of one of the accumulators
func (*AccumulatorMap) SetZerocoinParams ¶
func (a *AccumulatorMap) SetZerocoinParams(params *Params)
SetZerocoinParams sets new parameters and resets the accumulator
type AccumulatorWitness ¶
type AccumulatorWitness struct {
// contains filtered or unexported fields
}
AccumulatorWitness is a witness that a public coin is in the accumulation of a set of coins.
func (AccumulatorWitness) AddElement ¶
func (a AccumulatorWitness) AddElement(coin PublicCoin)
AddElement adds a public coin to the accumulator.
func (AccumulatorWitness) ResetValue ¶
func (a AccumulatorWitness) ResetValue(checkpoint *Accumulator, coin PublicCoin)
ResetValue resets the value of the accumulator witness to a given checkpoint and public coin.
func (AccumulatorWitness) VerifyWitness ¶
func (a AccumulatorWitness) VerifyWitness(acc *Accumulator, p *PublicCoin) (bool, error)
VerifyWitness verifies that a witness matches the accumulator.
type Denomination ¶
type Denomination int64
Denomination represents a Zerocoin denomination
const ( // DenomError is the default error zerocoin denomination DenomError Denomination = 0 // DenomOne represents a zerocoin with denomination 1 DenomOne Denomination = 1 // DenomFive represents a zerocoin with denomination 5 DenomFive Denomination = 5 // DenomTen represents a zerocoin with denomination 10 DenomTen Denomination = 10 // DenomFifty represents a zerocoin with denomination 50 DenomFifty Denomination = 50 // DenomOneHundred represents a zerocoin with denomination 100 DenomOneHundred Denomination = 100 // DenomFiveHundred represents a zerocoin with denomination 500 DenomFiveHundred Denomination = 500 // DenomOneThousand represents a zerocoin with denomination 1000 DenomOneThousand Denomination = 1000 // DenomFiveThousand represents a zerocoin with denomination 5000 DenomFiveThousand Denomination = 5000 )
func AmountToZerocoinDenomination ¶
func AmountToZerocoinDenomination(amount int64) Denomination
AmountToZerocoinDenomination converts an amount to a zerocoin denomination
type IntegerGroupParams ¶
type IntegerGroupParams struct {
// G is the generator for the group
G *big.Int
// H is another generator for the group
H *big.Int
Modulus *big.Int
GroupOrder *big.Int
Initialized bool
}
IntegerGroupParams is a cryptographic integer group. Note log_G(H) and log_H(G) must be unknown.
func NewIntegerGroupParams ¶
func NewIntegerGroupParams() *IntegerGroupParams
NewIntegerGroupParams returns a new uninitialized version of integer group params.
type Params ¶
type Params struct {
Initialized bool
AccumulatorParams *AccumulatorAndProofParams
// CoinCommitmentGroup is the quadratic residue group from which
// we form a coin as a commitment to a serial number.
CoinCommitmentGroup *IntegerGroupParams
// One of two groups used to form a commitment to a coin. This
// is used in the serial number proof. The order must equal the
// modulus of CoinCommitmentGroup.
SerialNumberSoKCommitmentGroup *IntegerGroupParams
// Number of iterations used in the serial number proof.
ZKPIterations uint32
// Amount of the hash function we use for proofs.
ZKPHashLength uint32
}
Params are parameters for Zerocoin with a trusted modulus N.
type PublicCoin ¶
type PublicCoin struct {
// contains filtered or unexported fields
}
PublicCoin is the part of the coin that is published to the network and contains the value of the commitment to a serial number and the denomination of the coin.
func NewPublicCoin ¶
func NewPublicCoin(p *Params) (*PublicCoin, error)
NewPublicCoin initializes a new public coin without a denomination.
func NewPublicCoinFromValue ¶
func NewPublicCoinFromValue(p *Params, coin *big.Int, d Denomination) (*PublicCoin, error)
NewPublicCoinFromValue initializes a new public coin from an existing value and denomination.
func (*PublicCoin) Denomination ¶
func (p *PublicCoin) Denomination() Denomination
Denomination gets the denomination of the pubcoin
func (PublicCoin) Equal ¶
func (p PublicCoin) Equal(pub2 PublicCoin) bool
Equal returns two if the two public coins are equal.
func (*PublicCoin) Params ¶
func (p *PublicCoin) Params() *Params
Params gets the parameters used by the pubcoin
func (PublicCoin) Validate ¶
func (p PublicCoin) Validate() bool
Validate checks the validity of a public coin.
func (*PublicCoin) Value ¶
func (p *PublicCoin) Value() *big.Int
Value gets the value of the pubcoin