@left-curve/crypto
v1.0.0
Published
Cryptographic primitives for the [Dango](https://dango.exchange) ecosystem.
Readme
@left-curve/crypto
Cryptographic primitives for the Dango ecosystem.
Installation
npm install @left-curve/cryptoUsage
import { sha256, Secp256k1, Ed25519 } from "@left-curve/crypto";
const hash = sha256(new Uint8Array([1, 2, 3]));
const keypair = Secp256k1.fromMnemonic("your mnemonic ...");
const pubkey = keypair.publicKey();API
Hash Functions
sha256(data)/Sha256- SHA-256sha512(data)/Sha512- SHA-512keccak256(data)/Keccak256- Keccak-256ripemd160(data)/Ripemd160- RIPEMD-160
Key Pairs
Secp256k1- secp256k1 elliptic curve key pairSecp256k1.fromMnemonic(mnemonic)- derive from BIP-39 mnemonicSecp256k1.fromPrivateKey(key)- from raw private key.publicKey(),.sign(data),.verify(data, signature)
Ed25519- Ed25519 key pair.publicKey(),.sign(data),.verify(data, signature)
Utilities
secp256k1RecoverPubKey(hash, signature, recoveryId)- recover public keysecp256k1CompressPubKey(pubkey)- compress public keysecp256k1VerifySignature(pubkey, hash, signature)- verify signatureed25519VerifySignature(pubkey, hash, signature)- verify signatureethHashMessage(message)- EIP-191 message hashing
WebAuthn
createWebAuthnCredential(options)- create passkey credentialsignWithWebAuthn(credential, challenge)- sign with passkeyverifyWebAuthn(credential, signature)- verify passkey signature
Dependencies
Built on audited libraries:
@noble/curves- elliptic curves@noble/hashes- hash functions@scure/bip32- HD key derivation@scure/bip39- mnemonic generation
License
TBD
