blockchain

What is the behavior of the disclose() function in Compact language?


I'm building on Midnight, and am still trying to learn compact. I'm trying to understand the disclose() function and it's impact on and privacy selective disclosure in a permissioned DApp context.

I'm looking at Midnight's documentation and looking at this example:

import CompactStandardLibrary;
witness get_balance(): Bytes<32>;
export ledger balance: Bytes<32>;

export circuit record_balance(): [] {
    balance = disclose(get_balance());
}

When disclose(get_balance()) is used to assign a value to the public ledger variable balance, does this mean the private witness data (get_balance()) becomes permanently readable by all users on the public ledger, or is the disclosed data only accessible to specific parties (e.g., the caller or permissioned users)? If it’s fully public, how does this align with the concept of selective disclosure?


Solution

  • disclose(get_balance()) doesn't make the value of get_balance readable.  It just makes it okay to write it to the public ledger.  Writing it to the public ledger would then make that value visible, and we want the programmer to have to explicitly write some code to acknowledge that is what they intended.