Skip to content

KikiProjecto/shadowvault-protocol

Repository files navigation

ShadowVault AI - Privacy-First DeFi Intelligence

Solana Built with Arcium TypeScript Rust

Colosseum Cypherpunk Hackathon | Arcium Encrypted Compute Track

Overview

ShadowVault AI is the first AI-powered DeFi intelligence platform where portfolio data, trading strategies, and positions remain completely private through Arcium's Multi-Party Computation (MPC) network.

Key Innovation: XorSHAP Explainable AI in MPC

This project uniquely combines:

  • AI-Powered DeFi Recommendations - Intelligent strategy generation based on encrypted portfolio analysis
  • Explainable AI - XorSHAP decision trees with transparent feature importance (see ai_strategy.rs lines 47-143)
  • Fully Encrypted Computation - Arcium MPC ensures zero data leakage throughout the entire pipeline
  • Production-Ready Implementation - Complete smart contract and frontend integration

Quick Start

# 1. Clone the repository
git clone https://github.com/kikiprojecto/shadowvault-protocol
cd shadowvault-protocol

# 2. Install frontend dependencies
cd app
npm install

# 3. Deploy smart contract (requires Anchor CLI)
anchor build
anchor deploy --provider.cluster devnet

# 4. Update environment variables
cp .env.example .env.local
# Add your deployed PROGRAM_ID to .env.local

# 5. Run the frontend
npm run dev

# 6. Visit http://localhost:3000

Project Structure

This project follows Arcium's encrypted compute architecture:

// encrypted-ixs/add_together.rs

use arcis_imports::*;

#[encrypted]
mod circuits {
    use arcis_imports::*;

    pub struct InputValues {
        v1: u8,
        v2: u8,
    }

    #[instruction]
    pub fn add_together(input_ctxt: Enc<Shared, InputValues>) -> Enc<Shared, u16> {
        let input = input_ctxt.to_arcis();
        let sum = input.v1 as u16 + input.v2 as u16;
        input_ctxt.owner.from_arcis(sum)
    }
}

// programs/my_program/src/lib.rs

use anchor_lang::prelude::*;
use arcium_anchor::prelude::*;

declare_id!("<some ID>");

#[arcium_program]
pub mod my_program {
    use super::*;

    pub fn init_add_together_comp_def(ctx: Context<InitAddTogetherCompDef>) -> Result<()> {
        init_comp_def(ctx.accounts, true, 0, None, None)?;
        Ok(())
    }

    pub fn add_together(
        ctx: Context<AddTogether>,
        computation_offset: u64,
        ciphertext_0: [u8; 32],
        ciphertext_1: [u8; 32],
        pub_key: [u8; 32],
        nonce: u128,
    ) -> Result<()> {
        let args = vec![
            Argument::ArcisPubkey(pub_key),
            Argument::PlaintextU128(nonce),
            Argument::EncryptedU8(ciphertext_0),
            Argument::EncryptedU8(ciphertext_1),
        ];
        ctx.accounts.sign_pda_account.bump = ctx.bumps.sign_pda_account;
        queue_computation(
            ctx.accounts,
            computation_offset,
            args,
            None,
            vec![AddTogetherCallback::callback_ix(&[])],
        )?;
        Ok(())
    }

    #[arcium_callback(encrypted_ix = "add_together")]
    pub fn add_together_callback(
        ctx: Context<AddTogetherCallback>,
        output: ComputationOutputs<AddTogetherOutput>,
    ) -> Result<()> {
        let o = match output {
            ComputationOutputs::Success(AddTogetherOutput { field_0: o }) => o,
            _ => return Err(ErrorCode::AbortedComputation.into()),
        };

        emit!(SumEvent {
            sum: o.ciphertexts[0],
            nonce: o.nonce.to_le_bytes(),
        });
        Ok(())
    }
}

#[queue_computation_accounts("add_together", payer)]
#[derive(Accounts)]
#[instruction(computation_offset: u64)]
pub struct AddTogether<'info> {
    #[account(mut)]
    pub payer: Signer<'info>,
    // ... other required accounts
}

#[callback_accounts("add_together", payer)]
#[derive(Accounts)]
pub struct AddTogetherCallback<'info> {
    #[account(mut)]
    pub payer: Signer<'info>,
    // ... other required accounts
    pub some_extra_acc: AccountInfo<'info>,
}

#[init_computation_definition_accounts("add_together", payer)]
#[derive(Accounts)]
pub struct InitAddTogetherCompDef<'info> {
    #[account(mut)]
    pub payer: Signer<'info>,
    // ... other required accounts
}

About

Privacy-first institutional DeFi aggregator using Arcium's encrypted compute on Solana

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

 
 
 

Contributors