Version: v0.0.8 Latest Latest

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

Go to latest
Published: Jun 3, 2020 License: GPL-3.0 Imports: 19 Imported by: 1




View Source
const (
	ErrStrTooManySiblings = "number of mtp siblings in %v (%v) is higher than requested levels (%v)"


View Source
var (
	ErrRevokedClaim                   = fmt.Errorf("revocation nonce exists in the Revocation Tree.  The claim is revoked.")
	ErrRootNotFound                   = fmt.Errorf("claims tree root not found in roots tree.")
	ErrFailedVerifyZkProofCredential  = fmt.Errorf("failed verifing generated zk proof of credential")
	ErrCalculatedIdenStateDoesntMatch = fmt.Errorf("Calculated IdenState from public data doesn't match the one queried")
View Source
var ConfigDefault = Config{Config: issuer.ConfigDefault}


func Create

func Create(cfg Config, kOpComp *babyjub.PublicKeyComp, extraGenesisClaims []claims.Claimer,
	storage db.Storage, keyStore *keystore.KeyStore) (*core.ID, error)

Create a new Holder, calling the internal Issuer.New().


type Config

type Config struct {

type CredentialProofInputs added in v0.0.8

type CredentialProofInputs struct {
	// A
	Claim []*big.Int `mapstructure:"claim"`

	// B. holder proof of claimKOp in the genesis
	PrivateKey             *big.Int   `mapstructure:"hoKOpSk"`
	ClaimKOpMtp            []*big.Int `mapstructure:"hoClaimKOpMtp"`
	ClaimKOpClaimsTreeRoot *big.Int   `mapstructure:"hoClaimKOpClaimsTreeRoot"`

	// C. issuer proof of claim existence
	CredExistMtp            []*big.Int `mapstructure:"isProofExistMtp"`
	CredExistClaimsTreeRoot *big.Int   `mapstructure:"isProofExistClaimsTreeRoot"`

	// D. issuer proof of claim validity
	CredValidNotRevMtp      []*big.Int `mapstructure:"isProofValidNotRevMtp"`
	CredValidNotRevMtpNoAux *big.Int   `mapstructure:"isProofValidNotRevMtpNoAux"`
	CredValidNotRevMtpAuxHi *big.Int   `mapstructure:"isProofValidNotRevMtpAuxHi"`
	CredValidNotRevMtpAuxHv *big.Int   `mapstructure:"isProofValidNotRevMtpAuxHv"`
	CredValidClaimsTreeRoot *big.Int   `mapstructure:"isProofValidClaimsTreeRoot"`
	CredValidRevTreeRoot    *big.Int   `mapstructure:"isProofValidRevTreeRoot"`
	CredValidRootsTreeRoot  *big.Int   `mapstructure:"isProofValidRootsTreeRoot"`

	// E. issuer proof of Root (ExistClaimsTreeRoot)
	CredValidRootMtp []*big.Int `mapstructure:"isProofRootMtp"`

	// F. issuer recent idenState
	IdenState *big.Int `mapstructure:"isIdenState"`

CredentialProofInputs are all the iinputs for the credential ownership proof `credential.circom`.

type CredentialValidityAux added in v0.0.8

type CredentialValidityAux struct {
	IdenStateData  *proof.IdenStateData
	MtpNotNonce    *merkletree.Proof
	ClaimsTreeRoot *merkletree.Hash
	RevTreeRoot    *merkletree.Hash
	RootsTreeRoot  *merkletree.Hash
	PublicData     *idenpuboffchain.PublicData

CredentialValidityAux contains the data used in a validity proof.

type Holder

type Holder struct {
	// contains filtered or unexported fields

Holder is an identity that holds claims. It is an extension of an Issuer.

func Load

func Load(storage db.Storage, keyStore *keystore.KeyStore,
	idenPubOnChain idenpubonchain.IdenPubOnChainer,
	idenStateZkProofConf *issuer.IdenStateZkProofConf,
	idenPubOffChainWriter idenpuboffchain.IdenPubOffChainWriter,
	idenPubOffChainReader idenpuboffchain.IdenPubOffChainReader) (*Holder, error)

New creates a Holder by loading a previously created Holder (with New, and calling the internal Issuer.Load().

func (*Holder) HolderGenZkProofCredential added in v0.0.8

func (h *Holder) HolderGenZkProofCredential(
	credExist *proof.CredentialExistence,
	addInputs func(inputs map[string]interface{}) error,
	idOwnershipLevels, issuerLevels int,
	zkFiles *zkutils.ZkFiles) (*ZkProofCredOut, error)

HolderGenZkProofCredential generates a zkp of a credential. This function prepares all the inputs of the `credential.circom` circuit and removes the "claim" input. The `addInputs` function allows adding circuit inputs as necessary (for example, inputs used to build the claim).

func (*Holder) HolderGetCredentialProofInputs added in v0.0.8

func (h *Holder) HolderGetCredentialProofInputs(
	idOwnershipGenesisInputs *issuer.IdOwnershipGenesisInputs,
	credExist *proof.CredentialExistence,
	credValidData *CredentialValidityAux,
	issuerLevels int) (*CredentialProofInputs, error)

HolderGetCredentialProofInputs generates the inputs for the credential ownership proof `credential.circom`.

func (*Holder) HolderGetCredentialValidity

func (h *Holder) HolderGetCredentialValidity(
	credExist *proof.CredentialExistence) (*proof.CredentialValidity, error)

HolderGetCredentialValidity gets a Credential of Validity from a Credential of Existence. This requires a request to the Issuer IdenStatePubOffChain.

func (*Holder) HolderGetCredentialValidityData added in v0.0.8

func (h *Holder) HolderGetCredentialValidityData(
	credExist *proof.CredentialExistence) (*CredentialValidityAux, error)

HolderGetCredentialValidityData is a helper function to get the data used in a validity proof from a credential existence proof.

type ZkProofCredOut added in v0.0.8

type ZkProofCredOut struct {
	ZkProofOut      zkutils.ZkProofOut
	IssuerID        *core.ID
	IdenStateBlockN uint64

ZkProofCredOut is the data output of a generated credential zkp, and contains the inputs required for verification of a credential zkp.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL