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: 24 Imported by: 3




This section is empty.


View Source
var (
	ErrIdenGenesisOnly                    = fmt.Errorf("identity is genesis only")
	ErrIdenPubOnChainNil                  = fmt.Errorf("idenPubOnChain is nil")
	ErrIdenStateSNARKPathsNil             = fmt.Errorf("idenStateZkProofConf is nil")
	ErrEthClientNil                       = fmt.Errorf("ethClient is nil")
	ErrIdenPubOffChainWriterNil           = fmt.Errorf("idenPubOffChainWriter is nil")
	ErrIdenStatePendingNotNil             = fmt.Errorf("update of the published IdenState is pending")
	ErrIdenStateOnChainZero               = fmt.Errorf("no IdenState known to be on chain")
	ErrClaimNotFoundStateOnChain          = fmt.Errorf("claim not found under the on chain identity state")
	ErrClaimNotFoundClaimsTree            = fmt.Errorf("claim not found in the claims tree: the claim hasn't been issued")
	ErrClaimNotYetInOnChainState          = fmt.Errorf("claim has been issued but is not yet under a published on chain identity state")
	ErrFailedVerifyZkProofIdenStateUpdate = fmt.Errorf("failed verifing generated zk proof of identity state update")
View Source
var ConfigDefault = Config{MaxLevelsClaimsTree: 140, MaxLevelsRevocationTree: 140, MaxLevelsRootsTree: 140, GenesisOnly: false, ConfirmBlocks: 3}

ConfigDefault is a default configuration for the Issuer.

View Source
var (
	SigPrefixSetState = []byte("setstate:")


func Create

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

Create a new Issuer, creating a new genesis ID and initializes the storages. The extraGenesisClaims metadata's are updated.


type Config

type Config struct {
	MaxLevelsClaimsTree     int
	MaxLevelsRevocationTree int
	MaxLevelsRootsTree      int
	GenesisOnly             bool
	ConfirmBlocks           uint64

Config allows configuring the creation of an Issuer.

type IdOwnershipGenesisInputs added in v0.0.8

type IdOwnershipGenesisInputs struct {
	Id             *big.Int
	PrivateKey     *big.Int
	MtpSiblings    []*big.Int
	ClaimsTreeRoot *big.Int

type IdenStateTreeRoots

type IdenStateTreeRoots struct {
	ClaimsTreeRoot      *merkletree.Hash
	RevocationsTreeRoot *merkletree.Hash
	RootsTreeRoot       *merkletree.Hash

IdenStateTreeRoots is the set of the three roots of each Identity Merkle Tree.

type IdenStateZkProofConf added in v0.0.8

type IdenStateZkProofConf struct {
	Levels int
	Files  zkutils.ZkFiles

IdenStateZkProofConf are the paths to the SNARK related files required to generate an identity state update zkSNARK proof.

type Issuer

type Issuer struct {
	// contains filtered or unexported fields

Issuer is an identity that issues claims

func Load

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

Load creates an Issuer by loading a previously created Issuer (with New).

func (*Issuer) GenCredentialExistence

func (is *Issuer) GenCredentialExistence(claim merkletree.Entrier) (*proof.CredentialExistence, error)

GenCredentialExistence generates an existence credential (claim + proof of existence) of an issued claim. The result contains all data necessary to validate the credential against the Identity State found in the blockchain. For now, there are no genesis credentials.

func (*Issuer) GenIdOwnershipGenesisInputs added in v0.0.8

func (is *Issuer) GenIdOwnershipGenesisInputs(levels int) (*IdOwnershipGenesisInputs, error)

func (*Issuer) GenZkProofIdenStateUpdate added in v0.0.8

func (is *Issuer) GenZkProofIdenStateUpdate(oldIdState, newIdState *merkletree.Hash) (*zkutils.ZkProofOut, error)

func (*Issuer) ID

func (is *Issuer) ID() *core.ID

ID returns the Issuer ID (Identity ID).

func (*Issuer) IdenStateOnChain

func (is *Issuer) IdenStateOnChain() *merkletree.Hash

func (*Issuer) IdenStatePending

func (is *Issuer) IdenStatePending() (*merkletree.Hash, bool)

func (*Issuer) IssueClaim

func (is *Issuer) IssueClaim(claim claims.Claimer) error

IssueClaim adds a new claim to the Claims Merkle Tree of the Issuer. The Identity State is not updated. The claim metadata is updated if the issue is successfull.

func (*Issuer) KeyOperational

func (is *Issuer) KeyOperational() *babyjub.PublicKeyComp

KeyOperational returns the identity's operational key.

func (*Issuer) PublishState

func (is *Issuer) PublishState() error

PublishState calculates the current Issuer identity state, and if it's different than the last one, it publishes in in the blockchain.

func (*Issuer) RevokeClaim

func (is *Issuer) RevokeClaim(claim merkletree.Entrier) error

RevokeClaim revokes an already issued claim.

func (*Issuer) Sign

func (is *Issuer) Sign(string) (string, error)

Sign signs a message by the kOp of the issuer.

func (*Issuer) SignBinary

func (is *Issuer) SignBinary(prefix, msg []byte) (*babyjub.SignatureComp, error)

SignBinary signs a binary message by the kOp of the issuer.

func (*Issuer) SignElems

func (is *Issuer) SignElems(toHash [poseidon.T]*big.Int) (*babyjub.SignatureComp, error)

SignElems signs a [poseidon.T]*big.Int of elements in *big.Int format

func (*Issuer) SignState

func (is *Issuer) SignState(oldState, newState *merkletree.Hash) (*babyjub.SignatureComp, error)

SignState signs the Identity State transition (oldState+newState) by the kOp of the issuer.

func (*Issuer) State

func (is *Issuer) State() (*merkletree.Hash, IdenStateTreeRoots)

State calculates and returns the current Identity State and the three merkle tree roots.

func (*Issuer) StateDataOnChain

func (is *Issuer) StateDataOnChain() *proof.IdenStateData

StateDataOnChain returns the last known IdentityState Data known to be on chain.

func (*Issuer) SyncIdenStatePublic

func (is *Issuer) SyncIdenStatePublic() error

SyncIdenStatePublic updates the IdenStateOnChain and IdenStatePending from the values in the Smart Contract.

func (*Issuer) UpdateClaim

func (is *Issuer) UpdateClaim(hIndex *merkletree.Hash, value []merkletree.ElemBytes) error

UpdateClaim allows updating the value of an already issued claim.

type UniqueNonceGen

type UniqueNonceGen struct {
	// contains filtered or unexported fields

UniqueNonceGen is a generator of unique nonces with persistent state.

func NewUniqueNonceGen

func NewUniqueNonceGen(index *db.StorageValue) *UniqueNonceGen

NewUniqueNonceGen creates a new unique nonce generator, storing the persistent state in the index.

func (*UniqueNonceGen) Init

func (u *UniqueNonceGen) Init(tx db.Tx)

Init is required to initialize the unique nonce generator.

func (*UniqueNonceGen) Next

func (u *UniqueNonceGen) Next(tx db.Tx) (uint32, error)

Next returns a new unique nonce.

Jump to

Keyboard shortcuts

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