paulmillr/noble-secp256k1 là một trong những repo tập trung bảo mật mà TopGit theo dõi, hiện có 881 sao, viết chủ yếu bằng TypeScript. Fastest 5KB JS implementation of secp256k1 signatures and ECDH
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
Fastest 5KB JS implementation of secp256k1 signatures & ECDH.
✍️ ECDSA
signatures compliant with RFC6979
➰ Schnorr
signatures compliant with BIP340
🤝 Elliptic Curve Diffie-Hellman ECDH
🔒 Supports hedged signatures guarding against fault attacks
🪶 4.94KB (gzipped) - 10-25x smaller than similar libraries
The module is a sister project of noble-curves.
Use noble-secp256k1 if you need smaller attack surface & better auditability.
Switch to noble-curves (drop-in) if you need features like MSM, DER encoding, custom point precomputes.
898-byte version of the library is available for learning purposes in test/misc/1kb.min.js,
it was created for the article Learning fast elliptic-curve cryptography.
This library belongs to noble cryptography
noble-cryptography — high-security, easily auditable set of contained cryptographic libraries and tools.
Zero or minimal dependencies
Highly readable TypeScript / JS code
PGP-signed releases and transparent NPM builds
All libraries:
ciphers,
curves,
hashes,
post-quantum,
5kb secp256k1 /
ed25519
WASM version: awasm-noble
Check out the homepage
for reading resources, documentation, and apps built with noble
Usage
npm install @noble/secp256k1
deno add jsr:@noble/secp256k1
We support all major platforms and runtimes. For React Native, additional polyfills are needed: see below.
Only async methods are available by default, to keep the library dependency-free.
To enable sync methods:
npm install @noble/hashes
import * as secp from '@noble/secp256k1';
import { hmac } from '@noble/hashes/hmac.js';
import { sha256 } from '@noble/hashes/sha2.js';
secp.hashes.hmacSha256 = (key, msg) => hmac(sha256, key, msg);
secp.hashes.sha256 = sha256;
React Native: polyfill getRandomValues and sha256
React Native does not provide secure getRandomValues by default.
This can't be securely polyfilled from our end, so one will need a RN-specific compile-time dep.
Message will be hashed with sha256. If you want to use a different hash function,
make sure to use { prehash: false }.
extraEntropy: true enables hedged signatures. They incorporate
extra randomness into RFC6979 (described in section 3.6),
to provide additional protection against fault attacks.
Check out blog post Deterministic signatures are not your friends.
Even if their RNG is broken, they will fall back to determinism.
Default behavior lowS: true prohibits signatures which have (sig.s >= CURVE.n/2n) and is compatible with BTC/ETH. Setting lowS: false allows to create malleable signatures, which is default openssl behavior. Non-malleable signatures can still be successfully verified in openssl.
verify
import * as secp from '@noble/secp256k1';
import { hmac } from '@noble/hashes/hmac.js';
import { sha256 } from '@noble/hashes/sha2.js';
import { keccak_256 } from '@noble/hashes/sha3.js';
secp.hashes.hmacSha256 = (key, msg) => hmac(sha256, key, msg);
secp.hashes.sha256 = sha256;
const { secretKey, publicKey } = secp.keygen();
const msg = new TextEncoder().encode('hello noble');
const sig = secp.sign(msg, secretKey);
const isValid = secp.verify(sig, msg, publicKey);
const sigH = secp.sign(keccak_256(msg), secretKey, { prehash: false });
Verifies ECDSA signature.
Message will be hashed with sha256. If you want to use a different hash function,
make sure to use { prehash: false }.
Default behavior lowS: true prohibits malleable signatures which have (sig.s >= CURVE.n/2n) and
is compatible with BTC / ETH.
Setting lowS: false allows to create signatures, which is default openssl behavior.
getSharedSecret
import * as secp from '@noble/secp256k1';
const alice = secp.keygen();
const bob = secp.keygen();
const shared33b = secp.getSharedSecret(alice.secretKey, bob.publicKey);
const shared65b = secp.getSharedSecret(bob.secretKey, alice.publicKey, false);
const sharedPoint = secp.Point.fromBytes(bob.publicKey).multiply(
secp.etc.secretKeyToScalar(alice.secretKey)
);
Computes ECDH (Elliptic Curve Diffie-Hellman) shared secret between
key A and different key B.
We cross-test against sister project noble-curves, which was audited and provides improved security.
The current version has not been independently audited. It is a rewrite of v1, which has been audited by cure53 in Apr 2021:
PDF (funded by Umbra.cash & community).
It's being fuzzed in a separate repository
Constant-timeness
We're targetting algorithmic constant time. JIT-compiler and Garbage Collector make "constant time"
extremely hard to achieve timing attack resistance
in a scripting language. Which means any other JS library can't have
constant-timeness. Even statically typed Rust, a language without GC,
makes it harder to achieve constant-time
for some cases. If your goal is absolute security, don't use any JS lib — including bindings to native ones.
Use low-level libraries & languages.
Supply chain security
Commits are signed with PGP keys to prevent forgery. Be sure to verify the commit signatures
Releases are made transparently through token-less GitHub CI and Trusted Publishing. Be sure to verify the provenance logs for authenticity.
Rare releasing is practiced to minimize the need for re-audits by end-users.
Dependencies are minimized and strictly pinned to reduce supply-chain risk.
We use as few dependencies as possible.
Version ranges are locked, and changes are checked with npm-diff.
Dev dependencies are excluded from end-user installs; they’re only used for development and build steps.
For this package, there are 0 dependencies; and a few dev dependencies:
jsbt is used for benchmarking / testing / build tooling and developed by the same author
prettier, fast-check and typescript are used for code quality / test generation / ts compilation
Randomness
We rely on the built-in
crypto.getRandomValues,
which is considered a cryptographically secure PRNG.
Browsers have had weaknesses in the past - and could again - but implementing a userspace CSPRNG is even worse, as there’s no reliable userspace source of high-quality entropy.
Quantum computers
Cryptographically relevant quantum computer, if built, will allow to
break elliptic curve cryptography (both ECDSA / EdDSA & ECDH) using Shor's algorithm.
Consider switching to newer / hybrid algorithms, such as SPHINCS+. They are available in
noble-post-quantum.
NIST prohibits classical cryptography (RSA, DSA, ECDSA, ECDH) after 2035. Australian ASD prohibits it after 2030.
Upgrading
v2 to v3
v3 brings the package closer to noble-curves v2.
Add Schnorr signatures
Most methods now expect Uint8Array, string hex inputs are prohibited
Add keygen, keygenAsync method
sign, verify: Switch to prehashed messages. Instead of
messageHash, the methods now expect unhashed message.
To bring back old behavior, use option {prehash: false}
sign, verify: Switch to Uint8Array signatures (format: 'compact') by default.
verify: der format must be explicitly specified in {format: 'der'}.
This reduces malleability
verify: prohibit Signature-instance signature. User must now always do
signature.toBytes()
Node v20.19 is now the minimum required version
Various small changes for types
etc: hashes are now set in hashes object. Also sha256 needs to be set now for prehash: true:
paulmillr/noble-secp256k1 có 881 sao GitHub — tải lại trang để xem số mới nhất, hoặc xem trực tiếp github.com/paulmillr/noble-secp256k1. TopGit phản chiếu số sao của GitHub nhưng không cam kết đến từng phút.
paulmillr/noble-secp256k1 còn đang phát triển không?
Commit gần nhất trên paulmillr/noble-secp256k1 là 9 ngày trước (theo timestamp GitHub). Repo có 125 fork — một chỉ báo về mức độ quan tâm của cộng đồng.
paulmillr/noble-secp256k1 là gì?
paulmillr/noble-secp256k1 (paulmillr/noble-secp256k1) là dự án TypeScript trên GitHub. Theo mô tả gốc: Fastest 5KB JS implementation of secp256k1 signatures and ECDH
paulmillr/noble-secp256k1 so với các dự án Security khác thế nào?
paulmillr/noble-secp256k1 được TopGit xếp vào nhóm Security, với 881 sao GitHub và viết bằng TypeScript. Xem trang chủ đề Security trên TopGit để so sánh với các dự án tương tự theo số sao và mức độ hoạt động.
paulmillr/noble-secp256k1 viết bằng ngôn ngữ gì?
paulmillr/noble-secp256k1 chủ yếu viết bằng TypeScript. Trường "language" của GitHub dựa trên phần lớn byte ở nhánh mặc định.
Vì sao paulmillr/noble-secp256k1 được xếp vào nhóm Security?
TopGit xếp paulmillr/noble-secp256k1 vào nhóm Security dựa trên GitHub topics và mô tả của repo (gắn thẻ: "bitcoin", "cryptography", "curve"). Việc phân loại dựa trên metadata thật của repo, không phải đoán theo cảm tính biên tập.
Đọc đầy đủ README ở tab phía trên.
Muốn nghe thêm một ý kiến về noble-secp256k1?
Hỏi một AI đọc được trang này — một cú bấm là có ngay nhận định về noble-secp256k1.