SACRED Technical Private Doc
  • What is Sacred?
    • Introduction to Sacred
    • Repos and Video Walkthrough
    • How to Use Sacred
    • Sacred Pools (Boxes)
    • Anonymity Set
    • User journey - from Deposit to Withdrawal
      • 1. Receive Note
      • 2. Deposit Tokens
      • 3. Earn While Waiting
        • Shares-of-Staked Seconds
        • Interest earning interest
        • Share Tracking Quirks
      • 4. Withdraw
      • 5. Redeem Claim - Receive Principal
        • Sacred Automated Market Maker
      • 6. Redeem Yield
      • 7. Redeem Incognito Credits
      • Using a Relayer to withdraw the principal, IC and yield
    • Sacred Rules to keep your deposit private
    • Circuits Summary
    • Links to individual Contracts
Powered by GitBook
On this page
  1. What is Sacred?
  2. User journey - from Deposit to Withdrawal

1. Receive Note

Before an asset is deposited into a Sacred pool, a unique Sacred Claim (secure note) in the form of a string of words and letters is generated. This claim is locally generated and only the depositor will have access to this Sacred Claim. The Claim is critical to withdraw the deposited assets and needs to be stored somewhere safe.

Code Summary - Generating the note - (ZK Proof)

  1. Crafting the Note:

    1. Generate two random values, nullifier and secret

    2. Calculate the commitment (Pedersen Hash of (nullifier + secret))

    3. Note contains:

      • Currency (from user input)

      • Amount (from user input)

      • Network (from user input)

      • Nullifier Secret

    Only the commitment is sent to the contract when depositing. Note: the Secret value is never shared to the contract or any parties other than the user and their browser.

  2. Generating the proof (done locally):

    1. Get current state from contract (past deposits)

    2. Assemble merkle tree (locally) from past deposits

    3. Sanity checks (corrupted Merkle tree, spent note, non-existent, etc.)

    4. Generate SNARK proof:

      1. Public Inputs

        1. Root

        2. Nullifier (hash)

        3. Recipient (address)

        4. Relayer (address)

        5. Fee

        6. Refund

      2. Private Inputs

        1. Nullifier

        2. Secret

        3. Path indices (location in Merkle Tree)

    5. Output is the Proof

PreviousUser journey - from Deposit to WithdrawalNext2. Deposit Tokens

Last updated 2 years ago

Logosacred-cli-tools/cli.js at 9e297751a63087e140b6e0577cba6af702806341 · Sacred-Finance/sacred-cli-toolsGitHub