Commit Graph

51 Commits

Author SHA1 Message Date
samkim-crypto 2d58bb287d
[zk-token-sdk] Add option to create proof context state in the proof verification program (#29996)
* extend verifiable trait

* add PodBool

* implement ZkProofData trait

* add proof context program to zk-token-proof program

* update tests  for close account

* add close account instruction

* reorganize tests

* complete tests

* clean up and add docs

* clean up pod

* add proof program state

* update tests

* move proof program tests as separate module

* clippy

* cargo sort

* cargo fmt

* re-organize visibility

* add context state description

* update maintainer reference

* change `VerifyProofData` and `ProofContextState` to pod

* add tests for mixing proof types

* add tests for self owned context state accounts

* cargo fmt

* remove unnecessary scoping and add comments on scopes

* re-organize proof instructions

* clippy

* update zk-token-proof-test to 1.16.0

* upgrade spl-token-2022 to 0.6.1

* reoganize proof type

* cargo lock

* remove ZkProofContext trait
2023-03-16 07:35:20 +09:00
samkim-crypto ae57a14ef6
[zk-token-sdk] reorganize errors (#29005)
* reorganize error using DRY principle

* rename error `Format` to `Deserialization`

* Rename `EncryptionError` to `DiscreteLogError`

* resolve errors from rebase

* resolve clippy

* change `ProofInstructionError` to `ProofError`
2022-12-01 20:29:14 +09:00
samkim-crypto 11efaf75a4
[zk-token-sdk] divide fee encryption into two ciphertexts (#28472)
* divide fee encryption into two ciphertexts

* clippy

* update range proof

* add fee ciphertext decryption

* clean up split_u64 function

* remove unnecessary casting
2022-11-30 15:11:38 +09:00
samkim-crypto f1e7ffba0c
[zk-token-sdk] use canonical decoding for scalars (#28870)
use canonical decoding for scalars
2022-11-18 15:11:06 +09:00
samkim-crypto 491ec1e275
[zk-token-sdk] clean up pod ciphertext arithmetic operations (#28470)
* clean up pod ciphertext arithmetic operations

* rename add_ciphertext to add
2022-10-19 17:36:57 +09:00
samkim-crypto 00b1d0930f
[zk-token-sdk] Restructure proof error types (#28407)
* add pubkey sigma proof

* cargo fmt

* add EncryptionError

* add encryption errors
2022-10-16 07:06:57 +09:00
samkim-crypto bc927097ce
[zk-token-sdk] add pubkey proof (#28392)
* add pubkey proof

* add pubkey sigma proof

* add docs for the sigma proof functions

* add pod public key sigma proof

* add public-key validity proof instruction

* add public-key validity proof instruction

* add VerifyPubkeyValidity instruction

* cargo fmt
2022-10-14 20:15:20 +09:00
Tyera Eulberg 2114136e59
Add Display implementations for various ConfidentialTransfer pod structs (#26783) 2022-07-25 21:09:41 -06:00
samkim-crypto 930fe8ad10
Zk token ops using curve25519 syscalls (#25935)
* zk-token-sdk: use curve25519 syscalls for ElGamal arithmetic

* zk-token-sdk: clippy

* adjust curve25519 syscall costs

* cargo fmt
2022-06-13 22:39:07 +09:00
Alessandro Decina 2c8a3f39a6
Consolidate syscalls under solana_program::syscalls, implement static syscalls (sbfv2) (#24188)
Move all syscall declarations under solana_program::syscalls. If the target
supports static syscalls (sbfv2), then actually define them statically to avoid
dynamic relocations.
2022-05-26 23:01:55 +10:00
samkim-crypto d33cb2fa54
zk-token-sdk: implement convert traits for elgamal ciphertexts and ristretto points (#25549) 2022-05-26 05:46:29 +09:00
Michael Vines b05c7d91ed Fix derive_partial_eq_without_eq clippy lint 2022-05-22 22:22:21 -07:00
Dmitri Makarov 569b00025c fix: replace rust cfg annotations that use bpf by target_os solana 2022-05-18 20:39:43 -07:00
samkim-crypto d2b23da9ea
Zk token sdk clean decryption (#23478)
* zk-token-sdk: add decryption for pod elgamal ciphertexts

* zk-token-sdk: add decryption for pod elgamal ciphertexts

* zk-token-sdk: cargo fmt

* zk-token-sdk: minor update to docs

* zk-token-sdk: minor

* zk-token-sdk: fix bpf build error

* zk-token-sdk: more simplifying discrete log

* zk-token-sdk: fmt

* zk-token-sdk: minor update to doc
2022-03-04 15:57:19 -04:00
samkim-crypto 8d53ea81e9
zk-token-sdk: change variable names to use suffix rather than prefix (#23474)
* zk-token-sdk: change variable names to use suffix rather than prefix for type

* zk-token-sdk: cargo fmt
2022-03-03 15:07:27 -05:00
samkim-crypto b4100a9b5d
Add additional zkp for fee (#23112)
* zk-token-sdk: add equality proof for fee

* zk-token-sdk: tweak some naming conventions for readability

* zk-token-sdk: add verify withdraw withheld instruction

* zk-token-sdk: add test for withdraw withheld verification

* zk-token-sdk: more renaming of variables for readability

* zk-token-sdk: cargo fmt

* zk-token-sdk: minor

* zk-token-sdk: resolve bpf compilation warnings

* zk-token-sdk: minor update to doc
2022-02-17 12:45:07 -05:00
samkim-crypto 7873175764
zk-token-sdk: fix pod for zk-token transfer (#22957) 2022-02-08 12:09:50 -05:00
samkim-crypto 65f8f43665
Zk instructions pass (#22851)
* zk-token-sdk: re-organize transcript

* zk-token-sdk: add pod ElGamal group encryption

* zk-token-sdk: add transcript domain separators for sigma proofs

* zk-token-sdk: clean up transfer tx decryption

* zk-token-sdk: resolve encoding issues for transfer

* zk-token-sdk: fix transfer test

* zk-token-sdk: clean up transcript for close account and withdraw instructions

* zk-token-sdk: add transfer with fee instruction

* zk-token-sdk: add transfer with fee instruction

* zk-token-sdk: add pod for cryptographic structs needed for fee

* zk-token-sdk: add pod for fee sigma proof

* zk-token-sdk: fix test for transfer with fee instruction

* zk-token-sdk: add range proof verification for transfer with fee

* zk-token-sdk: add transfer amount decryption for transfer-with-fee

* zk-token-sdk: add proof generation error for instruction

* zk-token-sdk: cargo fmt and clippy

* zk-token-sdk: fix bpf build
2022-02-01 14:11:28 -05:00
samkim-crypto 5cef4c0a4c
Sigma pass (#22801)
* zk-token-sdk: add zeroize and reference arithmetic to zero-balance proof

* zk-token-sdk: add zeroize and reference arithmetic to equality proof

* zk-token-sdk: add zeroize and reference arithmetic to validity proof

* zk-token-sdk: add aggregated validity proof

* zk-token-sdk: use subtle choice for fee

* zk-token-sdk: add test for fee proof

* zk-token-sdk: add documentation for sigma protocols

* zk-token-sdk: add edge case tests for equality proof

* zk-token-sdk: add edge case tests for zero-balance proof

* zk-token-sdk: add edge case tests for validity proof

* zk-token-sdk: add some docs for fee sigma proof

* zk-token-sdk: clippy
2022-01-27 19:53:15 -05:00
samkim-crypto d8cbb2a952
Elgamal pass (#22632)
* zk-token-sdk: change G and H to static and optimize pedersen arithmetic

* zk-token-sdk: remove unnecessary copy in elgamal arithmetic

* zk-token-sdk: fix elgamal tests for new syntax

* zk-token-sdk: use lazy-static for pedersen base

* zk-token-sdk: add dlog test for elgamal decryption

* zk-token-sdk: reflect changes in elgamal in the rest of the sdk

* zk-token-sdk: rustfmt and clippy

* zk-token-sdk: some documentation for elgamal and pedersen

* zk-token-sdk: minor remove whitespace

* zk-token-sdk: update lock files

* zk-token-sdk: change random() to new_rand()

* zk-token-sdk: add explanation for suppressing clippy::op_ref
2022-01-21 20:56:27 -05:00
Tyera Eulberg 7be533a770
Add zeroed default for ElGamalCiphertext (#22639) 2022-01-21 19:52:36 +00:00
samkim-crypto 41fb98c771
zk-token_sdk: define defaults for pod ElGamal/AES ciphertexts (#22532) 2022-01-20 16:27:31 -05:00
Sam Kim 5b41d62f8a feat: fix clippy for new error types 2022-01-05 08:51:18 -08:00
Sam Kim 0944abc0e2 feat: update error types for sdk 2022-01-05 08:51:18 -08:00
Sam Kim 584c63bcc4 refactor: CloseAccount now uses zero-balance-proof 2022-01-05 08:51:18 -08:00
Sam Kim c26fa1d0e9 refactor: create pod struct for ZeroBalanceProof 2022-01-05 08:51:18 -08:00
Sam Kim c6cd0a5591 refactor: group equality and validity proofs in sigma_proofs module 2022-01-05 08:51:18 -08:00
Sam Kim 9a43fbe3b2 clean up authenticated encryption implementation and also rename aes to auth_encryption 2022-01-05 08:51:18 -08:00
Sam Kim 7a568482de cargo fmt and fix clippy 2022-01-05 08:51:18 -08:00
Sam Kim 30871784e4 incorporate validity proof into transfer proof 2022-01-05 08:51:18 -08:00
Sam Kim 6c329e2431 add equality proof struct 2022-01-05 08:51:18 -08:00
Michael Vines aba8c2f4af reformat imports 2022-01-05 08:51:18 -08:00
Sam Kim defdf8da72 change AESCiphertext to AesCiphertext 2022-01-05 08:51:18 -08:00
Sam Kim 3721eda23e serialization for aes 2022-01-05 08:51:18 -08:00
Sam Kim 173d88d514 remove `OptionAESCiphertext` 2022-01-05 08:51:18 -08:00
Sam Kim 6749c45c63 merge 2022-01-05 08:51:18 -08:00
Sam Kim 57103c515b update applying pending balance for aes ciphertext 2022-01-05 08:51:18 -08:00
samkim-crypto 2d225de48c pod for AESCiphertext 2022-01-05 08:51:18 -08:00
Michael Vines 93eb49a3e3 Rename ElGamalKeypair fields 2022-01-05 08:51:18 -08:00
Michael Vines c33e24de57 Rename ElGamal to ElGamalKeypair 2022-01-05 08:51:18 -08:00
Michael Vines f272c025bd Rename ElGamal::new() to ElGamal::default() 2022-01-05 08:51:18 -08:00
Michael Vines 2c1aa715b0 Adjust ElGamal::new() signature 2022-01-05 08:51:18 -08:00
Sam Kim 73c06d9e33 Rename ElGamalPubkey::gen_decrypt_handle method to ElGamalPubkey::decrypt_handle 2022-01-05 08:51:18 -08:00
Michael Vines 20c6001836 derive Debug for pods for BPF target as well 2022-01-05 08:51:18 -08:00
Sam Kim a40e7fc59b Rename Pedersen related structs and methods for consistency 2022-01-05 08:51:18 -08:00
Michael Vines a622ee4b8d Rename ElGamal::keygen to ElGamal::new 2022-01-05 08:51:18 -08:00
Michael Vines 2f138ecb96 Fix tests 2022-01-05 08:51:18 -08:00
Michael Vines 48047b55ba clippy 2022-01-05 08:51:18 -08:00
Michael Vines f227504ea7 Add sol_zk_token_elgamal syscall declarations 2022-01-05 08:51:18 -08:00
Michael Vines 78799640ea Rename ElGamalCT to ElGamalCiphertext, ElGamalPK to ElGamalPubkey 2022-01-05 08:51:18 -08:00