feat: add signing, totp & raw-mode AEAD/KDF/HMAC primitives (Phase 5)#2
Merged
Conversation
…rypto extraction Phase 5 of the Singra->DIS crypto extraction needs the non-encryption primitives that Vault/Premium still call directly: - signing (ECDSA P-256, SHA-256): op-log device signatures; raw r||s 64-byte wire form, SPKI public keys, non-extractable private keys. - totp (RFC 6238 via otpauth): SHA1/6-digit/30s pinned to enrolled secrets. - integrity: sha256Bytes/Base64Url/Hex, sha1Hex (HIBP interop only), hmacSha256(+WithKey/importKey). - kdf: argon2idRaw (ad-hoc params/salt), deriveHkdfSha256Bits, deriveHkdfAesGcmKey. - aead: raw-mode aesGcmEncrypt/Decrypt (caller nonce, binary AAD, ct||tag), importAesGcmRawKey, generateAesGcmKey. - random: randomInt (rejection-sampled, bias-free), fillRandom. - core/encoding: bytesToBase64Url/base64UrlToBytes/bytesToHex. New subpath exports @dis/shield/signing and /totp; barrel re-exports added. +30 tests (KAT vectors: SHA-256/SHA-1 abc, RFC 4231 HMAC; otpauth interop; randomInt range/coverage; raw-AEAD AAD binding & tamper). 96 tests green, typecheck/lint/build green. Co-Authored-By: Gaming Gruppe <einmalmaik@gmail.com>
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
devin-ai-integration
Bot
changed the base branch from
devin/1780259862-dis-foundation
to
main
June 9, 2026 12:46
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.
Summary
Phase 5 of the Singra → DIS crypto extraction. Phases 0–4 moved all data encryption (vault, PQ, file/attachment) into
@dis/shield. This adds the remaining non-encryption primitives that Vault & Premium still call directly (op-log signing/hashing, auth, integrity HMAC, device-key/passkey KDF, secure random, TOTP) so both apps can drop every directcrypto.subtle/hash-wasmcall. Wire formats are pinned byte-for-byte so no stored data migrates.New subpath exports
@dis/shield/signingand@dis/shield/totp; existing/integrity,/kdf,/aead,/randomand/coregain helpers. Barrel (@dis/shield) re-exports all of them.New surfaces:
sha1Hexis documented as legacy-interop-only (HaveIBeenPwned k-anonymity); the SHA-1 inside TOTP is the standard RFC-6238 HMAC. Raw-mode AEAD exists because op-log records/snapshots store nonce and ciphertext as separate fields and bind binary AAD, unlike the high-levelbase64(IV||ct)helpers.Tests
+30 tests (96 total, all green; typecheck/lint/build green). Known-answer vectors: SHA-256/SHA-1 of
"abc", RFC 4231 HMAC case 1; otpauth round-trip interop;randomIntrange + full-coverage + bias bounds; raw-AEAD AAD-binding and tamper rejection; ECDSA tamper/wrong-key/bad-length rejection; Argon2id & HKDF determinism + salt-sensitivity.Link to Devin session: https://app.devin.ai/sessions/24b35de4890f41edb8a0250d5f4aba7c
Requested by: @einmalmaik