- BigInt literals (15n) are not supported in some environments
- Must use BigInt('15') instead
- It was not supported in React Native 0.70. Need to test in new versions
- Must use hybrid ESM-Common.js package
- ESM (ECMAScript modules) are not supported in Electron, Jest
- Electron needs pre-compilation step aka bundler
- Jest has experimental esm flag, also can be replaced with micro-should
- Common.js modules (legacy node.js modules) are not supported in browsers, Deno
- Browsers can be worked around with UMD wrapper
- ESM (ECMAScript modules) are not supported in Electron, Jest
- Doesn’t play well with ESM in-browser imports
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
multiplyAndAddUnsafe(Q: ProjectivePoint, a: bigint, b: bigint): ProjectivePoint | undefined { | |
// R=R*2+P //bits from a,b = 1,0 | |
// R=R*2 //bits from a,b = 0,0 | |
// R=R*2+Q //bits from a,b = 0,1 | |
// R=R*2+P+Q //bits from a,b = 1,1 | |
const G: ProjectivePoint = this; | |
const spl = (a: bigint) => a.toString(2).padStart(max, '0').split('').map(i => Number(i)); | |
const max = Math.max(ut.bitLen(a), ut.bitLen(b)); | |
const aBits = spl(a); | |
const bBits = spl(b); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function jacobi(a, n) { | |
if (n <= 0n) throw new Error('n must be positive integer'); | |
if (n % 2n === 0n) throw new Error('n must be odd'); | |
a %= n; | |
let result = 1; | |
while (a !== 0n) { | |
while (a % 2n === 0n) { | |
a /= 2n; | |
let n_mod_8 = n % 8n; | |
if (n_mod_8 === 3n || n_mod_8 === 5n) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { secp256k1 } from '@noble/curves/secp256k1'; | |
import elliptic from 'elliptic'; | |
import { mark } from 'micro-bmark'; | |
const EC = elliptic.ec; | |
(async () => { | |
var ec = new EC('secp256k1'); | |
const a = '0000000000000000000000000000000000000000000000000000000000000003'; | |
const b = '3000000000000000000000000000000000000000000000000000000000000000'; |
Metamask uses noble for low-level cryptography operations, such as signature creation. The audit path as per Sep 2023, where every item is name of NPM package:
flowchart TD;
MM[metamask-extension] -->|imports KeyringController| MMKC["@metamask/keyring-controller"];
MMKC -->|imports HDKeyring| MMHD["@metamask/eth-hd-keyring"];
MMKC -->|imports SimpleKeyring| MMSK["@metamask/eth-simple-keyring"];
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MD5: { | |
fn: md5, | |
obj: md5.create, | |
node: (buf) => Uint8Array.from(crypto.createHash('md5').update(buf).digest()), | |
node_obj: () => crypto.createHash('md5'), | |
nist: [ | |
'90015098 3cd24fb0d 6963f7d2 8e17f72', | |
'd41d8cd9 8f00b204e 9800998e cf8427e', | |
'8215ef07 96a20bcaa ae116d38 76c664a', | |
'03dd8807 a93175fb0 62dfb55d c7d359c', |
OlderNewer