Repository navigation
Add SLH-DSA-SHA2-128s (post-quantum) signature support to v2 - #142
Open
gregnazario wants to merge 1 commit into
Open
gregnazario wants to merge 1 commit into
gregnazario wants to merge 1 commit into
Conversation
Mirror aptos-ts-sdk PR #802 (AIP-137): 32-byte public keys, 48-byte three-seeds private keys, 7,856-byte signatures, AnyPublicKey variant 5 / AnySignature variant 4, AIP-80 slh-dsa-sha2-128s-priv- strings, SingleKey address derivation, hardened SLIP-0010-style HD derivation, Account.generate_slh_dsa_sha2_128s and mnemonic derivation. Signing/verification use the optional pqcrypto dependency (pip install "aptos-sdk-v2[slh-dsa-sha2-128s]"); public-key derivation from the seed value is standard-library only, so key handling and BCS work without it. Mirrored to aptos_sdk/v2 per the sync check. Co-authored-by: greg <greg@gnazar.io>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #142 +/- ##
==========================================
+ Coverage 93.07% 93.34% +0.27%
==========================================
Files 56 57 +1
Lines 5239 5468 +229
==========================================
+ Hits 4876 5104 +228
- Misses 363 364 +1
🚀 New features to boost your workflow:
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds SLH-DSA-SHA2-128s (post-quantum, AIP-137) signature support to the v2 SDK (
aptos_sdk_v2, mirrored toaptos_sdk/v2), mirroring aptos-ts-sdk#802:crypto/slh_dsa_sha2_128s.py—SlhDsaSha2128sPrivateKey(48-byte three-seeds value, as in the TS SDK),SlhDsaSha2128sPublicKey(32 bytes),SlhDsaSha2128sSignature(7,856 bytes), with BCS (de)serialization,generate(),from_str/from_hex, and TS-compatiblefrom_derivation_path/from_derivation_path_inner.AnyPublicKeyvariant 5,AnySignaturevariant 4 (newAnySignatureVariant, also fixingAnySignaturepreviously reusingAnyPublicKeyVariant), AIP-80 prefixslh-dsa-sha2-128s-priv-(including a fix toparse_hex_inputso multi-hyphen prefixes parse), SingleKey authentication scheme (0x02) for address derivation.Account.generate_slh_dsa_sha2_128s(),Account.from_mnemonic(..., slh_dsa_sha2_128s=True),derive_slh_dsa_sha2_128s_private_key()(custom SLIP-0010"SLH-DSA-SHA2-128s seed"HMAC derivation, hardened-only), simulated signing support. Single-sender, multi-agent, and fee-payer flows work unchanged throughSingleKeyAuthenticator.pqcryptopackage (PQClean C bindings, abi3 wheels for Linux/macOS/Windows):pip install "aptos-sdk-v2[slh-dsa-sha2-128s]"(also declared on the root package for theaptos_sdk.v2mirror). This mirrors the TS SDK's optional@noble/post-quantum. Public-key derivation from the 48-byte seed (XMSS root, FIPS 205 SHA2 instantiation) is standard-library only, so key handling, BCS, and address derivation work without the optional dependency;sign/verifyraise an actionableImportErrorwhen it is missing. Alternatives considered:slh-dsa(pure-Python/mypyc; ~1.7s per signature and no seeded key generation) — used here as an independent cross-check implementation instead;cryptography/PyNaCl do not expose SLH-DSA.aptos_sdk.ed25519etc.) is intentionally unchanged; CHANGELOG, v2 README, and thedifferent_key_typesexample are updated.Test Plan
cd v2 && uv run pytest tests/unit -q— 457 passed (39 new intests/unit/test_slh_dsa_sha2_128s.py), including:hdKey.test.ts)pqcrypto/PQClean and the pure-Pythonslh-dsa): their signature verifies here and ours verifies therecd v2 && uv run ruff check src/ tests/anduv run mypy src/— clean; new modules at 99–100% coveragemake lintandmake test(unittest + behave, 248 scenarios) — pass;.github/scripts/check_v2_sync.sh— OKRelated Links