Commit Graph

305 Commits

Author SHA1 Message Date
mergify[bot] bdf39e85c1
v2.0: [zk-token-sdk] Specify version in deprecations in `zk-token-sdk` (backport of #2011) (#2014) 2024-07-08 20:55:59 +09:00
Jon C 9bb532abcc
deps: Use bytemuck_derive explicitly instead of "derive" feature on bytemuck (#1799)
* deps: Use bytemuck_derive explicitly

* Missed a couple in zk-token-sdk

* Fix last few bits

* Fixup a re-export

* Use re-exports properly
2024-06-21 12:50:36 +02:00
samkim-crypto ef80b59f9b
[curve25519] Remove `ElGamalError` from curve25519 crate (#1777)
* remove `ElGamalError` from curve25519 crate

* add `ElGamalError` to zk-token-sdk
2024-06-18 20:39:43 +09:00
Kevin Heavey b855bd0c54
Extract curve25519 crate from zk-token-sdk (#951)
* extract curve25519 crate

* remove obsolete comment

* fix Cargo.toml files

* fix imports

* update lock file

* remove unused deps from zk-token-sdk

* fmt

* add solana-curve25519 patch

* add missing override to programs/sbf/Cargo.toml

* copy over an allow()

* move new crate to curves dir

* use workspace version

* add back missing dev dep

* add missing dependencies to programs/sbf

* fmt

* move dep to the correct dependency table

* remove #[cfg(not(target_os = "solana"))] above errors mod
2024-06-18 14:08:57 +09:00
Andrei Silviu Dragnea ac00bea0a9
Re-export curve25519-dalek from solana-zk-token-sdk (#1657) 2024-06-10 22:09:33 +09:00
Yihau Chen 3ea11e0498
chore: bump aes-gcm-siv from 0.10.3 to 0.11.1 (#1521) 2024-05-30 00:17:31 +00:00
Yihau Chen ec9bd79849
clippy: fix legacy_numeric_constants (#1314)
clippy: legacy_numeric_constants
2024-05-15 11:29:19 +08:00
Kevin Heavey 59e3eaafb5
Prefer explicitly using serde_derive instead of the "derive" feature of serde (#1329)
* use serde_derive instead of the derive feature of serde

* make serde_derive version match serde version

* remove serde dep entirely from programs/address-lookup-table

* replace remaining usage of serde "derive" feature

* update lock files

* explicitly use serde_derive in svm and frozen-abi

* add comments about serde and serde_derive versions matching
2024-05-15 01:11:31 +02:00
Yihau Chen f121b8539a
clippy: allow dead_code for zk transcript (#1244) 2024-05-08 23:32:39 +08:00
samkim-crypto b28792bcb2
[zk-token-sdk] Expose `ProofVerificationError` type in sbf target build (#954)
* include range proof and sigma proof errors in sbf target build

* include proof verification and transcript error types in sbf target build
2024-04-23 20:46:49 +09:00
samkim-crypto c33537bf74
[zk-token-sdk] Make transfer modules public (#953)
make transfer modules public
2024-04-23 20:46:37 +09:00
samkim-crypto 8cca3f9a3c
[zk-token-sdk] Add ciphertext validity proof with 3 handles instruction (#897)
* refactor ciphertext for 2 handles instructions

* add instruction data for ciphertext with 3 handles validity proof

* add ciphertext for 3 handles validity proof instruction

* add test and bench for ciphertext 3 handles validity proof instruction

* cargo fmt

* Apply suggestions from code review

Co-authored-by: Jon C <me@jonc.dev>

* update instruction docs to mention the possibility to read from accounts

* Apply suggestions from code review

Co-authored-by: Jon C <me@jonc.dev>

---------

Co-authored-by: Jon C <me@jonc.dev>
2024-04-23 07:06:13 +09:00
samkim-crypto 3426f7ec0a
[zk-token-sdk] Add ciphertext validity proof with 3 handles (#809)
* refactor ciphertext validity sigma proofs for 2 handles

* add ciphertext validity sigma proofs for 3 handles

* add pod types for ciphertext validity sigma proofs for 3 handles

* add `allow(dead_code)` temporarily

* cargo clippy

* Update zk-token-sdk/src/zk_token_elgamal/pod/sigma_proofs.rs

Co-authored-by: Jon C <me@jonc.dev>

---------

Co-authored-by: Jon C <me@jonc.dev>
2024-04-18 17:44:26 +09:00
samkim-crypto 385f7eed15
[zk-token-sdk] Add ctxt extraction functions for grouped ElGamal ciphertexts (#588)
* add extraction functions for `GroupedElGamalCiphertext3Handles`

* use macro for extraction functions

* add extraction functions for `GroupedElGamalCiphertext2Handles`

* fix `ElGamalError` visibility

* add tests for ciphertext extraction
2024-04-16 07:37:47 +09:00
samkim-crypto b046c12cdc
[zk-token-sdk] Refactor `AuthenticatedEncryptionError` and `ElGamalError` to errors module (#589)
* make the `errors` module available in sbf targets

* move `AuthenticatedEncryptionError` to the `errors` module

* move `ElGamalError` to the `errors` module
2024-04-12 11:26:40 +09:00
abcalphabet 855a0c1a92
ElGamal: add From impls; deprecate from/to_bytes (#246)
* ElGamal: add From impls; deprecate from/to_bytes

* variable names
2024-04-05 08:47:07 +09:00
abcalphabet 0168e0ab69
add serialization to AeKey (#208)
* add serialization to AeKey

* make ElGamalKeypair/AeKey byte lengths public

* switch from/to_bytes to from

* tests for change logic

* variable names

* fix clippy on tests

* fix nit

Co-authored-by: samkim-crypto <skim13@cs.stanford.edu>

---------

Co-authored-by: samkim-crypto <skim13@cs.stanford.edu>
2024-04-03 10:50:37 +09:00
samkim-crypto fb1ee7842f
[zk-token-sdk] Allow discrete log to be executed in the current thread (#443) 2024-03-30 06:37:43 +09:00
samkim-crypto a3bc406b55
[zk-token-sdk] Remove `std::thread` from wasm target (#379) 2024-03-26 19:54:06 +09:00
samkim-crypto fba70c8504
[zk-token-sdk] Implement `FromStr` for `ElGamalPubkey`, `ElGamalCiphertext`, and `AeCiphertext` (#130)
* add `ParseError` in `zk-token-elgamal`

* implement `FromStr` for `ElGamalPubkey` and `ElGamalCiphertext`

* implement `FromStr` for `AeCiphertext`

* fix target

* cargo fmt

* use constants for byte length check

* make `FromStr` functions available on chain

* use macros for the `FromStr` implementations

* restrict `from_str` macro to `pub(crate)`

* decode directly into array

* cargo fmt

* Apply suggestions from code review

Co-authored-by: Jon C <me@jonc.dev>

* remove unnecessary imports

* remove the need for `ParseError` dependency

---------

Co-authored-by: Jon C <me@jonc.dev>
2024-03-15 09:09:41 +09:00
samkim-crypto b11d41a3f7
[zk-token-sdk] Use checked arithmetic when processing transfer amount (#34130)
* add `try_split_u64`

* add `try_combine_lo_hi_u64`

* add `try` variants of ciphertext arithmetic functions

* use try functions in proof generaiton and verification logic

* deprecate non-`try` functions

* use try functions in proof generaiton and verification logic

* Apply suggestions from code review

Co-authored-by: Jon C <me@jonc.dev>

* cargo fmt

---------

Co-authored-by: Jon C <me@jonc.dev>
2024-01-24 22:27:03 +09:00
samkim-crypto e2c2029ac4
[zk-token-sdk] Restrict a single-bit of 256-bit batched range proof to 128 (#34803)
* fix previous typo

* restrict single-bit of 256-bit batched range proof to 128
2024-01-18 14:37:04 +09:00
samkim-crypto b222fdf3d7
[zk-token-proof] Add functionality to read proof from accounts instead of instruction data (#34750)
* add functionality to read proof from accounts instead of instruction data

* update add tests

* clippy

* clarify instruction data discriminator

* avoid cloning entire proof data

* Update programs/zk-token-proof/src/lib.rs

Co-authored-by: Jon C <me@jonc.dev>

* update `PROOF_OFFSET_LENGTH` to `INSTRUCTION_DATA_LENGTH_WITH_PROOF_ACCOUNT`

* update instruction docs

* add feature gate

* Update sdk/src/feature_set.rs

Co-authored-by: Jon C <me@jonc.dev>

* update feature name `enable_zk_from_account` to `enable_zk_proof_from_account`

* Apply suggestions from code review

Co-authored-by: Jon C <me@jonc.dev>

* clarify the instruction data length more precisely

---------

Co-authored-by: Jon C <me@jonc.dev>
2024-01-13 08:15:44 +09:00
Nick Frostbutter fc2a8794be
[docs] updated readme and fix links (#34565)
* feat: updated readme

* fix: updated links

* fix: proposal links

* fix: more links

* fix: json-rpc links

* fix: more links

* fix: zk links

* fix: managing forks

* fix: links for deprecated methods
2024-01-03 09:06:06 -05:00
Brooks 59dd007899
clippy: zk-token-sdk lints (#34633) 2024-01-02 22:01:42 -05:00
GoodDaisy 03386cc7b9
Fix typos (#34459)
* Fix typos

* Fix typos

* fix typo
2023-12-21 13:06:00 -07:00
samkim-crypto aaccbdd0ae
[zk-token-sdk] Fix range proof transcript seed typo (#34468)
fix range proof transcript seed typo
2023-12-14 13:37:12 -08:00
pandabadger 549c3e7813
Fix a number of typos (#34385)
* Update vote-accounts.md

* Update what-is-a-validator.md

* Update what-is-a-validator.md

* Update accounts-db-replication.md

* Update blockstore-rocksdb-compaction.md

* Update rip-curl.md

* Update ledger-replication-to-implement.md

* Update optimistic_confirmation.md

* Update return-data.md

* Update handle-duplicate-block.md

* Update timely-vote-credits.md

* Update optimistic-transaction-propagation-signal.md

* Update simple-payment-and-state-verification.md

* Update off-chain-message-signing.md

* Update mod.rs

* Update elgamal.rs

* Update ledger.md

* Update deploy-a-program.md

* Update staking-rewards.md

* Update reliable-vote-transmission.md

* Update repair-service.md

* Update abi-management.md

* Update testing-programs.md

* Update docs/src/implemented-proposals/staking-rewards.md

Co-authored-by: Tyera <teulberg@gmail.com>

---------

Co-authored-by: Tyera <teulberg@gmail.com>
2023-12-12 15:27:29 -05:00
samkim-crypto d21e7edd2b
[zk-token-sdk] Fix transfer with fee edge case error (#34314) 2023-12-07 06:46:57 +09:00
samkim-crypto ded278fb57
[zk-token-sdk] Add range proof generation error types (#34065)
* replace assert statements with `VectorLengthMismatch` error variant

* add a condition to check that the bit lengths are in the correct range

* replace assert statements with `GeneratorLengthMismatch`

* remove unchecked arithmetic

* add `InnerProductLengthMismatch` error

* fix typo

* add a clarifying comment on unwrap safety

* fix typo
2023-11-22 06:50:24 +09:00
samkim-crypto 0e6dd54f81
[zk-token-sdk] Restrict range proof generator length and prevent 0-bit range proof (#34166)
* limit range proof generator length

* forbid 0-bit range proof verification
2023-11-21 08:48:41 +09:00
samkim-crypto e251b8607c
[zk-token-sdk] Add a length check on range proof commitment length (#34165)
add a length check on range proof commitment length
2023-11-21 08:48:15 +09:00
samkim-crypto 0fd4762399
[zk-token-sdk] Re-organize error types (#34034)
* add deserialization error type for encryption

* re-organize sigma proof error types

* re-organize range proof error types

* update pod conversion module

* update instruction error types

* clippy

* fix `thiserror` visibility

* Apply suggestions from code review

Co-authored-by: Jon Cinque <me@jonc.dev>

---------

Co-authored-by: Jon Cinque <me@jonc.dev>
2023-11-17 07:00:47 +09:00
Brooks ea98c0ea36
clippy: Uses .into() when .try_into() is infallible (#34049) 2023-11-13 23:49:35 -05:00
Brooks e9135e2211
clippy: Remove unused import (#34050) 2023-11-13 17:25:11 -05:00
Brooks 725ab37bf4
clippy: Replaces .get(0) with .first() (#34048) 2023-11-13 17:22:17 -05:00
samkim-crypto 381d2254eb
[zk-token-sdk] Check that discrete log compression batch size is greater than 0 (#33699)
check that discrete log compression batch size is greater than 0
2023-10-24 11:11:28 -07:00
samkim-crypto c3d588b3f1
[zk-token-sdk] clean-up range-proof docs (#33803)
* add/fix docs for range proof

* remove pre-compute generators todo

* remove double check generators todo
2023-10-24 07:53:48 -07:00
samkim-crypto dd2b1bb5a0
[zk-token-sdk] Limit max seed length for key derivations (#33700)
* limit max seed length for elgamal keypairs

* limit max seed length for authenticated encryption keys

* Apply suggestions from code review

Co-authored-by: Jon Cinque <me@jonc.dev>

* rename `SeedLengthTooLarge` to `SeedLengthTooLong`

---------

Co-authored-by: Jon Cinque <me@jonc.dev>
2023-10-20 13:02:37 -07:00
ripatel-fd fb80288f88
zk-token-sdk: Fix incorrect mention of OsRng in docs (#33774)
Co-authored-by: Richard Patel <ripatel@jumptrading.com>
2023-10-20 01:14:01 +02:00
samkim-crypto a4ceea32d7
[zk-token-sdk] Allow all zero auditor pubkey in proofs (#33106)
* allow auditor ElGamal public key to be all zero

* remove test components on all zero auditor ElGamal pubkey
2023-09-01 10:26:15 -07:00
Alexander Meißner 9e703f85de
Upgrades Rust to 1.72.0 & nightly-2023-08-25 (#32961)
* allow pedantic invalid cast lint

* allow lint with false-positive triggered by `test-case` crate

* nightly `fmt` correction

* adapt to rust layout changes

* remove dubious test

* Use transmute instead of pointer cast and de/ref when check_aligned is false.

* Renames clippy::integer_arithmetic to clippy::arithmetic_side_effects.

* bump rust nightly to 2023-08-25

* Upgrades Rust to 1.72.0

---------

Co-authored-by: Trent Nelson <trent@solana.com>
2023-09-01 07:26:13 +00:00
Jon Cinque 0fe902ced7
Bump rand to 0.8, rand_chacha to 0.3, getrandom to 0.2 (#32871)
* sdk: Add concurrent support for rand 0.7 and 0.8

* Update rand, rand_chacha, and getrandom versions

* Run command to replace `gen_range`

Run `git grep -l gen_range | xargs sed -i'' -e 's/gen_range(\(\S*\), /gen_range(\1../'

* sdk: Fix users of older `gen_range`

* Replace `hash::new_rand` with `hash::new_with_thread_rng`

Run:
```
git grep -l hash::new_rand | xargs sed -i'' -e 's/hash::new_rand([^)]*/hash::new_with_thread_rng(/'
```

* perf: Use `Keypair::new()` instead of `generate`

* Use older rand version in zk-token-sdk

* program-runtime: Inline random key generation

* bloom: Fix clippy warnings in tests

* streamer: Scope rng usage correctly

* perf: Fix clippy warning

* accounts-db: Map to char to generate a random string

* Remove `from_secret_key_bytes`, it's just `keypair_from_seed`

* ledger: Generate keypairs by hand

* ed25519-tests: Use new rand

* runtime: Use new rand in all tests

* gossip: Clean up clippy and inline keypair generators

* core: Inline keypair generation for tests

* Push sbf lockfile change

* sdk: Sort dependencies correctly

* Remove `hash::new_with_thread_rng`, use `Hash::new_unique()`

* Use Keypair::new where chacha isn't used

* sdk: Fix build by marking rand 0.7 optional

* Hardcode secret key length, add static assertion

* Unify `getrandom` crate usage to fix linking errors

* bloom: Fix tests that require a random hash

* Remove some dependencies, try to unify others

* Remove unnecessary uses of rand and rand_core

* Update lockfiles

* Add back some dependencies to reduce rebuilds

* Increase max rebuilds from 14 to 15

* frozen-abi: Remove `getrandom`

* Bump rebuilds to 17

* Remove getrandom from zk-token-proof
2023-08-21 19:11:21 +02:00
samkim-crypto 91186d3860
[zk-token-sdk] replace hard-coded constants with constant variables (#32274)
* add ristretto and scalar byte length constants

* add serialization and deserialization helper functions

* remove hard-coded constants in the `sigma` module

* remove hard-coded constants in the `encryption` module

* remove hard-coded constants in the `zk-token-elgamal` module

* Apply suggestions from code review

Co-authored-by: Tyera <tyera@solana.com>

* fix docs for range proof constants

* Apply suggestions from code review

Co-authored-by: Tyera <tyera@solana.com>

* clippy

---------

Co-authored-by: Tyera <tyera@solana.com>
2023-06-29 07:03:26 +09:00
samkim-crypto 5624aaa1e5
[zk-token-sdk](docs) Update docs to include a brief description of how fee sigma proof is computed (#32288)
* function docs to focus on the action they perform

* update docs for fee sigma proof

* add link to zk token proof doc

* Apply suggestions from code review

Co-authored-by: Tyera <tyera@solana.com>

---------

Co-authored-by: Tyera <tyera@solana.com>
2023-06-28 09:55:55 +09:00
samkim-crypto 4bc8f90182
[zk-token-sdk] Add fee sigma proof verification instruction (#32291)
* add fee sigma proof verification instruction

* update proof program processor for fee sigma proof

* update bench for fee sigma proof

* cargo fmt

* clippy

* fix target arch

* add comments to describe fee, delta, and claimed instruction data field
2023-06-28 09:49:56 +09:00
Tyera bde7c174b8
[zk-token-proof] Fix doc typo (#32270)
Fix doc typo
2023-06-24 15:24:22 -07:00
samkim-crypto 1452ed7044
[zk-token-sdk] Make `ElGamalKeypair` fields private (#32190)
* make `ElGamalKeypair` fields private

* update the rest of `zk-token-sdk` for the visibility update

* update `zk-token-proof-tests` for the visibility update

* update `zk-keygen` for the visibility update

* update `zk-token-proof` benches for the updated visibility

* cargo fmt

* rename `ElGamalKeypair::new` to `ElGamalKeypair::new_for_tests`
2023-06-22 10:28:13 +09:00
samkim-crypto 42aa5d243c
[zk-token-proof] Update docs for the ZK Token proof program in `zk-token-sdk` (#32186)
* add docs for the proof program instructions

* add docs for the zk token proof program

* add docs for the instruction data types

* add brief description of the proofs for each of the proof instructions

* Apply suggestions from code review

Co-authored-by: Tyera <teulberg@gmail.com>

* change `pubkey` or `public-key` in the docs to `public key`

---------

Co-authored-by: Tyera <teulberg@gmail.com>
2023-06-21 20:50:49 +09:00
samkim-crypto 1bc101252c
[zk-token-sdk] Use `TryFrom<&[T]>` for `&[T]` instead of `arrayref` (#31959)
* remove `arrayref` from `auth_encryption`

* remove `arrayref` from `sigma_proofs`

* refactor `canonical_scalar_from_slice`

* remove `arrayref` from `Cargo.toml`

* cargo lock
2023-06-21 06:14:18 +09:00