Socket
Book a DemoInstallSign in
Socket

@iden3/contracts

Package Overview
Dependencies
Maintainers
4
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@iden3/contracts

Smart Contract library for Solidity

Source
npmnpm
Version
1.4.8
Version published
Weekly downloads
362
160.43%
Maintainers
4
Weekly downloads
 
Created
Source

State smart contract

The contract is aimed to be a part of a core protocol for self-sovereign identity system. Its purpose is to store the meta information about identities.

In particular, State contract stores the data of uint256 type for each identity, which is called "identity state" or state. The state represents a root of special cryptographic structure, which is out of scope of smart contract logic. But the only thing that smart contract should check is that the caller knows some private key, which public key is inside the structure. The overall check is hidden in the Zero-knowledge proof verifier smart contract attached to the State contract. The verifier contract was automatically generated by the Iden3 SnarkJS ZK library and was audited by the library creators.

Another data structure used by State is a Sparse Merkle Tree, which keeps the whole tree on chain as well as its full history. Each tree leaf consist of an index and a value. The indexes keep identity identifier and values keep states. The main purpose of the SMT is to provide inclusion and non-inclusion proofs of the states of identities into the SMT root. The tree processing logic is implemented by the Smt library contract linked to the state contract.

Take into account that the State contract and SMT library import Poseidon.sol contract, which is nothing more than a "placeholder" for auto generated EVM code. The code is responsible for the onchain Poseidon hash implementation. There is a helper method in the repo, which uses the circomlibjs Poseidon ABI and code generator.

Finally, the State contract is OwnableUpgradeable, which means that it works via the ERC1967 Proxy contract, that keeps all its state. Any further upgrades of the State contract should avoid any storage collisions.

Keywords

solidity

FAQs

Package last updated on 23 Feb 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts