
Security News
Anthropic Identifies Biased Reasoning and Recklessness as Drivers of Claude’s PyPI Attack
Anthropic found biased reasoning and recklessness drove Claude Mythos 5 to publish malware on PyPI and compromise a security vendor.
@turnkey/crypto
Advanced tools
This package consolidates some common cryptographic utilities used across our applications, particularly primitives related to keys, encryption, and decryption in a pure JS implementation. For react-native you will need to polyfill our random byte generation by importing react-native-get-random-values
Example usage (Hpke E2E):
const senderKeyPair = generateP256KeyPair();
const receiverKeyPair = generateP256KeyPair();
const receiverPublicKeyUncompressed = uncompressRawPublicKey(
uint8ArrayFromHexString(receiverKeyPair.publicKey),
);
const plainText = "Hello, this is a secure message!";
const plainTextBuf = textEncoder.encode(plainText);
const encryptedData = hpkeEncrypt({
plainTextBuf: plainTextBuf,
encappedKeyBuf: receiverPublicKeyUncompressed,
senderPriv: senderKeyPair.privateKey,
});
// Extract the encapsulated key buffer and the ciphertext
const encappedKeyBuf = encryptedData.slice(0, 33);
const ciphertextBuf = encryptedData.slice(33);
const decryptedData = hpkeDecrypt({
ciphertextBuf,
encappedKeyBuf: uncompressRawPublicKey(encappedKeyBuf),
receiverPriv: receiverKeyPair.privateKey,
});
// Convert decrypted data back to string
const decryptedText = new TextDecoder().decode(decryptedData);
Use @turnkey/crypto directly when you want to manage verification-key fetching and caching yourself. Verification must use the exact raw request body bytes that Turnkey sent, the Turnkey signature headers, Turnkey webhook verification keys, and an explicit maxTimestampAgeMs replay window.
Turnkey sends these signature headers with the body: x-turnkey-timestamp, x-turnkey-event-id, x-turnkey-signature-key-id, x-turnkey-signature-algorithm, x-turnkey-signature-version, and x-turnkey-signature. Pass the complete headers object through as received.
x-turnkey-event-id is stable across retry attempts for the same webhook event. Use it as the deduplication or idempotency key after signature verification succeeds.
import { verifyTurnkeyWebhookSignature } from "@turnkey/crypto";
const body = req.body; // Buffer from express.raw(), not parsed JSON
const verificationKeys = [
{
keyId: process.env.TURNKEY_WEBHOOK_KEY_ID!,
publicKey: process.env.TURNKEY_WEBHOOK_PUBLIC_KEY!, // Hex-encoded Ed25519 public key
algorithm: "ed25519",
},
];
const result = verifyTurnkeyWebhookSignature({
headers: req.headers,
body,
verificationKeys,
maxTimestampAgeMs: 5 * 60 * 1000,
});
if (!result.ok) {
throw new Error(`Invalid Turnkey webhook: ${result.reason}`);
}
const event = JSON.parse(body.toString("utf8"));
Do not verify a parsed and re-stringified JSON object. Even harmless-looking changes to whitespace or key ordering will change the signed payload.
FAQs
Encryption, decryption, and key related utility functions
The npm package @turnkey/crypto receives a total of 130,522 weekly downloads. As such, @turnkey/crypto popularity was classified as popular.
We found that @turnkey/crypto demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.

Security News
Anthropic found biased reasoning and recklessness drove Claude Mythos 5 to publish malware on PyPI and compromise a security vendor.

Research
/Security News
Malicious Chrome and Firefox extensions target Axiom Trade and Padre users, stealing session tokens and wallet data.

Security News
GPT-6 Astra hits 100% on ExploitBench and finds zero-days autonomously, while independent tests reveal scope violations and monitoring gaps.