Audit scope: every site in libs/aje/, libs/aphrodite/, libs/airmid/,
libs/iris/memory/privacy/, libs/iris/a2a/, and
libs/iris/privacy/security/dlp/ where the source code marks itself as a
non-real cryptographic operation: // would use crypto, // would use AES-GCM,
// would use keccak256, simulated* helpers, simpleHash, Math.random()-
shaped hashes/signatures, and similar placeholder patterns.
Replacement target: every entry below resolves to a primitive in
@oshun/crypto (the OshunCryptoSuite introduced by V1-P2-0173, plus the
OshunSigningKeystore from V1-P2-0174). Resolution policy:
| placeholder pattern | replace with |
|---|---|
simpleHash(input: string) → number/string |
keccak256 (eth path) / sha256 (non-eth) |
simulatedKeccak256(...) |
keccak256(...) from @oshun/crypto |
simulatedSign(digest, priv) |
secp256k1Sign(digest, priv) (eth/btc) / keystore |
simulatedRecover(digest, sig) |
secp256k1Recover + keccak256 for address |
| "would use crypto.subtle.digest('SHA-256')" | sha256 from @oshun/crypto |
| "would use AES-256-GCM" / XOR placeholder | aesGcmEncrypt / aesGcmDecrypt |
| "would use ECDSA / Schnorr to sign" | secp256k1Sign / Bitcoin Schnorr (@scure/btc-signer) |
Math.random().toString(16) for hash/sig |
randomBytes(32) for material; |
| recompute the actual hash from inputs | |
| simulated threshold encryption | aesGcmEncrypt + Shamir over secp256k1Ecdh |
Each entry below is a discrete checklist item. When a site has been remediated,
flip its checkbox to [x] and reference the commit that replaced it.
1. Explicit "would use ..." comments#
Comment-marked placeholders that name the missing primitive directly. These are the highest-priority remediations because the comment is a contract: the production behaviour is not what the code currently does.
1.1 libs/aje/#
-
libs/aje/defi/src/safety/cow-protocol.ts:86— "Simplified hash representation (actual implementation would use keccak256)". Replace withkeccak256(utf8Encode(payload))from@oshun/cryptoand remove the legacysimpleHash/string concat shortcut. -
libs/aje/wallets/src/social-login/recovery.ts:439— "XOR encryption (simplified; real implementation would use AES-256-GCM)". Replace withaesGcmEncrypt(key, plaintext, nonce, aad)from@oshun/crypto. Persist the 12-byte nonce alongside the ciphertext; do not reuse across recovery shares. -
libs/aje/bridges/src/custom-bridge/bridges.ts:215— "In production, this would use keccak256 and RLP encoding." Replace the message hash derivation withkeccak256(rlpEncode(...)). RLP via@scure/rlpif not already available; the keccak primitive is@oshun/crypto. -
libs/aje/bitcoin/src/bitvm/operators.ts:415— "Simplified signing (real implementation would use ECDSA)". Replace withsecp256k1Sign(messageHash, privateKey)and route private-key access throughOshunSigningKeystore. -
libs/aje/bitcoin/src/bitvm/scripts.ts:434— "Simplified: real implementation would use secp256k1 point addition". Replace with proper curve point addition (@noble/curves/secp256k1Point.add). -
libs/aje/bitcoin/src/lightning/routing.ts:372— "In a real implementation, this would use crypto.createHash('sha256')". Replace withsha256(buf)from@oshun/crypto. -
libs/aje/bitcoin/src/lsp/protocol.ts:332— "In real implementation, would use secp256k1 signing". Replace placeholder withsecp256k1Sign(hash, key)(or, when the operator is remote,OshunSigningKeystore.sign). -
libs/aje/bitcoin/src/lsp/protocol.ts:375— "In real implementation, would use secp256k1 verification". Replace withsecp256k1Verify(sig, hash, pubkey). -
libs/aje/bitcoin/src/rgb/validation.ts:89— "In real implementation, would use cryptographic commitment scheme". Replace placeholder commitment with a Pedersen commitment over secp256k1 (secp256k1Ecdh+keccak256for the binding nonce) or, simpler,keccak256(value || blindingFactor)if hiding-binding is sufficient. -
libs/aje/bitcoin/src/shared/psbt.ts:188— "SHA-256 hash (placeholder - in real implementation would use crypto)". Replace withsha256. -
libs/aje/bitcoin/src/shared/psbt.ts:191— "In a real implementation, this would use crypto.subtle.digest or a library". Same site — replace the inline implementation entirely withsha256(buf). -
libs/aje/bitcoin/src/shared/psbt.ts:542— "In a real implementation, this would use ECDSA or Schnorr to sign". Replace withsecp256k1Sign(for ECDSA) or Schnorr via@scure/btc-signer. -
libs/aje/nodes/src/rpc/alchemy.ts:378— "In a real implementation this would use crypto, but since we need…". Replace the deterministic pseudo-random fallback withrandomBytesfor nonces andkeccak256for derived ids.
1.2 libs/airmid/#
-
libs/airmid/clinical/src/audit-compliance.ts:209— "In production, this would use crypto.subtle.digest('SHA-256', …) but…". Replace withsha256from@oshun/crypto. Audit-log integrity hashes cannot besimpleHash— clinical compliance contracts assume cryptographic collision resistance.
1.3 libs/iris/memory/privacy/#
-
libs/iris/memory/privacy/src/encryption/zero-knowledge.ts:52— "Real ZK proofs would use cryptographic circuits." This is correct as a pre-condition comment but the body of theprovefunction should at minimum sign the public inputs withOshunSigningKeystoreso a non-ZK proof is at least attested. Track replacement when a real ZK backend (circom/halo2/risc0) is wired in.
1.4 libs/iris/a2a/#
-
libs/iris/a2a/src/agent-card.ts:352— "Verify an agent card signature (placeholder - actual implementation would use crypto)". Replace withed25519Verify(A2A canonical algorithm) over the canonical-JSON-encoded agent card. -
libs/iris/a2a/src/agent-card.ts:365— "Check signature presence (actual verification would use cryptographic methods)". Same site — remove the presence-only check and called25519Verify.
1.5 libs/aphrodite/, libs/iris/privacy/security/dlp/#
No "would use ..." comments under these directories at audit time (grep returns zero hits). Re-run the scan after large merges before declaring this section complete.
2. simulated* crypto helpers#
libs/aje/sdk/src/core/signer.ts defines a hand-written simulatedKeccak256
and simulatedSign/simulatedRecover. These functions are deterministic —
they return reproducible bytes — but they are not collision-resistant keccak and
not ECDSA. Every callsite is a stub.
2.1 Helper definitions#
-
libs/aje/sdk/src/core/signer.ts:86—simulatedKeccak256definition. Replace the function body with a thin wrapper aroundkeccak256from@oshun/crypto. After the replacement the function name should be deleted and callers updated. -
libs/aje/sdk/src/core/signer.ts:197—simulatedSign. Replace body withsecp256k1Sign(digest, privateKeyBytes)(and surface the recovery id from the result). Delete the helper after callers migrate. -
libs/aje/sdk/src/core/signer.ts:742—simulatedRecover. Replace withsecp256k1Recover(sig, digest)+keccak256(uncompressedPub) → last 20 bytesfor the Ethereum address. -
libs/aje/sdk/src/core/contracts.ts:132— duplicatesimulatedKeccak256. Replace with import from@oshun/crypto. -
libs/aje/sdk/src/core/events.ts:126— duplicatesimulatedKeccak256. Replace with import. -
libs/aje/sdk/src/core/factories.ts:130— duplicatesimulatedKeccak256. Replace with import. -
libs/aje/security/src/mev-protection/encryption.ts:455— "Encrypt data using a simulated threshold encryption scheme." Replace with a realt-of-nAES-GCM scheme: derive per-share keys viasecp256k1Ecdh+hkdf, split via Shamir over the secp256k1 scalar field, encrypt withaesGcmEncrypt. Until a real implementation lands, gate the export so production code paths cannot accidentally rely on it.
2.2 Helper callsites in libs/aje/sdk/src/core/signer.ts#
After 2.1 lands, every call below disappears. They are listed here so the audit can tick them off as the helpers are deleted.
-
libs/aje/sdk/src/core/signer.ts:158—simulatedKeccak256(privateKeyBytes)(inderiveAddress). -
libs/aje/sdk/src/core/signer.ts:170—simulatedKeccak256(combined) -
libs/aje/sdk/src/core/signer.ts:186—simulatedKeccak256(pubKey) -
libs/aje/sdk/src/core/signer.ts:202—simulatedKeccak256(rInput) -
libs/aje/sdk/src/core/signer.ts:209—simulatedKeccak256(sInput) -
libs/aje/sdk/src/core/signer.ts:265—simulatedKeccak256(combined) -
libs/aje/sdk/src/core/signer.ts:324—simulatedKeccak256(stringToBytes(encoded)) -
libs/aje/sdk/src/core/signer.ts:346—simulatedKeccak256(stringToBytes(...)) -
libs/aje/sdk/src/core/signer.ts:349—simulatedKeccak256(bytesVal) -
libs/aje/sdk/src/core/signer.ts:353—simulatedKeccak256(nested) -
libs/aje/sdk/src/core/signer.ts:373—simulatedKeccak256(stringToBytes(...)) -
libs/aje/sdk/src/core/signer.ts:433—simulatedKeccak256(encodeDomainSeparator) -
libs/aje/sdk/src/core/signer.ts:434—simulatedKeccak256(encodeStructData) -
libs/aje/sdk/src/core/signer.ts:442—simulatedKeccak256(combined) -
libs/aje/sdk/src/core/signer.ts:656—simulatedKeccak256(combined) -
libs/aje/sdk/src/core/signer.ts:663—simulatedKeccak256(reversed) -
libs/aje/sdk/src/core/signer.ts:712—simulatedKeccak256(hmacInput)→ Replace withhmacSha256(key, message)(the helper is mis-named — it's an HMAC, not keccak). -
libs/aje/sdk/src/core/signer.ts:718—simulatedKeccak256(ccInput) -
libs/aje/sdk/src/core/signer.ts:755—simulatedKeccak256(combined) -
libs/aje/sdk/src/core/signer.ts:760—simulatedKeccak256(reversed) -
libs/aje/sdk/src/core/signer.ts:766—simulatedKeccak256(fullPub) -
libs/aje/sdk/src/core/signer.ts:840—simulatedSign(digest, …)(legacy tx signing). -
libs/aje/sdk/src/core/signer.ts:856—simulatedSign(digest, …)(EIP-1559 signing). -
libs/aje/sdk/src/core/signer.ts:862—simulatedKeccak256(unsignedRlp) -
libs/aje/sdk/src/core/signer.ts:863—simulatedSign(digest, …)(EIP-2930 signing). -
libs/aje/sdk/src/core/signer.ts:1108—simulatedKeccak256(keyIdBytes) -
libs/aje/sdk/src/core/signer.ts:1115—simulatedSign(digest, …)(KMS-backed signer fallback). After replacement this call should route throughOshunSigningKeystore.signinstead of generating a pseudo-private-key locally. -
libs/aje/sdk/src/core/signer.ts:1148—simulatedKeccak256(unsignedRlp) -
libs/aje/sdk/src/core/signer.ts:1190—simulatedRecover(digest, sig)
2.3 Helper callsites in libs/aje/sdk/src/core/{contracts,events,factories}.ts#
-
libs/aje/sdk/src/core/contracts.ts:164—simulatedKeccak256(stringToBytes(str))(selector / event topic derivation). Real keccak required. -
libs/aje/sdk/src/core/events.ts:158—simulatedKeccak256(stringToBytes(str))(event topic). -
libs/aje/sdk/src/core/events.ts:163—simulatedKeccak256(data) -
libs/aje/sdk/src/core/factories.ts:162—simulatedKeccak256(stringToBytes(str))
3. simpleHash — non-cryptographic hash used in security paths#
simpleHash is a 32-bit FNV-style or polynomial hash defined separately in many
files. It is fine for cache-keying but not acceptable for: tx hashes,
addresses, public-key fingerprints, audit log digests, or any value that will be
persisted, displayed as 0x…, or compared cryptographically. Each file defining
simpleHash is listed first; remediating the definition removes the entire
downstream callsite cluster.
3.1 simpleHash definitions#
-
libs/aje/sui-move/src/aptos/aptos.ts:112— replace withsha256(Aptos uses SHA-3-256 / SHA-2-256 in its native crypto — adoptkeccak256for tx digests andsha256for non-tx hashes). -
libs/aje/sui-move/src/move-language/move-language.ts:84— replace withsha256(Move bytecode digests are cryptographic). -
libs/aje/sui-move/src/sui-network/sui-network.ts:89— replace withsha256(Sui uses Blake2b for tx digests;blake3(buf, 32)from@oshun/cryptois the closest acceptable substitute). -
libs/aje/agents/src/safety/safety.ts—simpleHash(entryData)at L1043. Audit-log entries are subject to tamper-evidence contracts; replace withsha256and chain via prior-hash field. -
libs/aje/agents/src/ai/ai.ts— 13 callsites (lines 254, 256, 286, 289, 320, 386, 412, 580, 619, 659, 769, 770, 771, 806, 807, 838, 896, 914, 921, 942, …). All represent tx hashes / model hashes / ZK proof hashes; replace withsha256(zk-AI proofs typically commit via Poseidon, butsha256is a strict-better stand-in until a real proving backend is wired up). -
libs/aje/agents/src/communication/communication.ts— replace withsha256. -
libs/aje/agents/src/frameworks/frameworks.ts— replace withsha256. -
libs/aje/agents/src/wallets/wallets.ts— replace withkeccak256(these are EOA address derivations). -
libs/aje/agents/src/x402/x402.ts— replace withsha256(HTTP payment header hashes). -
libs/aje/account-abstraction/src/advanced-aa/advanced-aa.ts— replace withkeccak256(UserOperation hashing). -
libs/aje/account-abstraction/src/eip7702/eip7702.ts— replace withkeccak256(EIP-7702 authorization tuple hashing). -
libs/aje/account-abstraction/src/erc6900/erc6900.ts— replace withkeccak256. -
libs/aje/appchains/src/altlayer/altlayer.ts— replace withkeccak256. -
libs/aje/appchains/src/config/config.ts— replace withkeccak256(precompile output digest). -
libs/aje/appchains/src/da/da.ts— replace withsha256(data availability commitments). -
libs/aje/chains/src/abstraction/address-resolver.ts— replace withkeccak256. -
libs/aje/depin/src/iot/iot.ts— replace withsha256(device attestation digest). -
libs/aje/gaming/src/mud/mud.ts— replace withkeccak256(MUD Store record key hashing). -
libs/aje/privacy/src/advanced-privacy/advanced-privacy.ts— replace withkeccak256. -
libs/aje/privacy/src/privacy-pools/privacy-pools.ts— replace withkeccak256(ASP commitment). -
libs/aje/restaking/src/avs/avs.ts— replace withkeccak256(operator set digest). -
libs/aje/restaking/src/eigenlayer/eigenlayer.ts— replace withkeccak256. -
libs/aje/security/src/audit-tooling/analysis.ts— replace withsha256(analysis report digest). -
libs/aphrodite/payments/src/processors/index.ts:300— replace privatesimpleHashwithsha256(PCI-tokenisation surrogate identifiers must be cryptographic). -
libs/aphrodite/property/src/property-engine.ts:2219— replace withsha256. -
libs/aphrodite/safety-intelligence/src/safety-engine.ts:399— replace withsha256. -
libs/aphrodite/agent-platform/src/data/security.ts:44— replace withsha256(DLP redaction codes; the[HASH:…]placeholder must be a one-way function). -
libs/airmid/api/src/api-documentation.ts:332— replace withsha256. -
libs/airmid/docking/src/qsar-modeling.ts:275— for QSAR molecular fingerprintssimpleHashis acceptable (this is not a security primitive); leave but rename topolynomialHashso future audits don't flag it.
3.2 simpleHash call clusters#
After every definition in §3.1 is replaced by an import from @oshun/crypto,
the 325 callsite count drops to zero by construction. The audit can tick these
en bloc:
-
libs/aje/sui-move/src/aptos/aptos.ts— 14 callsites at L276, 376, 377, 378, 494, 495, 496, 505, 532, 551, 1890, 1913, 1914, 2316, 2385, 2386. -
libs/aje/sui-move/src/move-language/move-language.ts— 7 callsites at L191, 455, 456, 461, 477, 494. -
libs/aje/sui-move/src/sui-network/sui-network.ts— 4 callsites at L478, 1099, 1443, 1529. -
libs/aje/agents/src/ai/ai.ts— 25+ callsites; verify everytxHash/inputHash/outputHash/modelHash/circuitHash/srsHash/proofData/instanceData/contractAddris using the cryptographic replacement. - All other
libs/aje/agents/,libs/aje/account-abstraction/,libs/aje/appchains/,libs/aje/chains/,libs/aje/depin/,libs/aje/gaming/,libs/aje/privacy/,libs/aje/restaking/,libs/aje/security/files listed in §3.1 — replace every remainingsimpleHash(callsite once the definition is gone. -
libs/aphrodite/payments/,libs/aphrodite/property/,libs/aphrodite/safety-intelligence/,libs/aphrodite/agent-platform/— same. -
libs/airmid/api/,libs/airmid/docking/— same.
4. Math.random()-shaped hashes / signatures / addresses#
These are non-deterministic placeholders that masquerade as cryptographic outputs. They are catastrophic in any code path that treats the result as a commitment, signature, or unique identifier.
-
libs/aje/predictions/src/oracles/oracles.ts:517—historyHash: '0x' + Math.random().toString(16).slice(2, 66). Replace with'0x' + bytesToHex(keccak256(historyBuffer)). -
libs/aje/security/src/static-analysis/reporting.ts:1115— hex generator usingMath.random(). Replace withrandomBytes(N)then hex-encode. -
libs/aje/gaming/src/gaming-l2s/gaming-l2s.ts:98—TxHashmock. Replace withkeccak256over the actual unsigned tx. -
libs/aje/gaming/src/gaming-l2s/gaming-l2s.ts:101—Addressmock. Replace withkeccak256(pubkey).slice(-20)for an EOA. -
libs/aje/gaming/src/economy/economy.ts:105—TxHashmock, same fix. -
libs/aje/gaming/src/assets/assets.ts:108—TxHashmock, same fix. -
libs/aje/gaming/src/autonomous/autonomous.ts:147—TxHashmock, same fix. -
libs/aje/bitcoin/src/lightning/swaps.ts:437,476— placeholder signatures and hex strings for Lightning swaps. Replace withsecp256k1Sign(signature) andrandomBytesfor nonces. -
libs/aje/bitcoin/src/lightning/invoices.ts:542— invoice payment-hash hex viaMath.random(). Replace withrandomBytes(32)preimage thensha256(preimage)for the actual payment hash. -
libs/aje/bitcoin/src/ln-apps/wallets.ts:246,358,368,381— placeholder signature blobs. Replace withsecp256k1Signover the LN message hash. -
libs/aje/chains/src/solana/transaction.ts:468,747—sigPlaceholders = new Uint8Array(numSignatures * 64). These are zeroed signature buffers. Replace withed25519Signagainst the keystore-held key for each signer slot. -
libs/aje/chains/src/zksync/account-abstraction.ts:347— "we use a placeholder that represents the bytecode hash". Replace with the actual zkSync bytecode hash routine (keccak256(bytecode)truncated to 32 bytes with the version byte prefix). -
libs/aje/chains/src/abstraction/unified-provider.ts:497— "as a placeholder since we don't have the signing key". Route the call throughOshunSigningKeystore.sign(keyId, message). -
libs/aje/bitcoin/src/stacks/wallets.ts:263— "placeholder that returns a dummy 20-byte hash". Replace withsha256(pubkey).slice(0, 20)for Stacks address derivation.
5. Summary statistics#
| directory | "would use ..." | simulated* |
simpleHash |
Math.random mock |
total |
|---|---|---|---|---|---|
libs/aje/ |
13 | 42 | ~280 | 18 | ~353 |
libs/aphrodite/ |
0 | 0 | 13 | 0 | 13 |
libs/airmid/ |
1 | 0 | 7 | 0 | 8 |
libs/iris/memory/privacy/ |
1 | 0 | 0 | 0 | 1 |
libs/iris/a2a/ |
2 | 0 | 0 | 0 | 2 |
libs/iris/privacy/security/dlp/ |
0 | 0 | 0 | 0 | 0 |
| total | 17 | 42 | ~300 | 18 | ~377 |
Counts exclude node_modules, *.spec.ts, and *.test.ts. The simpleHash
total is reported as ~300 because some callsites are inside template-string
expressions where the same line uses the helper multiple times — the
authoritative count is the union of the file paths in §3.1, which after
remediation will eliminate every occurrence by deletion of the helper.
6. Remediation policy#
- Replace the definition first, then the callsites. Because every library
has its own
simpleHash/simulatedKeccak256, deleting the definition forces every caller in the file to migrate via a singleimportchange. This is faster and less error-prone than touching the call list directly. - Replace eth-shaped hashes with
keccak256, others withsha256. Use the table at the top of this document. Anything that lands on the EVM as a hash (tx hash, EIP-712 digest, mapping key, event topic,keccak256(rlp(…))) must bekeccak256. Cross-chain or non-EVM digests (Stacks, Aptos, Sui, off-chain audit logs) usesha256unless the chain spec mandates a different primitive. - Route signing through
OshunSigningKeystore. For private-key operations (simulatedSign, "would use ECDSA"), the in-process key was already a placeholder; production code must store keys in a KMS. The replacement iskeystore.sign(keyId, message), not a directsecp256k1Sign(message, privateKey)call. Use the noble primitives only in test code that owns the bytes. - Use real randomness.
Math.random()for any byte that becomes a commitment, nonce, payment hash, address, or signature is a bug. Replace withrandomBytes(N)from@oshun/crypto. - Remove the comment after the fix. A
// would use keccak256comment that survives the replacement is misleading — delete it when the underlying call is migrated.
When every checkbox above is [x], file V1-P2-0176 can be marked complete in
OSHUN_V1_TODOS_P2.md. Until then, the backlog of placeholder cryptography is
the source of truth and any new code that introduces additional
simpleHash/simulated* callers must be rejected at review.