Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ON HOLD] wip: Reference implementation of message encryption #1127

Draft
wants to merge 3 commits into
base: feature/transaction-messages
Choose a base branch
from

Conversation

dhedey
Copy link
Contributor

@dhedey dhedey commented Jun 19, 2023

Summary

Work in progress implementation of message encryption - currently only working for Curve25519.

Details

Still to-do:

  • There is a version clash where curve25519-dalek 3.x requires zeroize version = ">=1, <1.4": https://github.com/dalek-cryptography/curve25519-dalek/blob/3.2.1/Cargo.toml BUT other crypto libraries such as https://github.com/RustCrypto/elliptic-curves/blob/master/k256/Cargo.toml require later versions. As they're both on major version 1.x, Cargo just errors. Instead, I suggest we get rid of x25519_dalek (as it's really not adding much) and update to curve25519-dalek v4 for this which has a more sane feature/dependency list.
  • Implement Secp256k1 handling when the above zeroize issue is resolved - possibly with k256 = { version = "0.13.1", default-features = false, features= ["arithmetic", "ecdh", "alloc"], optional = true } (although that might only support ECDH not static DH, so will need some investigation)
  • Ensure the test vectors align with other implementations
  • Better handling of zeroizing private keys

Testing

More to come:

  • Secp256k1 impl and testing
  • Test vectors

Update Recommendations

For dApp Developers

N/A

For Internal Integrators

Toolkit

When ready, can be used by the toolkit to implement message encryption as part of intent construction -- assuming OsRng is exposed the toolkit appropriately in the given runtime. (EG it might error in WASM unless a secure RNG is linked in, which depends on how the WASM is run).

@github-actions
Copy link

github-actions bot commented Jun 19, 2023

Benchmark for 66f75f2

Click to view benchmark
Test Base PR %
Decimal::add/0 2.8±0.04ns 2.8±0.04ns 0.00%
Decimal::div/0 222.0±0.68ns 220.1±0.40ns -0.86%
Decimal::from_string/0 261.1±0.70ns 265.1±2.31ns +1.53%
Decimal::mul/0 182.0±0.34ns 180.9±0.70ns -0.60%
Decimal::pow/0 919.2±1.55ns 914.9±6.60ns -0.47%
Decimal::root/0 12.2±0.05µs 12.2±0.26µs 0.00%
Decimal::sub/0 0.7±0.03ns 0.7±0.01ns 0.00%
Decimal::to_string/0 604.5±1.33ns 614.1±2.60ns +1.59%
Decompile Intent Natively/Prepare NotarizedTransaction 2.3±0.01ms 2.3±0.01ms 0.00%
Decompile Intent Natively/Prepare NotarizedTransaction and Decompile 6.9±0.15ms 6.9±0.02ms 0.00%
Decompile Intent Natively/Prepare NotarizedTransaction, Decompile, then Recompile 27.1±0.97ms 25.8±0.07ms -4.80%
PreciseDecimal::add/0 7.6±0.06ns 7.6±0.63ns 0.00%
PreciseDecimal::div/0 705.4±1.97ns 705.1±4.27ns -0.04%
PreciseDecimal::from_string/0 632.2±1.50ns 634.4±2.40ns +0.35%
PreciseDecimal::mul/0 705.5±2.55ns 711.1±1.53ns +0.79%
PreciseDecimal::pow/0 3.7±0.03µs 3.7±0.08µs 0.00%
PreciseDecimal::root/0 95.7±0.56µs 96.4±0.20µs +0.73%
PreciseDecimal::sub/0 7.2±0.01ns 7.3±0.49ns +1.39%
PreciseDecimal::to_string/0 1511.8±5.69ns 1528.9±92.86ns +1.13%
Radiswap::run 3.9±0.02ms 3.9±0.02ms 0.00%
Schema::validate_payload 251.9±1.20µs 250.1±0.89µs -0.71%
SpinLoop::run 161.1±4.00ms 156.5±1.07ms -2.86%
Transfer::run 1552.8±6.31µs 1543.9±28.80µs -0.57%
Validation::validate_manifest 46.2±0.11µs 46.3±0.27µs +0.22%
Validation::verify_ecdsa 82.2±0.19µs 82.2±0.20µs 0.00%
Validation::verify_ed25519 51.9±0.22µs 51.8±0.34µs -0.19%
WASM::instantiate_wasm 3.1±0.20ms 3.0±0.02ms -3.23%
WASM::instantiate_wasm_preloaded 76.3±0.16µs 77.4±0.11µs +1.44%
WASM::validate_wasm 15.8±0.08ms 15.9±0.40ms +0.63%

@dhedey dhedey changed the title wip: Reference implementation of message encryption [ON HOLD] wip: Reference implementation of message encryption Jun 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant