Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to Ernest Young's Starlight #427

Open
ggviana opened this issue Apr 26, 2024 · 2 comments
Open

Add support to Ernest Young's Starlight #427

ggviana opened this issue Apr 26, 2024 · 2 comments

Comments

@ggviana
Copy link

ggviana commented Apr 26, 2024

Starlight is a transpiler that converts Solidity smart contracts into zApps (zero-knowledge applications), offering developers a streamlined process to create privacy-focused decentralized applications by adding privacy decorators to Solidity, and then running the zappify command to generate a fully functioning zApp.

It introduces 4 new keywords: secret, known, unknown and encrypt and uses the file extension: *.zol

More details could be seen here

Example code:

contract Escrow {
    secret mapping(address => uint256) public balances; // Secret balance
    IERC20 public erc20;

    constructor(address erc20Address) {
        erc20 = IERC20(erc20Address);
    }

    function deposit(uint256 amount) public {
        bool hasBalance = erc20.transferFrom(msg.sender, address(this), amount);
        require(hasBalance == true);
        balances[msg.sender] += amount;
    }
    
    // Transfer secretly using Zero Knowledge receipts
    function transfer(secret address recipient, secret uint256 amount) public {
        balances[msg.sender] -= amount;
        // Increase recipient amount and emit a encrypted event that only recipient can decrypt
        encrypt unknown balances[recipient] += amount;
    }

    function withdraw(uint256 amount) public {
        bool success = erc20.transfer(msg.sender, amount);
        require(success, "ERC20 transfer failed");
        balances[msg.sender] -= amount;
    }
}
@mbolotov
Copy link
Member

there is also a known keyword there.

@ggviana
Copy link
Author

ggviana commented Apr 30, 2024

there is also a known keyword there.

True, I'll edit the OP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants