
Security News
PolinRider: North Korea-Linked Supply Chain Campaign Expands Across Open Source Ecosystems
PolinRider expands across npm, Packagist, Go modules, and Chrome extensions, using hidden loaders to target developer environments.
@zidendev/zidenjs
Advanced tools
Core library for interacting with Ziden protocol, supports all functions for holders, issuers and verifiers
Core library for interacting with Ziden protocol, supports all functions for holders, issuers and verifiers
npm i
npm run test-all
npm run gen-doc
npm run build
Some functions of the library require cryptograhic operators that require time to setup. To optimize your application, you should call the setup function for them first as precomputation.
import { params } from '@zidendev/zidenjs';
await params.setupParams();
The keys created can be later used to construct your identity
In the following example, the private key is created randomly, you may want to utilize some key generation techniques to make it more secure and easier to manage.
import { auth } from '@zidendev/zidenjs';
import { randomBytes } from 'crypto';
const privateKey = randomBytes(32);
const auth = await auth.newAuthFromPrivateKey(privateKey);
import { auth, db, state } from '@zidendev/zidenjs';
import { randomBytes } from 'crypto';
const privateKey = randomBytes(32);
const auth = await auth.newAuthFromPrivateKey(privateKey);
// setup level DB to store trees
const authDb = smt.SMTLevelDb('/path/to/your/authDb');
const claimDb = smt.SMTLevelDb('/path/to/your/claimDb');
const claimRevDb = smt.SMTLevelDb('/path/to/your/claimRevDb');
const identity = await state.State.generateState([auth], authDb, claimDb, claimRevDb);
import { claim } from '@zidendev/zidenjs';
const { newClaim, schemaHashFromBigInt, withIndexData, withExpirationDate } = claim;
const claim = newClaim(
schemaHashFromBigInt(BigInt('123456')),
withIndexData(Buffer.alloc(30, 5), Buffer.alloc(30, 6)),
withExpirationDate(BigInt(Date.now() + 100000))
);
The witness returned from the stateTransition function will be passed as input into the stateTransion circuit
State Transition relates to inserting new Auths, Claims or revoking invalid Auths, Claims
import { stateTransition } from '@zidendev/zidenjs';
const witness = await stateTransition.stateTransitionWitnessWithPrivateKey(
priv1,
auth,
state,
[insertedAuth],
[insertedClaim],
[revokedAuth1.authHi, revokedAuth2.authHi],
[revokedClaim.getRevocationNonce()]
);
Holding a certain claim with some qualities, the holder can demonstrate these qualities by using functions provide by queryMTP module
import { queryMTP, claim, auth } from '@zidendev/zidenjs';
const { newClaim, schemaHashFromBigInt, withSlotData, withIndexID } = claim;
const holderPrivateKey = // mock here
const holderAuth = await auth.newAuthFromPrivateKey(holderPrivateKey);
const query1 = {
slotIndex: 2,
operator: OPERATOR.LESS_THAN,
values: [BigInt(20040101)],
valueTreeDepth: 6,
from: 10,
to: 100,
timestamp: Date.now(),
claimSchema: BigInt(12394),
};
const slot1 = setBits(BigInt(0), query1.from, BigInt(20010101));
const claim1 = newClaim(
schemaHashFromBigInt(query1.claimSchema),
withSlotData(query1.slotIndex, numToBits(slot1, 32)),
withIndexID(holderState.userID)
);
// issuer side: grant kycGenerateQueryMTPInput for holder once issued
const kycQueryMTPInput = await kycGenerateQueryMTPInput(claim1.hiRaw(), issuerState);
// issuer side: grant kycGenerateNonRevQueryMTPInput for holder when asked
const kycNonRevQueryMTPInput = await kycGenerateNonRevQueryMTPInput(claim1.getRevocationNonce(), issuerState);
// holder side: generate queryMTP proof on their claim
const witness = await holderGenerateQueryMTPWitnessWithPrivateKey(
claim1,
holderPrivateKey,
holderAuth,
BigInt(1),
holderState,
kycQueryMTPInput,
kycNonRevQueryMTPInput,
query1
);
For more detailed codes, please refer to test files in the library
FAQs
Core library for interacting with Ziden protocol, supports all functions for holders, issuers and verifiers
The npm package @zidendev/zidenjs receives a total of 20 weekly downloads. As such, @zidendev/zidenjs popularity was classified as not popular.
We found that @zidendev/zidenjs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?

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.

Security News
PolinRider expands across npm, Packagist, Go modules, and Chrome extensions, using hidden loaders to target developer environments.

Security News
Open source attacks are accelerating as AI coding agents pull in dependencies faster, with less human review.

Research
/Security News
Malicious Chrome and Firefox extensions posed as free VPNs while stealing clipboard data through later extension updates.