Documentation ¶
Index ¶
- Variables
- func Create(cfg Config, kOpComp *babyjub.PublicKeyComp, ...) (*core.ID, error)
- type Config
- type IdOwnershipGenesisInputs
- type IdenStateTreeRoots
- type IdenStateZkProofConf
- type Issuer
- func (is *Issuer) GenCredentialExistence(claim merkletree.Entrier) (*proof.CredentialExistence, error)
- func (is *Issuer) GenIdOwnershipGenesisInputs(levels int) (*IdOwnershipGenesisInputs, error)
- func (is *Issuer) GenZkProofIdenStateUpdate(oldIdState, newIdState *merkletree.Hash) (*zkutils.ZkProofOut, error)
- func (is *Issuer) ID() *core.ID
- func (is *Issuer) IdenStateOnChain() *merkletree.Hash
- func (is *Issuer) IdenStatePending() (*merkletree.Hash, bool)
- func (is *Issuer) IssueClaim(claim claims.Claimer) error
- func (is *Issuer) KeyOperational() *babyjub.PublicKeyComp
- func (is *Issuer) PublishState() error
- func (is *Issuer) RevokeClaim(claim merkletree.Entrier) error
- func (is *Issuer) Sign(string) (string, error)
- func (is *Issuer) SignBinary(prefix, msg []byte) (*babyjub.SignatureComp, error)
- func (is *Issuer) SignElems(toHash [poseidon.T]*big.Int) (*babyjub.SignatureComp, error)
- func (is *Issuer) SignState(oldState, newState *merkletree.Hash) (*babyjub.SignatureComp, error)
- func (is *Issuer) State() (*merkletree.Hash, IdenStateTreeRoots)
- func (is *Issuer) StateDataOnChain() *proof.IdenStateData
- func (is *Issuer) SyncIdenStatePublic() error
- func (is *Issuer) UpdateClaim(hIndex *merkletree.Hash, value []merkletree.ElemBytes) error
- type UniqueNonceGen
Constants ¶
This section is empty.
Variables ¶
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") )
var ConfigDefault = Config{MaxLevelsClaimsTree: 140, MaxLevelsRevocationTree: 140, MaxLevelsRootsTree: 140, GenesisOnly: false, ConfirmBlocks: 3}
ConfigDefault is a default configuration for the Issuer.
var (
SigPrefixSetState = []byte("setstate:")
)
Functions ¶
Types ¶
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 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
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) IdenStateOnChain ¶
func (is *Issuer) IdenStateOnChain() *merkletree.Hash
func (*Issuer) IdenStatePending ¶
func (is *Issuer) IdenStatePending() (*merkletree.Hash, bool)
func (*Issuer) IssueClaim ¶
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 ¶
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) 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 ¶
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 ¶
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.