Moonight Protocol: Project Story

About the Project

What Inspired Us

The inspiration for Moonight Protocol came from a powerful realization: 1.4 billion people worldwide participate in informal lending circles (ROSCAs), but digital solutions force them to choose between financial inclusion and privacy.

Traditional ROSCAs work beautifully - groups of friends or community members pool money monthly, taking turns receiving lump sums. It's a $180+ billion global market that has helped communities build wealth for centuries. But when these move online, participants must expose their entire financial lives to strangers.

Existing DeFi lending requires overcollateralization and makes every transaction public. We saw an opportunity to preserve the social benefits of community lending while adding the privacy protections people deserve.

What We Learned

Building on Midnight taught us that privacy isn't just a feature - it's a fundamental requirement for inclusive finance. Key insights:

  • Zero-knowledge proofs enable trust without exposure: We can prove creditworthiness without revealing transaction history
  • Anonymous governance actually increases participation: People vote more honestly when their preferences remain private
  • Cross-chain privacy requires ground-up design: Simply bridging assets isn't enough - identities must remain unlinkable
  • Privacy and transparency can coexist: Circle operations remain verifiable while individual actions stay confidential

How We Built It

Architecture Overview

// Core privacy-preserving smart contract structure
contract MoonightCore {
    // Private member registry with ZK proofs
    mapping(bytes32 => PrivateMember) private members;

    // Anonymous circles with confidential parameters  
    mapping(uint256 => PrivateCircle) public circles;

    // ZK trust scoring system
    ZKTrustOracle private trustOracle;

    function joinCircle(
        uint256 circleId,
        ZKMembershipProof memory proof,
        CommittedStake memory stake
    ) external returns (bytes32 anonymousId);
}

Trust Scoring Algorithm

We implemented a multi-dimensional trust system using zero-knowledge proofs:

$$\text{Trust Score} = 0.4 \times P + 0.3 \times C + 0.2 \times D + 0.1 \times S$$

Where:

  • \(P\) = Payment reliability score (private transaction history)
  • \(C\) = Circle completion rate (anonymous participation record)
  • \(D\) = DeFi experience score (private protocol interactions)
  • \(S\) = Social verification score (selective identity disclosure)

Privacy-Preserving Bidding

// Anonymous bidding mechanism using ZK proofs
contract PrivateBidding {
    struct ConfidentialBid {
        bytes32 bidCommitment;    // Hides bid amount
        bytes32 memberNullifier;  // Prevents double-bidding
        ZKEligibilityProof proof; // Proves bidding rights
    }

    function submitBid(ConfidentialBid memory bid) external {
        // Verify eligibility without revealing identity
        require(verifyEligibility(bid.proof), "Not eligible");

        // Store private bid
        privateBids[currentRound].push(bid);
    }

    function revealWinner() external returns (address winner) {
        // ZK proof determines winner without exposing losing bids
        return zkDetermineWinner(privateBids[currentRound]);
    }
}

Challenges We Faced

1. Zero-Knowledge Circuit Complexity

Creating circuits that could verify trust scores without revealing underlying data required multiple iterations. We had to balance privacy with computational efficiency.

Solution: Implemented hierarchical ZK proofs - basic eligibility proofs for common operations, detailed trust proofs only when needed.

2. Cross-Chain Anonymous Identity

Maintaining unlinkable identities across different blockchains while proving they belong to the same trusted participant.

Solution: Used Midnight as the privacy coordination layer, generating chain-specific nullifiers from a master anonymous identity.

// Cross-chain identity management
class AnonymousIdentity {
    private masterKey: PrivateKey;

    generateChainNullifier(chainId: string): Nullifier {
        return hash(this.masterKey, chainId, "nullifier_salt");
    }

    // Proves same identity across chains without linking addresses
    generateCrossChainProof(): ZKProof {
        return proveInZK({
            privateInput: this.masterKey,
            publicOutput: "Same trusted participant"
        });
    }
}

3. Privacy-Preserving Governance

Enabling democratic decision-making while keeping individual votes confidential.

Solution: Implemented anonymous voting with trust-weighted tallying using ZK-SNARKs.

4. Economic Security Without Transparency

Traditional staking relies on public accountability, but privacy requirements meant hidden stakes and penalties.

Solution: Created ZK proofs of stake sufficiency and automated penalty enforcement through private smart contracts.

Technical Stack

Frontend Architecture

Built a privacy-focused React application with TypeScript that prioritizes user anonymity:

// Privacy-preserving authentication component
const AnonymousAuth: React.FC = () => {
  const [zkIdentity, setZkIdentity] = useState<ZKIdentity | null>(null);

  const generateAnonymousIdentity = async () => {
    const identity = await MidnightSDK.createAnonymousIdentity();
    const proof = await identity.generateMembershipProof();
    setZkIdentity(identity);
  };

  return (
    <div className="privacy-auth-container">
      <h2>Anonymous Access</h2>
      <button onClick={generateAnonymousIdentity}>
        Generate Private Identity
      </button>
      {zkIdentity && <TrustScoreDisplay identity={zkIdentity} />}
    </div>
  );
};

Smart Contract Integration

Connected frontend to Midnight's private smart contracts using custom SDK:

// Circle interaction with privacy preservation
class MoonightCircleManager {
  private midnightSDK: MidnightSDK;

  async joinPrivateCircle(circleId: string, stakeAmount: number) {
    const membershipProof = await this.generateMembershipProof();
    const stakeCommitment = await this.commitToStake(stakeAmount);

    const joinTx = await this.midnightSDK.executePrivateTransaction({
      contract: 'MoonightCore',
      method: 'joinCircle',
      params: {
        circleId,
        proof: membershipProof,
        stake: stakeCommitment
      },
      privacy: 'maximum'
    });

    return joinTx.anonymousReceipt;
  }
}

Privacy Innovations

  1. Anonymous Trust Building: Build reputation across protocols without exposing transaction details
  2. Confidential Bidding: Compete for loans without revealing bid amounts to other participants
  3. Private Governance: Democratic decision-making with hidden individual preferences
  4. Cross-Chain Privacy: Participate across blockchains with unlinkable identities
  5. Selective Disclosure: Choose exactly what information to reveal and to whom

Impact and Future Vision

Moonight Protocol represents the first privacy-native community lending platform. By combining traditional ROSCA principles with zero-knowledge technology, we're creating a new category of social finance that serves the 1.4 billion people seeking financial inclusion without surveillance.

Our hackathon prototype demonstrates that privacy and community finance are not just compatible - they're synergistic. Privacy actually increases participation by removing barriers like financial shame and competitive concerns.

Share this project:

Updates