I couldn't find any example of usage, I'm trying the following and getting Attempt to load a program that does not exist
.
This is trying the official Solana zk-program:
let url = "https://api.mainnet-beta.solana.com".to_string();
let connection = RpcClient::new(url);
let wallet = read_keypair_file("id.json").unwrap();
let keypair = ElGamalKeypair::new_rand();
let amount: u64 = 55;
let ciphertext = keypair.pubkey().encrypt(amount);
let (commitment, opening) = Pedersen::new(amount);
let proof_data = CiphertextCommitmentEqualityProofData::new(
&keypair,
&ciphertext,
&commitment,
&opening,
amount,
)
.unwrap();
let pubkey_validity_data = PubkeyValidityData::new(&keypair).unwrap();
pubkey_validity_data.verify_proof().unwrap();
let latest_blockhash = connection.get_latest_blockhash().unwrap();
let instruction = verify_ciphertext_commitment_equality(None, &pubkey_validity_data);
let txn = Transaction::new_signed_with_payer(
&[instruction],
Some(&wallet.pubkey()),
&[&wallet],
latest_blockhash,
);
match connection.send_and_confirm_transaction(&txn) {
Ok(sig) => loop {
if let Ok(confirmed) = connection.confirm_transaction(&sig) {
if confirmed {
println!("Transaction: {} Status: {}", sig, confirmed);
break;
}
}
},
Err(e) => println!("Error:, {}", e),
}
Also, didn't find anywhere to use proof_data
.
In general, seems like the whole zk-program
is lacking on documentation.