Skip to content
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.

WIP: Confidential permanent-delegate extension #6882

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

abcalphabet
Copy link
Contributor

WIP implementation for the feature proposed in #6880

How to run

Start up a local validator with the bpf compiled from this branch and the zk-token-sdk enabled on it.

Build the cli on the branch and run the following

solana-keygen new -o key.json;

export SPL_TOKEN_CLI=$PWD"/target/debug/spl-token"
export SIGNER_KEYPAIR='key.json'
export SIGNER_PUBKEY="`solana-keygen pubkey $SIGNER_KEYPAIR`"

export TOKEN_ADDR=$($SPL_TOKEN_CLI create-token --program-id TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb \
    --enable-confidential-transfers auto \
    --enable-confidential-permanent-delegate \
    --decimals 2 --output json \
    --mint-authority $SIGNER_KEYPAIR \
    | jq -r .commandOutput.address)

$IPL_TOKEN_CLI generate-rsa --outfile rsa.pem
$IPL_TOKEN_CLI configure-rsa $TOKEN_ADDR --fee-payer $SIGNER_KEYPAIR \
    --permanent-delegate $SIGNER_KEYPAIR --rsa-key rsa.pem

$SPL_TOKEN_CLI create-account $TOKEN_ADDR \
    --fee-payer $SIGNER_KEYPAIR --owner $SIGNER_KEYPAIR
export ATA_ADDR=$($SPL_TOKEN_CLI accounts $TOKEN_ADDR \
    --owner $SIGNER_KEYPAIR --output json | jq -r .accounts[0].address)
$SPL_TOKEN_CLI configure-confidential-transfer-account --address $ATA_ADDR \
    --fee-payer $SIGNER_KEYPAIR \
    --owner $SIGNER_KEYPAIR
    
$SPL_TOKEN_CLI post-encrypted-keys $TOKEN_ADDR $ATA_ADDR \
    --fee-payer $SIGNER_KEYPAIR --owner $SIGNER_KEYPAIR
$SPL_TOKEN_CLI approve-with-confidential-permanent-delegate \
    $TOKEN_ADDR $ATA_ADDR \
    --fee-payer $SIGNER_KEYPAIR --permanent-delegate $SIGNER_KEYPAIR \
    --rsa-key rsa.pem

Implementation Notes

This implementation uses RSA as the asymmetric encryption algorithm for the permanent delegate. As such the extension may not necessarily be rent and tx-size optimized. Using e.g. ElGamal for the secret key encryption may lead to smaller data sizes.

@mergify mergify bot added the community Community contribution label Jun 19, 2024
@joncinque joncinque requested a review from samkim-crypto June 20, 2024 14:55
@github-actions github-actions bot added the stale [bot only] Added to stale content; will be closed soon label Jul 5, 2024
@samkim-crypto samkim-crypto added do-not-close Add this tag to exempt a PR / issue from being closed automatically and removed stale [bot only] Added to stale content; will be closed soon labels Jul 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
community Community contribution do-not-close Add this tag to exempt a PR / issue from being closed automatically
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants