Integration
This section will guide you through integrating Albus into your workflow. The on-chain part is implemented in Rust, while the off-chain part is built with TypeScript.
On-Chain Component (Rust)
Installation
Add this code to install the albus-verifier crate.
[dependencies]
albus-solana-verifier = "0.1.2"Usage
Verify user compliance on-chain
This method verifies on-chain that a proof request (Certificate) is not expired and contains a valid ZK Proof. If both conditions are met, Albus proceeds to execute the code. If it's not, Albus returns an error.
Example
use albus_solana_verifier::AlbusCompliant;
AlbusCompliant::new(&ctx.accounts.proof_request)
// (Optional) checks association with a user
.with_user(ctx.accounts.sender.key("<USER_ADDRESS>"))
// (Optional) checks association with a policy
.with_policy(ctx.accounts.policy.key("<POLICY_ADDRESS>"))
.check()?;Retrieve a proof request's address
This method retrieves an address of a proof request (Certificate).
It's a non-unique address of an account created on-chain when a user requests a Certificate on the frontend of the Albus application. It's associated with a specific user, policy, and service provider. It can be found by addresses of the user and the policy it is associated with.
Example
Retrieve a policy's address
This method retrieves an address of a policy by its code stored in our database.
Example
Retrieve a service provider's address
This method retrieves an address of a service provider by its unique code stored in our database.
Example
Off-Chain Component (TypeScript)
Installation
Install the @albus/sdk package (yarn and npm package managers can also be used).
Install via CLI
Install via package.json
Initialization
Initialize the Albus client (in a browser)
Initialize the Albus client (on a validator node)
Methods Available to Web3 Businesses
Retrieve all service providers
This method retrieves a list of all service providers.
Retrieve a service provider by its address
This method retrieves a specific service provider by its address.
Retrieve all proof requests
This method retrieves a list of all proof requests (Certificates).
Retrieve all policies
This method retrieves a list of all policies.
Internal methods of Albus Protocol
Create a proof request
This method creates a proof request (Certificate) on-chain based on codes of a service provider and a policy. The codes can be added from a config file or retrieved with the find method.
Example
Generate a ZK Proof for a proof request
This method generates a Zero-Knowledge Proof for a specific proof request (Certificate). Once the ZK Proof is generated and verified, the user is issued the Certificate on the frontend.
Props
Data passed to the fullProve method:
proofRequest: address of the proof request for which the ZK Proof is to be generated.vc: address of the credential to be used to generate the ZK Proof.userPrivateKey: key generated from a seed phrase and used to encrypt and decrypt credentials of a user.
Example
Delete a proof request
This method deletes a proof request (Certificate).
Example
Retrieve all credentials
This method retrieves a list of all credentials.
Example
Revoke a credential
This method revokes a credential issued for a user. Credential NFTs can only be deleted using the revoke method.
Example
Update a service provider
This method updates a service provider.
Props
Data passed to the update method:
name: service provider's name.website: service provider's website.secretShareThreshold: the number of shares into which a decryption key is split under a secret sharing scheme (for details, see the Glossary).contactInfo:kind: contact type:0: Telegram1: email2: Discord
value: contact info.
serviceProvider: service provider's address.newAuthority: address of a new authority.trustees: addresses of Trustees.
Example
Retrieve all Trustees
This method retrieves a list of all Trustees.
Add a Trustee(s) for a service provider
This method associates a Trustee(s) with a specific service provider.
Props
Data passed to the update method:
serviceProvider: service provider's address.trustees: addresses of Trustees.
Example
Retrieve all circuits
This method retrieves a list of all circuits.
Create a policy
Props
Data passed to the create method:
circuitCode: code of the circut used.code: any arbitrary name.description: service provider description (max. 64 characters).name: service provider's name (max. 30 characters).expirationPeriod: period in seconds after which the Certificate expires and is no longer valid.retentionPeriod: time in seconds during which user data passed for generating a ZK Proof is retained for regulatory purposes.serviceCode: service provider's code.rules: specific requirements included in a policy.
Example
Update policy
This method updates a policy.
Delete policy
This method deletes a policy.
Example
Last updated