Commit Graph

171 Commits

Author SHA1 Message Date
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 c828031d9a
[zk-token-sdk] Fix ElGamal key derivation (#28792)
* fix ElGamal key derivation

* cargo fmt
2022-11-12 08:44:02 +09:00
Brooks Prumo d1ba42180d
clippy for rust 1.65.0 (#28765) 2022-11-09 19:39:38 +00:00
samkim-crypto 636baaf494
[zk-token-sdk] Update docs for encryption in zk-token-sdk (#28760)
clean up docs for encryption
2022-11-08 10:03:24 +00: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
samkim-crypto 3f63283eda
add curve25519 multiscalar multiplication syscall (#28216)
* add curve25519 multiscalar multiplication syscall

* update compute unit costs

* update tests

* add update to compute budget

* add syscall call function

* update compute costs in tests

* update syscall syntax
2022-10-12 14:43:02 +09:00
samkim-crypto bac6ebcd88
zk-token-sdk: update errors in comments (#27602)
update errors in comments
2022-09-15 17:11:14 +09:00
samkim-crypto bd88e2a11c
Zk token sdk/batch discrete log (#27412)
* zk-token-sdk: optimize discrete log search with batch compression

* zk-token-sdk: include batch size as part of discrete log struct

* zk-token-sdk: add a note on discrete log timings

* zk-token-sdk: add upper bound on the number of threads

* zk-token-sdk: minor

* zk-token-sdk: cargo.lock
2022-08-27 06:54:59 +09:00
samkim-crypto 4c944931c5
zk-token-sdk:add length checks (#27389)
* zk-token-sdk: add length check for ristretto encodings

* zk-token-sdk: add type check for sigma proofs
2022-08-25 14:22:52 +09:00
samkim-crypto 5e8b8abd84
zk-token-sdk: constant time equality check for elgamal and aes key derivation (#27364)
zk-token-sdk: use constant time equality check for elgamal and aes key derivation
2022-08-24 18:56:55 +09:00
samkim-crypto 0ea984ae20
zk-token-sdk: calculate transfer fee without conditional branch (#27356) 2022-08-24 17:29:23 +09:00
samkim-crypto 19fc4fcbf8
zk-token-sdk: use constant-time msm for inner product proof generation (#27355) 2022-08-24 14:56:21 +09:00
samkim-crypto 804dfe0f1a
zk-token-sdk: remove non-constant time assign for fee_proof transcript (#27354) 2022-08-24 14:25:09 +09:00
Brennan Watt e4a7d01e10
Rust v1.63 (#27303)
* Upgrade to Rust v1.63.0

* Add nightly_clippy_allows

* Resolve some new clippy nightly lints

* Increase QUIC packets completion timeout

* Update quinn-udp crate

Co-authored-by: Michael Vines <mvines@gmail.com>
2022-08-22 18:01:03 -07:00
Brennan Watt 7573000d87
Revert "Rust v1.63.0 (#27148)" (#27245)
This reverts commit a2e7bdf50a.
2022-08-19 09:19:44 +01:00
Brennan Watt a2e7bdf50a
Rust v1.63.0 (#27148)
* Upgrade to Rust v1.63.0

* Add nightly_clippy_allows

* Resolve some new clippy nightly lints

* Increase QUIC packets completion timeout

Co-authored-by: Michael Vines <mvines@gmail.com>
2022-08-17 15:48:33 -07:00
Tyera Eulberg 2114136e59
Add Display implementations for various ConfidentialTransfer pod structs (#26783) 2022-07-25 21:09:41 -06:00
samkim-crypto 700da0fc83
zk-token-sdk: implement Display for ciphertexts (#26755) 2022-07-23 21:59:40 +09:00
Michael Vines f3639b76ce Remove some clippy lints 2022-06-22 09:23:22 -07:00
Brian Anderson db9004bd0f
Fix doc warnings (#25953) 2022-06-14 21:55:08 -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
samkim-crypto 697a69cbe8
Add syscall tests for curve25519 (#25634)
* add curve25519 syscall tests

* add curve25519 syscall feature set description

* fmt

* rename curve25519 group syscall

* update point to scalar

* resolve conflict
2022-06-12 10:18:51 +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 aba6a89517
Curve25519 syscall group ops (#25071)
* zk-token-sdk: implement group ops trait for curve25519

* zk-token-sdk: extend syscall trait implementation for group ops for ristretto

* zk-token-sdk: register curve25519 group ops to bpf loader

* zk-token-sdk: update curve25519_syscall_enabled address
2022-05-08 11:28:07 +09:00
samkim-crypto d9deab4d2c
Curve25519 point validation syscall (#23771)
* zk-token-sdk: add curve25519 basic ops

* zk-token-sdk: add bpf operations for curve25519 ops

* zk-token-sdk: rebase

* zk-token-sdk: add tests for curve25519 opertions

* zk-token-sdk: rustfmt

* zk-token-sdk: organize syscalls by trait

* zk-token-sdk: organize syscalls by trait

* zk-token-sdk: cleaning up

* zk-token-sdk: rename mods

* zk-token-sdk: cargo fmt

* zk-token-sdk: fix tests for edwards and ristretto

* zk-token-sdk: add Syscall object for curve point validation

* zk-token-sdk: docs for curve syscall traits

* zk-token-sdk: fix errors from rebase

* zk-token-sdk: update Vec to slice

Co-authored-by: Trent Nelson <trent.a.b.nelson@gmail.com>

* zk-token-sdk: use enum with num-derive for curve ids

* zk-token-sdk: update vec to slice

* zk-token-sdk: make curve25519 tests be deterministic

* zk-token-sdk: rebase

* token-2022: re-organizing curve point validation

* token-2022: cargo fmt

* zk-token-sdk: minor

Co-authored-by: Trent Nelson <trent.a.b.nelson@gmail.com>
2022-05-07 16:20:53 +09:00
samkim-crypto b22abbce7d
Additional tests for proof verification when ElGamal pubkey is zeroed (#24243)
* zk-token-sdk: add edge case tests for withdraw withheld proof

* zk-token-sdk: add test cases for proof verification when pubkeys are invalid
2022-04-11 17:53:31 +01:00
samkim-crypto b2d502b461
zk-token-sdk: add support for scalar - ciphertext/commitment multiplication (#24120) 2022-04-09 14:19:29 +01:00
samkim-crypto ba92ba0e06
Zk instructions check length (#24103)
* zk-token-sdk: add a length check before decoding proof instruction

* zk-token-sdk: fix minor spelling

* zk-token-sdk: one-liner for length check

* zk-token-sdk: one-liner fix
2022-04-05 08:40:45 -04:00
samkim-crypto f1f8f5458d
Threads for discrete log (#23867)
* zk-token-sdk: add multi-thread for discrete log

* zk-token-sdk: some clean-up

* zk-token-sdk: change default discrete log thread to 1

* zk-token-sdk: allow discrete log thread nums to be chosen as param

* zk-token-sdk: join discrete log threads

* zk-token-sdk: join thread handles before returning

* zk-token-sdk: Apply suggestions from code review

Co-authored-by: Michael Vines <mvines@gmail.com>

* zk-token-sdk: update tests to use num_threads

* zk-token-sdk: simplify discrete log by removing mpsc and just using join

* zk-token-sdk: minor

Co-authored-by: Michael Vines <mvines@gmail.com>
2022-04-01 20:01:24 -04:00
samkim-crypto 10eeafd3d6
zk-token-sdk: handle edge cases for transfer with fee (#23804)
* zk-token-sdk: handle edge cases for transfer with fee

* zk-token-sdk: clippy

* zk-token-sdk: clippy

* zk-token-sdk: cargo fmt
2022-03-21 16:10:33 -04:00
samkim-crypto 4e02ec342c
zk-token-sdk: fixing a range proof edge case (#23605)
* zk-token-sdk: fixing a range proof edge case

* zk-token-sdk: clippy
2022-03-11 16:57:56 -05:00
samkim-crypto 08c9a650db
zk-token-sdk: generalize range proof (#23506)
* zk-token-sdk: update range proof in transfers for more flexible setting of params

* zk-token-sdk: clippy
2022-03-07 12:27:56 -05: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
Michael Vines 3ea9ca35fa grant public access to ProofError enum 2022-02-23 14:22:42 -08:00
Michael Vines 6872fc79ba
Derive Clone for AeCiphertext (#23293) 2022-02-22 22:47:26 -08:00
buffalu 70ebab2c82
Add rustfmt.toml and `cargo fmt` (#23238)
* fmt

* formatted

Co-authored-by: Lucas B <buffalu@jito.network>
2022-02-19 13:32:29 +08: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 a47b76afcc
zk-token-sdk: add verify transfer with fee instruction (#22924) 2022-02-04 08:52:49 -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
dependabot[bot] 66b44b48a4
chore: remove time dep (#22665)
* chore: bump time from 0.3.5 to 0.3.6

Bumps [time](https://github.com/time-rs/time) from 0.3.5 to 0.3.6.
- [Release notes](https://github.com/time-rs/time/releases)
- [Changelog](https://github.com/time-rs/time/blob/main/CHANGELOG.md)
- [Commits](https://github.com/time-rs/time/compare/v0.3.5...v0.3.6)

---
updated-dependencies:
- dependency-name: time
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* Remove separate time dependency

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Tyera Eulberg <tyera@solana.com>
2022-01-25 16:30:21 -07: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