Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
dead simple crypto functions for fognet
phog uses the Web Crypto API and base 58 encoding
open test.html in any browser to test
const configs = {
sign: {
algo: {name: 'ECDSA', namedCurve: 'P-256'},
usage: ['sign', 'verify'],
export: {public:'spki', private:'pkcs8'}
},
derive: {
algo: {name:'ECDH', namedCurve:'P-256'},
usage: ['deriveKey'],
export: {public:'spki', private:'pkcs8'}
},
encrypt: {
algo: {name:'AES-GCM', length: 256},
usage: ['encrypt', 'decrypt'],
export: {public:'raw', private:'raw'},
ivFunc: () => window.crypto.getRandomValues(new Uint8Array(12))
}
}
Generate a key (returns a CryptoKey pair)
const key = await phog.keyGen(phog.configs.sign) // for signing
const key = await phog.keyGen(phog.configs.derive) // for deriving shared keys
// returns { publicKey:CryptoKey{}, privateKey:CryptoKey{} }
Sign some text (returns base58-encoded signature string)
const sig = await phog.sign(txt, key.privateKey)
Verify a signature (returns a bool)
const verified = await phog.verify(txt, sig, importedPubKey)
Derive a shared symmetric key from your private key and another person's public key. (returns a CryptoKey)
const secret = await phog.deriveKey(key.privateKey, key.publicKey)
Symmetrically encrypt some data (returns a base58-encoded string)
const encrypted = await phog.encrypt(txt, secret)
Decrypt some data (returns a string)
const decrypted = await phog.decrypt(encrypted, secret)
Export a public key to base58:
const keyString = await phog.exportKey(key.publicKey, phog.configs.sign)
To export a private key, you must specify 'private' as the last argument:
const keyString = await phog.exportKey(key.privateKey, phog.configs.sign, 'private')
Import a base58-encoded public key (returns a CryptoKey)
const key = await phog.importKey(keyString, phog.configs.sign)
FAQs
Dead simple crypto module for Fognet
The npm package phog receives a total of 0 weekly downloads. As such, phog popularity was classified as not popular.
We found that phog demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.