Diversification of DAO Treasury through Real-World Assets (RWAs) and Real-World Projects (RWPs)

A diagram.

Some code.

Rust
use cosmwasm_std::{
    entry_point, to_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult,
};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use winterfell::{Proof, VerifierError};
use winterfell::crypto::hashers::{Blake3_256, Hasher};

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ExecuteMsg {
    VerifyProof(VerifyProofMsg),
}

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct VerifyProofMsg {
    pub proof: StarkProof,
    pub public_inputs: Vec<u8>,
    pub vk: Vec<u8>, // Verification key submitted with proof
}

#[entry_point]
pub fn instantiate(
    deps: DepsMut,
    _env: Env,
    _info: MessageInfo,
    _msg: Empty, // No instantiation message needed in this example
) -> Result<Response, ContractError> {
    // Initialize the verification key hash (if using hash commitment)
    // ...
    Ok(Response::default())
}

#[entry_point]
pub fn execute(
    deps: DepsMut,
    env: Env,
    info: MessageInfo,
    msg: ExecuteMsg,
) -> Result<Response, ContractError> {
    match msg {
        ExecuteMsg::VerifyProof(proof_msg) => verify_proof(deps, env, info, proof_msg),
    }
}

#[entry_point]
pub fn verify_proof(
    deps: DepsMut,
    env: Env,
    info: MessageInfo,
    msg: VerifyProofMsg,
) -> Result<Response, ContractError> {
   
    // 1. Load Verification Key (Stored in contract storage)
    let vk = load_verification_key(deps.storage)?;

    // 2. Verify Proof
    match winterfell::verify::<Blake3_256>(&vk, &msg.proof, &msg.public_inputs) {
        Ok(()) => Ok(Response::new().add_attribute("action", "proof_verified")),
        Err(VerifierError::VerificationFailed) => Err(ContractError::InvalidProof),
        Err(err) => Err(ContractError::VerificationError(err)), // Handle other errors
    }

}

The only state we’d need to initialize on this is owner. The HTTP server that sends the prover data from the rust server could hold the verification key and send it to all the verifier contracts on CosmWasm enabled chains.

MORE SCRUNITY SHOULD BE EVALUATED FOR ATTACK VECTORS, but overall this a way to KYC clients and stay sudo-anonymous. There is some minor errors in this code, and code for the entire system isn’t here, but it’s enough for validation.

1 Like