> For the complete documentation index, see [llms.txt](https://docs.zkid.digital/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.zkid.digital/zk-identity-on-solana/tech-layer-for-the-zk-identity-stack.md).

# Tech Layer for the ZK Identity Stack

Decentralized identity on Solana integrates four key operations:

1. **DID Mapping & Resolution**
2. **VC Issuance & Verification**
3. **ZK Proof Verification**
4. **Decentralized Storage Integration**

***

### 1. DID Integration with Solana

Solana acts as the programmable identity layer.

Bitcoin anchors → Solana resolves.

#### DID Mapping Example (Solana/Anchor Pseudocode)

```rust
#[account]
pub struct DidRecord {
    pub did: String,
    pub storage_ref: [u8; 32],
    pub active: bool,
}

pub fn register_did(ctx: Context<RegisterDid>, did: String, storage_ref: [u8; 32]) -> Result<()> {
    let record = &mut ctx.accounts.did_record;
    record.did = did;
    record.storage_ref = storage_ref;
    record.active = true;
    Ok(())
}
```

This stores the link between:

* DID identifier
* storage reference
* active state

***

### 2. Verifiable Credential Workflow

VCs are issued by trusted entities (or DAOs).\
They remain off-chain, with references hashed and stored in Solana contracts.

#### VC Workflow Example

1. Issuer signs credential
2. Metadata stored on Arweave/IPFS
3. Hash recorded on Solana contract
4. Verification queries DID + VC reference

#### Example Contract Snippet (Anchor)

```rust
#[account]
pub struct VcRegistry {
    pub owner: Pubkey,
    pub vc_hash: [u8; 32],
    pub issued_at: i64,
}

pub fn issue_vc(ctx: Context<IssueVc>, vc_hash: [u8; 32]) -> Result<()> {
    let record = &mut ctx.accounts.vc_registry;
    record.owner = ctx.accounts.user.key();
    record.vc_hash = vc_hash;
    record.issued_at = Clock::get()?.unix_timestamp;
    Ok(())
}
```

***

### 3. Credential-Based Access Control

Smart contracts can enforce:

* gated access
* membership verification
* reputation-weighted voting
* compliance-level proof

#### Access Logic Example

```rust
pub fn has_credential(ctx: Context<CheckCred>, required_hash: [u8; 32]) -> Result<bool> {
    let vc = &ctx.accounts.vc_registry;
    Ok(vc.vc_hash == required_hash)
}
```

Application logic executes based on the result.

***

### 4. ZK Proof Verification

Solana can verify zkSNARK proofs using circuits compiled to the Solana runtime.

Pseudocode for verifying a zk-proof:

```rust
pub fn verify_proof(proof: ZkProof, public_input: &[u8]) -> bool {
    // call verifier program
    zk_program::verify(proof, public_input)
}
```

This may use:

* Groth16
* PlonK
* Circom
* Halo2

The actual implementation depends on chosen ZK backend.

ZK Identities established on Solana as the programmable engine for identity workflows:

* fast DID mapping
* efficient VC referencing
* ZK verification
* cross-chain data coordination
