ox 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +54 -0
- package/dist/core/Engine.d.ts +43 -11
- package/dist/core/Engine.d.ts.map +1 -1
- package/dist/core/Engine.js +40 -10
- package/dist/core/Engine.js.map +1 -1
- package/dist/core/Hash.d.ts +36 -0
- package/dist/core/Hash.d.ts.map +1 -1
- package/dist/core/Hash.js +35 -0
- package/dist/core/Hash.js.map +1 -1
- package/dist/core/internal/engine.d.ts +8 -8
- package/dist/core/internal/engine.d.ts.map +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/node/Ed25519.d.ts +33 -0
- package/dist/node/Ed25519.d.ts.map +1 -0
- package/dist/node/Ed25519.js +67 -0
- package/dist/node/Ed25519.js.map +1 -0
- package/dist/node/Engine.d.ts +29 -16
- package/dist/node/Engine.d.ts.map +1 -1
- package/dist/node/Engine.js +38 -14
- package/dist/node/Engine.js.map +1 -1
- package/dist/node/Hash.d.ts +17 -19
- package/dist/node/Hash.d.ts.map +1 -1
- package/dist/node/Hash.js +17 -19
- package/dist/node/Hash.js.map +1 -1
- package/dist/node/Keystore.d.ts +36 -0
- package/dist/node/Keystore.d.ts.map +1 -0
- package/dist/node/Keystore.js +72 -0
- package/dist/node/Keystore.js.map +1 -0
- package/dist/node/Mnemonic.d.ts +35 -0
- package/dist/node/Mnemonic.d.ts.map +1 -0
- package/dist/node/Mnemonic.js +46 -0
- package/dist/node/Mnemonic.js.map +1 -0
- package/dist/node/P256.d.ts +32 -0
- package/dist/node/P256.d.ts.map +1 -0
- package/dist/node/P256.js +34 -0
- package/dist/node/P256.js.map +1 -0
- package/dist/node/X25519.d.ts +31 -0
- package/dist/node/X25519.d.ts.map +1 -0
- package/dist/node/X25519.js +71 -0
- package/dist/node/X25519.js.map +1 -0
- package/dist/node/index.d.ts +95 -8
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +95 -8
- package/dist/node/index.js.map +1 -1
- package/dist/trusted-setups/Paths.d.ts +1 -0
- package/dist/trusted-setups/Paths.d.ts.map +1 -1
- package/dist/trusted-setups/Paths.js +1 -0
- package/dist/trusted-setups/Paths.js.map +1 -1
- package/dist/trusted-setups/Setups.d.ts +35 -0
- package/dist/trusted-setups/Setups.d.ts.map +1 -0
- package/dist/trusted-setups/Setups.js +29 -0
- package/dist/trusted-setups/Setups.js.map +1 -0
- package/dist/trusted-setups/index.d.ts +20 -0
- package/dist/trusted-setups/index.d.ts.map +1 -1
- package/dist/trusted-setups/index.js +20 -0
- package/dist/trusted-setups/index.js.map +1 -1
- package/dist/trusted-setups/internal/paths.d.ts.map +1 -1
- package/dist/trusted-setups/internal/paths.js +1 -1
- package/dist/trusted-setups/internal/paths.js.map +1 -1
- package/dist/trusted-setups/internal/setups/mainnet.d.ts +7 -0
- package/dist/trusted-setups/internal/setups/mainnet.d.ts.map +1 -0
- package/dist/trusted-setups/internal/setups/mainnet.js +11 -0
- package/dist/trusted-setups/internal/setups/mainnet.js.map +1 -0
- package/dist/wasm/Ed25519.d.ts +35 -0
- package/dist/wasm/Ed25519.d.ts.map +1 -0
- package/dist/wasm/Ed25519.js +88 -0
- package/dist/wasm/Ed25519.js.map +1 -0
- package/dist/wasm/Engine.d.ts +36 -26
- package/dist/wasm/Engine.d.ts.map +1 -1
- package/dist/wasm/Engine.js +44 -25
- package/dist/wasm/Engine.js.map +1 -1
- package/dist/wasm/Hash.d.ts +13 -19
- package/dist/wasm/Hash.d.ts.map +1 -1
- package/dist/wasm/Hash.js +21 -27
- package/dist/wasm/Hash.js.map +1 -1
- package/dist/wasm/Keystore.d.ts +51 -0
- package/dist/wasm/Keystore.d.ts.map +1 -0
- package/dist/wasm/Keystore.js +51 -0
- package/dist/wasm/Keystore.js.map +1 -0
- package/dist/wasm/Kzg.d.ts +112 -0
- package/dist/wasm/Kzg.d.ts.map +1 -0
- package/dist/wasm/Kzg.js +333 -0
- package/dist/wasm/Kzg.js.map +1 -0
- package/dist/wasm/Mnemonic.d.ts +33 -0
- package/dist/wasm/Mnemonic.d.ts.map +1 -0
- package/dist/wasm/Mnemonic.js +30 -0
- package/dist/wasm/Mnemonic.js.map +1 -0
- package/dist/wasm/Secp256k1.d.ts +55 -0
- package/dist/wasm/Secp256k1.d.ts.map +1 -0
- package/dist/wasm/Secp256k1.js +181 -0
- package/dist/wasm/Secp256k1.js.map +1 -0
- package/dist/wasm/X25519.d.ts +33 -0
- package/dist/wasm/X25519.d.ts.map +1 -0
- package/dist/wasm/X25519.js +53 -0
- package/dist/wasm/X25519.js.map +1 -0
- package/dist/wasm/index.d.ts +124 -12
- package/dist/wasm/index.d.ts.map +1 -1
- package/dist/wasm/index.js +124 -12
- package/dist/wasm/index.js.map +1 -1
- package/dist/wasm/internal/blake3.d.ts +11 -0
- package/dist/wasm/internal/blake3.d.ts.map +1 -0
- package/dist/wasm/internal/blake3.js +31 -0
- package/dist/wasm/internal/blake3.js.map +1 -0
- package/dist/wasm/internal/blake3.wasm.d.ts +3 -0
- package/dist/wasm/internal/blake3.wasm.d.ts.map +1 -0
- package/dist/wasm/internal/blake3.wasm.js +10 -0
- package/dist/wasm/internal/blake3.wasm.js.map +1 -0
- package/dist/wasm/internal/crypto25519.d.ts +16 -0
- package/dist/wasm/internal/crypto25519.d.ts.map +1 -0
- package/dist/wasm/internal/crypto25519.js +5 -0
- package/dist/wasm/internal/crypto25519.js.map +1 -0
- package/dist/wasm/internal/crypto25519.wasm.d.ts +3 -0
- package/dist/wasm/internal/crypto25519.wasm.d.ts.map +1 -0
- package/dist/wasm/internal/crypto25519.wasm.js +10 -0
- package/dist/wasm/internal/crypto25519.wasm.js.map +1 -0
- package/dist/wasm/internal/ed25519.d.ts +4 -0
- package/dist/wasm/internal/ed25519.d.ts.map +1 -0
- package/dist/wasm/internal/ed25519.js +21 -0
- package/dist/wasm/internal/ed25519.js.map +1 -0
- package/dist/wasm/internal/hashes.d.ts +12 -0
- package/dist/wasm/internal/hashes.d.ts.map +1 -0
- package/dist/wasm/internal/hashes.js +8 -0
- package/dist/wasm/internal/hashes.js.map +1 -0
- package/dist/wasm/internal/hashes.wasm.d.ts +4 -2
- package/dist/wasm/internal/hashes.wasm.d.ts.map +1 -1
- package/dist/wasm/internal/hashes.wasm.js +4 -2
- package/dist/wasm/internal/hashes.wasm.js.map +1 -1
- package/dist/wasm/internal/instantiate.d.ts +12 -0
- package/dist/wasm/internal/instantiate.d.ts.map +1 -1
- package/dist/wasm/internal/instantiate.js +23 -7
- package/dist/wasm/internal/instantiate.js.map +1 -1
- package/dist/wasm/internal/keystore.d.ts +10 -0
- package/dist/wasm/internal/keystore.d.ts.map +1 -0
- package/dist/wasm/internal/keystore.js +10 -0
- package/dist/wasm/internal/keystore.js.map +1 -0
- package/dist/wasm/internal/kzg.d.ts +17 -0
- package/dist/wasm/internal/kzg.d.ts.map +1 -0
- package/dist/wasm/internal/kzg.js +8 -0
- package/dist/wasm/internal/kzg.js.map +1 -0
- package/dist/wasm/internal/kzg.wasm.d.ts +3 -0
- package/dist/wasm/internal/kzg.wasm.d.ts.map +1 -0
- package/dist/wasm/internal/kzg.wasm.js +10 -0
- package/dist/wasm/internal/kzg.wasm.js.map +1 -0
- package/dist/wasm/internal/mnemonic.d.ts +4 -0
- package/dist/wasm/internal/mnemonic.d.ts.map +1 -0
- package/dist/wasm/internal/mnemonic.js +45 -0
- package/dist/wasm/internal/mnemonic.js.map +1 -0
- package/dist/wasm/internal/pbkdf2.d.ts +12 -0
- package/dist/wasm/internal/pbkdf2.d.ts.map +1 -0
- package/dist/wasm/internal/pbkdf2.js +51 -0
- package/dist/wasm/internal/pbkdf2.js.map +1 -0
- package/dist/wasm/internal/scrypt.d.ts +16 -0
- package/dist/wasm/internal/scrypt.d.ts.map +1 -0
- package/dist/wasm/internal/scrypt.js +78 -0
- package/dist/wasm/internal/scrypt.js.map +1 -0
- package/dist/wasm/internal/scrypt.wasm.d.ts +7 -0
- package/dist/wasm/internal/scrypt.wasm.d.ts.map +1 -0
- package/dist/wasm/internal/scrypt.wasm.js +14 -0
- package/dist/wasm/internal/scrypt.wasm.js.map +1 -0
- package/dist/wasm/internal/secp256k1.d.ts +16 -0
- package/dist/wasm/internal/secp256k1.d.ts.map +1 -0
- package/dist/wasm/internal/secp256k1.js +20 -0
- package/dist/wasm/internal/secp256k1.js.map +1 -0
- package/dist/wasm/internal/secp256k1.wasm.d.ts +3 -0
- package/dist/wasm/internal/secp256k1.wasm.d.ts.map +1 -0
- package/dist/wasm/internal/secp256k1.wasm.js +10 -0
- package/dist/wasm/internal/secp256k1.wasm.js.map +1 -0
- package/dist/wasm/internal/x25519.d.ts +4 -0
- package/dist/wasm/internal/x25519.d.ts.map +1 -0
- package/dist/wasm/internal/x25519.js +21 -0
- package/dist/wasm/internal/x25519.js.map +1 -0
- package/package.json +64 -2
- package/src/core/Engine.ts +84 -11
- package/src/core/Hash.ts +59 -0
- package/src/core/_test/Block.test.ts +9 -2
- package/src/core/_test/Engine.test-d.ts +56 -0
- package/src/core/_test/Engine.test.ts +95 -0
- package/src/core/_test/Hash.test-d.ts +18 -0
- package/src/core/_test/Hash.test.ts +100 -1
- package/src/core/_test/Hash.vectors.test.ts +7 -0
- package/src/core/_test/Transaction.test.ts +11 -2
- package/src/core/internal/engine.ts +8 -8
- package/src/index.ts +5 -2
- package/src/node/Ed25519.ts +87 -0
- package/src/node/Engine.ts +79 -23
- package/src/node/Hash.ts +25 -30
- package/src/node/Keystore.ts +103 -0
- package/src/node/Mnemonic.ts +68 -0
- package/src/node/P256.ts +48 -0
- package/src/node/X25519.ts +93 -0
- package/src/node/_test/Curves.fuzz.ts +76 -0
- package/src/node/_test/Ed25519.test-d.ts +35 -0
- package/src/node/_test/Ed25519.test.ts +220 -0
- package/src/node/_test/Engine.test-d.ts +28 -0
- package/src/node/_test/Engine.test.ts +62 -22
- package/src/node/_test/Hash.test-d.ts +16 -9
- package/src/node/_test/Hash.test.ts +10 -11
- package/src/node/_test/Keystore.fuzz.ts +58 -0
- package/src/node/_test/Keystore.test-d.ts +43 -0
- package/src/node/_test/Keystore.test.ts +198 -0
- package/src/node/_test/Mnemonic.fuzz.ts +31 -0
- package/src/node/_test/Mnemonic.test-d.ts +21 -0
- package/src/node/_test/Mnemonic.test.ts +98 -0
- package/src/node/_test/P256.test-d.ts +29 -0
- package/src/node/_test/P256.test.ts +102 -0
- package/src/node/_test/X25519.test-d.ts +28 -0
- package/src/node/_test/X25519.test.ts +239 -0
- package/src/node/index.ts +100 -8
- package/src/trusted-setups/Paths.ts +1 -0
- package/src/trusted-setups/README.md +39 -0
- package/src/trusted-setups/Setups.ts +46 -0
- package/src/trusted-setups/_test/Paths.test.ts +16 -0
- package/src/trusted-setups/_test/Setups.test-d.ts +7 -0
- package/src/trusted-setups/_test/Setups.test.ts +43 -0
- package/src/trusted-setups/_test/index.test.ts +1 -0
- package/src/trusted-setups/index.ts +21 -0
- package/src/trusted-setups/internal/paths.ts +4 -1
- package/src/trusted-setups/internal/setups/mainnet.source.json +7 -0
- package/src/trusted-setups/internal/setups/mainnet.ts +16 -0
- package/src/version.ts +1 -1
- package/src/wasm/Ed25519.ts +114 -0
- package/src/wasm/Engine.ts +78 -31
- package/src/wasm/Hash.bench.ts +2 -2
- package/src/wasm/Hash.ts +29 -50
- package/src/wasm/Keystore.bench.ts +26 -0
- package/src/wasm/Keystore.ts +66 -0
- package/src/wasm/Kzg.bench.ts +63 -0
- package/src/wasm/Kzg.ts +518 -0
- package/src/wasm/Mnemonic.ts +44 -0
- package/src/wasm/Secp256k1.bench.ts +79 -0
- package/src/wasm/Secp256k1.ts +248 -0
- package/src/wasm/X25519.ts +70 -0
- package/src/wasm/_test/Crypto25519.conformance.ts +57 -0
- package/src/wasm/_test/Crypto25519.fuzz.ts +187 -0
- package/src/wasm/_test/Ed25519.test-d.ts +28 -0
- package/src/wasm/_test/Ed25519.test.ts +168 -0
- package/src/wasm/_test/Ed25519.vectors.test.ts +73 -0
- package/src/wasm/_test/Engine.test-d.ts +29 -0
- package/src/wasm/_test/Engine.test.ts +59 -25
- package/src/wasm/_test/Hash.browser.test.ts +14 -7
- package/src/wasm/_test/Hash.fuzz.ts +58 -23
- package/src/wasm/_test/Hash.test-d.ts +16 -10
- package/src/wasm/_test/Hash.test.ts +148 -48
- package/src/wasm/_test/Hash.vectors.test.ts +15 -8
- package/src/wasm/_test/Keystore.browser.test.ts +73 -0
- package/src/wasm/_test/Keystore.fuzz.ts +163 -0
- package/src/wasm/_test/Keystore.test-d.ts +42 -0
- package/src/wasm/_test/Keystore.test.ts +477 -0
- package/src/wasm/_test/Keystore.vectors.test.ts +21 -0
- package/src/wasm/_test/Kzg.test-d.ts +19 -0
- package/src/wasm/_test/Kzg.test.ts +220 -0
- package/src/wasm/_test/Mnemonic.test-d.ts +17 -0
- package/src/wasm/_test/Mnemonic.test.ts +110 -0
- package/src/wasm/_test/Runtime.test.ts +9 -0
- package/src/wasm/_test/Secp256k1.test-d.ts +35 -0
- package/src/wasm/_test/Secp256k1.test.ts +354 -0
- package/src/wasm/_test/X25519.test-d.ts +21 -0
- package/src/wasm/_test/X25519.test.ts +194 -0
- package/src/wasm/_test/fixtures.ts +4 -0
- package/src/wasm/index.ts +130 -12
- package/src/wasm/internal/blake3.ts +45 -0
- package/src/wasm/internal/blake3.wasm.ts +11 -0
- package/src/wasm/internal/crypto25519.ts +43 -0
- package/src/wasm/internal/crypto25519.wasm.ts +11 -0
- package/src/wasm/internal/ed25519.ts +31 -0
- package/src/wasm/internal/hashes.ts +29 -0
- package/src/wasm/internal/hashes.wasm.ts +5 -2
- package/src/wasm/internal/instantiate.ts +29 -9
- package/src/wasm/internal/keystore.ts +19 -0
- package/src/wasm/internal/kzg.ts +50 -0
- package/src/wasm/internal/kzg.wasm.ts +11 -0
- package/src/wasm/internal/mnemonic.ts +56 -0
- package/src/wasm/internal/pbkdf2.ts +86 -0
- package/src/wasm/internal/scrypt.ts +131 -0
- package/src/wasm/internal/scrypt.wasm.ts +17 -0
- package/src/wasm/internal/secp256k1.ts +62 -0
- package/src/wasm/internal/secp256k1.wasm.ts +11 -0
- package/src/wasm/internal/x25519.ts +29 -0
- package/wasm/vendor/c-kzg-4844/LICENSE +201 -0
- package/wasm/vendor/c-kzg-4844/blst/LICENSE +201 -0
- package/src/trusted-setups/internal/setups/mainnet.txt +0 -4163
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as crypto from 'node:crypto';
|
|
2
|
+
export * from '../core/P256.js';
|
|
3
|
+
/**
|
|
4
|
+
* Creates a Node.js implementation of the [`P256`](/api/P256) engine slot,
|
|
5
|
+
* without installing it.
|
|
6
|
+
*
|
|
7
|
+
* Node's other P256 operations do not reproduce Ox's recovered-signature and
|
|
8
|
+
* compressed-shared-point contracts, so they remain on Ox's defaults.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts twoslash
|
|
12
|
+
* // @noErrors
|
|
13
|
+
* import { Engine } from 'ox'
|
|
14
|
+
* import { P256 } from 'ox/node'
|
|
15
|
+
*
|
|
16
|
+
* await Engine.install({ P256: P256.engine() })
|
|
17
|
+
*
|
|
18
|
+
* P256.getPublicKey({ privateKey: '0x...' })
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @returns The raw `P256` engine slot.
|
|
22
|
+
*/
|
|
23
|
+
export function engine() {
|
|
24
|
+
return Promise.resolve({
|
|
25
|
+
getPublicKey: (privateKey) => {
|
|
26
|
+
if (privateKey.length !== 32)
|
|
27
|
+
throw new RangeError(`P256 private key must be 32 bytes, got ${privateKey.length}`);
|
|
28
|
+
const ecdh = crypto.createECDH('prime256v1');
|
|
29
|
+
ecdh.setPrivateKey(privateKey);
|
|
30
|
+
return new Uint8Array(ecdh.getPublicKey(undefined, 'uncompressed'));
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=P256.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"P256.js","sourceRoot":"","sources":["../../src/node/P256.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAIrC,cAAc,iBAAiB,CAAA;AAE/B;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,MAAM;IACpB,OAAO,OAAO,CAAC,OAAO,CAAC;QACrB,YAAY,EAAE,CAAC,UAAU,EAAE,EAAE;YAC3B,IAAI,UAAU,CAAC,MAAM,KAAK,EAAE;gBAC1B,MAAM,IAAI,UAAU,CAClB,0CAA0C,UAAU,CAAC,MAAM,EAAE,CAC9D,CAAA;YACH,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,YAAY,CAAC,CAAA;YAC5C,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,CAAA;YAC9B,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC,CAAA;QACrE,CAAC;KACF,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type * as Engine from '../core/Engine.js';
|
|
2
|
+
import type * as Errors from '../core/Errors.js';
|
|
3
|
+
export * from '../core/X25519.js';
|
|
4
|
+
/**
|
|
5
|
+
* Creates a Node.js implementation of the [`X25519`](/api/X25519) engine slot,
|
|
6
|
+
* without installing it.
|
|
7
|
+
*
|
|
8
|
+
* Random key generation remains on Ox's default implementation.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts twoslash
|
|
12
|
+
* // @noErrors
|
|
13
|
+
* import { Engine } from 'ox'
|
|
14
|
+
* import { X25519 } from 'ox/node'
|
|
15
|
+
*
|
|
16
|
+
* await Engine.install({ X25519: X25519.engine() })
|
|
17
|
+
*
|
|
18
|
+
* X25519.getPublicKey({ privateKey: '0x...' })
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @returns The raw `X25519` engine slot.
|
|
22
|
+
*/
|
|
23
|
+
export declare function engine(): Promise<engine.ReturnType>;
|
|
24
|
+
export declare namespace engine {
|
|
25
|
+
/** Every `X25519` primitive this module implements. */
|
|
26
|
+
type ReturnType = {
|
|
27
|
+
[key in 'getPublicKey' | 'getSharedSecret']-?: NonNullable<Engine.Ecdh[key]>;
|
|
28
|
+
};
|
|
29
|
+
type ErrorType = Errors.GlobalErrorType;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=X25519.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"X25519.d.ts","sourceRoot":"","sources":["../../src/node/X25519.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,MAAM,mBAAmB,CAAA;AAChD,OAAO,KAAK,KAAK,MAAM,MAAM,mBAAmB,CAAA;AAEhD,cAAc,mBAAmB,CAAA;AAKjC;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAYnD;AAED,MAAM,CAAC,OAAO,WAAW,MAAM,CAAC;IAC9B,uDAAuD;IACvD,KAAK,UAAU,GAAG;SACf,GAAG,IAAI,cAAc,GAAG,iBAAiB,CAAC,CAAC,GAAG,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;KAC7E,CAAA;IAED,KAAK,SAAS,GAAG,MAAM,CAAC,eAAe,CAAA;CACxC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import * as crypto from 'node:crypto';
|
|
2
|
+
export * from '../core/X25519.js';
|
|
3
|
+
const privateKeyPrefix = Buffer.from('302e020100300506032b656e04220420', 'hex');
|
|
4
|
+
const publicKeyPrefix = Buffer.from('302a300506032b656e032100', 'hex');
|
|
5
|
+
/**
|
|
6
|
+
* Creates a Node.js implementation of the [`X25519`](/api/X25519) engine slot,
|
|
7
|
+
* without installing it.
|
|
8
|
+
*
|
|
9
|
+
* Random key generation remains on Ox's default implementation.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts twoslash
|
|
13
|
+
* // @noErrors
|
|
14
|
+
* import { Engine } from 'ox'
|
|
15
|
+
* import { X25519 } from 'ox/node'
|
|
16
|
+
*
|
|
17
|
+
* await Engine.install({ X25519: X25519.engine() })
|
|
18
|
+
*
|
|
19
|
+
* X25519.getPublicKey({ privateKey: '0x...' })
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @returns The raw `X25519` engine slot.
|
|
23
|
+
*/
|
|
24
|
+
export function engine() {
|
|
25
|
+
return Promise.resolve({
|
|
26
|
+
getPublicKey: (privateKey) => rawPublicKey(crypto.createPublicKey(toPrivateKey(privateKey))),
|
|
27
|
+
getSharedSecret: (privateKey, publicKey) => copyAndClear(crypto.diffieHellman({
|
|
28
|
+
privateKey: toPrivateKey(privateKey),
|
|
29
|
+
publicKey: toPublicKey(publicKey),
|
|
30
|
+
})),
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
function copyAndClear(value) {
|
|
34
|
+
try {
|
|
35
|
+
return Uint8Array.from(value);
|
|
36
|
+
}
|
|
37
|
+
finally {
|
|
38
|
+
value.fill(0);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function assertLength(key, type) {
|
|
42
|
+
if (key.length !== 32)
|
|
43
|
+
throw new RangeError(`X25519 ${type} key must be 32 bytes, got ${key.length}`);
|
|
44
|
+
}
|
|
45
|
+
function rawPublicKey(publicKey) {
|
|
46
|
+
const der = publicKey.export({ format: 'der', type: 'spki' });
|
|
47
|
+
return Uint8Array.from(der.subarray(-32));
|
|
48
|
+
}
|
|
49
|
+
function toPrivateKey(privateKey) {
|
|
50
|
+
assertLength(privateKey, 'private');
|
|
51
|
+
const der = Buffer.concat([privateKeyPrefix, privateKey]);
|
|
52
|
+
try {
|
|
53
|
+
return crypto.createPrivateKey({
|
|
54
|
+
format: 'der',
|
|
55
|
+
key: der,
|
|
56
|
+
type: 'pkcs8',
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
finally {
|
|
60
|
+
der.fill(0);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function toPublicKey(publicKey) {
|
|
64
|
+
assertLength(publicKey, 'public');
|
|
65
|
+
return crypto.createPublicKey({
|
|
66
|
+
format: 'der',
|
|
67
|
+
key: Buffer.concat([publicKeyPrefix, publicKey]),
|
|
68
|
+
type: 'spki',
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=X25519.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"X25519.js","sourceRoot":"","sources":["../../src/node/X25519.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAIrC,cAAc,mBAAmB,CAAA;AAEjC,MAAM,gBAAgB,GAAG,MAAM,CAAC,IAAI,CAAC,kCAAkC,EAAE,KAAK,CAAC,CAAA;AAC/E,MAAM,eAAe,GAAG,MAAM,CAAC,IAAI,CAAC,0BAA0B,EAAE,KAAK,CAAC,CAAA;AAEtE;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,MAAM;IACpB,OAAO,OAAO,CAAC,OAAO,CAAC;QACrB,YAAY,EAAE,CAAC,UAAU,EAAE,EAAE,CAC3B,YAAY,CAAC,MAAM,CAAC,eAAe,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC;QAChE,eAAe,EAAE,CAAC,UAAU,EAAE,SAAS,EAAE,EAAE,CACzC,YAAY,CACV,MAAM,CAAC,aAAa,CAAC;YACnB,UAAU,EAAE,YAAY,CAAC,UAAU,CAAC;YACpC,SAAS,EAAE,WAAW,CAAC,SAAS,CAAC;SAClC,CAAC,CACH;KACJ,CAAC,CAAA;AACJ,CAAC;AAWD,SAAS,YAAY,CAAC,KAAa;IACjC,IAAI,CAAC;QACH,OAAO,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAC/B,CAAC;YAAS,CAAC;QACT,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACf,CAAC;AACH,CAAC;AAED,SAAS,YAAY,CAAC,GAAe,EAAE,IAA0B;IAC/D,IAAI,GAAG,CAAC,MAAM,KAAK,EAAE;QACnB,MAAM,IAAI,UAAU,CAClB,UAAU,IAAI,8BAA8B,GAAG,CAAC,MAAM,EAAE,CACzD,CAAA;AACL,CAAC;AAED,SAAS,YAAY,CAAC,SAA2B;IAC/C,MAAM,GAAG,GAAG,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAA;IAC7D,OAAO,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;AAC3C,CAAC;AAED,SAAS,YAAY,CAAC,UAAsB;IAC1C,YAAY,CAAC,UAAU,EAAE,SAAS,CAAC,CAAA;IACnC,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,gBAAgB,EAAE,UAAU,CAAC,CAAC,CAAA;IACzD,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,gBAAgB,CAAC;YAC7B,MAAM,EAAE,KAAK;YACb,GAAG,EAAE,GAAG;YACR,IAAI,EAAE,OAAO;SACd,CAAC,CAAA;IACJ,CAAC;YAAS,CAAC;QACT,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACb,CAAC;AACH,CAAC;AAED,SAAS,WAAW,CAAC,SAAqB;IACxC,YAAY,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAA;IACjC,OAAO,MAAM,CAAC,eAAe,CAAC;QAC5B,MAAM,EAAE,KAAK;QACb,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,eAAe,EAAE,SAAS,CAAC,CAAC;QAChD,IAAI,EAAE,MAAM;KACb,CAAC,CAAA;AACJ,CAAC"}
|
package/dist/node/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/** @entrypointCategory Node */
|
|
2
2
|
/**
|
|
3
|
-
* Node.js implementations of Ox's
|
|
3
|
+
* Node.js implementations of Ox's supported cryptographic primitives, backed
|
|
4
|
+
* by `node:crypto`.
|
|
4
5
|
*
|
|
5
6
|
* Import this entrypoint only in Node.js. Its static `node:crypto` dependency
|
|
6
7
|
* is intentionally kept outside Ox's runtime-neutral entrypoint.
|
|
@@ -8,10 +9,9 @@
|
|
|
8
9
|
* @example
|
|
9
10
|
* ```ts twoslash
|
|
10
11
|
* // @noErrors
|
|
11
|
-
* import { Hash } from 'ox'
|
|
12
|
-
* import { Engine } from 'ox/node'
|
|
12
|
+
* import { Engine, Hash } from 'ox/node'
|
|
13
13
|
*
|
|
14
|
-
* await Engine.
|
|
14
|
+
* await Engine.install()
|
|
15
15
|
*
|
|
16
16
|
* Hash.sha256('0xdeadbeef')
|
|
17
17
|
* ```
|
|
@@ -20,15 +20,32 @@
|
|
|
20
20
|
*/
|
|
21
21
|
export * as Engine from './Engine.js';
|
|
22
22
|
/**
|
|
23
|
-
*
|
|
23
|
+
* Ox's Ed25519 API and its supported Node.js engine primitives.
|
|
24
24
|
*
|
|
25
25
|
* @example
|
|
26
26
|
* ```ts twoslash
|
|
27
27
|
* // @noErrors
|
|
28
|
-
* import { Engine
|
|
29
|
-
* import
|
|
28
|
+
* import { Engine } from 'ox'
|
|
29
|
+
* import { Ed25519 } from 'ox/node'
|
|
30
30
|
*
|
|
31
|
-
* Engine.
|
|
31
|
+
* await Engine.install({ Ed25519: Ed25519.engine() })
|
|
32
|
+
*
|
|
33
|
+
* Ed25519.getPublicKey({ privateKey: '0x...' })
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @category Crypto
|
|
37
|
+
*/
|
|
38
|
+
export * as Ed25519 from './Ed25519.js';
|
|
39
|
+
/**
|
|
40
|
+
* Ox's hash API and its supported Node.js engine primitives.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```ts twoslash
|
|
44
|
+
* // @noErrors
|
|
45
|
+
* import { Engine } from 'ox'
|
|
46
|
+
* import { Hash } from 'ox/node'
|
|
47
|
+
*
|
|
48
|
+
* await Engine.install({ Hash: Hash.engine() })
|
|
32
49
|
*
|
|
33
50
|
* Hash.sha256('0xdeadbeef')
|
|
34
51
|
* ```
|
|
@@ -36,4 +53,74 @@ export * as Engine from './Engine.js';
|
|
|
36
53
|
* @category Crypto
|
|
37
54
|
*/
|
|
38
55
|
export * as Hash from './Hash.js';
|
|
56
|
+
/**
|
|
57
|
+
* Ox's keystore API and its supported Node.js engine primitives.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```ts twoslash
|
|
61
|
+
* // @noErrors
|
|
62
|
+
* import { Engine } from 'ox'
|
|
63
|
+
* import { Keystore } from 'ox/node'
|
|
64
|
+
*
|
|
65
|
+
* await Engine.install({ Keystore: Keystore.engine() })
|
|
66
|
+
*
|
|
67
|
+
* Keystore.pbkdf2({ password: 'testpassword' })
|
|
68
|
+
* ```
|
|
69
|
+
*
|
|
70
|
+
* @category Crypto
|
|
71
|
+
*/
|
|
72
|
+
export * as Keystore from './Keystore.js';
|
|
73
|
+
/**
|
|
74
|
+
* Ox's mnemonic API and its Node.js BIP-39 seed engine primitive.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```ts twoslash
|
|
78
|
+
* // @noErrors
|
|
79
|
+
* import { Engine } from 'ox'
|
|
80
|
+
* import { Mnemonic } from 'ox/node'
|
|
81
|
+
*
|
|
82
|
+
* await Engine.install({ Mnemonic: Mnemonic.engine() })
|
|
83
|
+
*
|
|
84
|
+
* Mnemonic.toSeed(
|
|
85
|
+
* 'test test test test test test test test test test test junk'
|
|
86
|
+
* )
|
|
87
|
+
* ```
|
|
88
|
+
*
|
|
89
|
+
* @category Crypto
|
|
90
|
+
*/
|
|
91
|
+
export * as Mnemonic from './Mnemonic.js';
|
|
92
|
+
/**
|
|
93
|
+
* Ox's P256 API and its Node.js public-key derivation engine primitive.
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```ts twoslash
|
|
97
|
+
* // @noErrors
|
|
98
|
+
* import { Engine } from 'ox'
|
|
99
|
+
* import { P256 } from 'ox/node'
|
|
100
|
+
*
|
|
101
|
+
* await Engine.install({ P256: P256.engine() })
|
|
102
|
+
*
|
|
103
|
+
* P256.getPublicKey({ privateKey: '0x...' })
|
|
104
|
+
* ```
|
|
105
|
+
*
|
|
106
|
+
* @category Crypto
|
|
107
|
+
*/
|
|
108
|
+
export * as P256 from './P256.js';
|
|
109
|
+
/**
|
|
110
|
+
* Ox's X25519 API and its supported Node.js engine primitives.
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```ts twoslash
|
|
114
|
+
* // @noErrors
|
|
115
|
+
* import { Engine } from 'ox'
|
|
116
|
+
* import { X25519 } from 'ox/node'
|
|
117
|
+
*
|
|
118
|
+
* await Engine.install({ X25519: X25519.engine() })
|
|
119
|
+
*
|
|
120
|
+
* X25519.getPublicKey({ privateKey: '0x...' })
|
|
121
|
+
* ```
|
|
122
|
+
*
|
|
123
|
+
* @category Crypto
|
|
124
|
+
*/
|
|
125
|
+
export * as X25519 from './X25519.js';
|
|
39
126
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/node/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAE/B;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAErC;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAE/B;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAErC;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AAEvC;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AAEjC;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AAEzC;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AAEzC;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AAEjC;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA"}
|
package/dist/node/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/** @entrypointCategory Node */
|
|
2
2
|
/**
|
|
3
|
-
* Node.js implementations of Ox's
|
|
3
|
+
* Node.js implementations of Ox's supported cryptographic primitives, backed
|
|
4
|
+
* by `node:crypto`.
|
|
4
5
|
*
|
|
5
6
|
* Import this entrypoint only in Node.js. Its static `node:crypto` dependency
|
|
6
7
|
* is intentionally kept outside Ox's runtime-neutral entrypoint.
|
|
@@ -8,10 +9,9 @@
|
|
|
8
9
|
* @example
|
|
9
10
|
* ```ts twoslash
|
|
10
11
|
* // @noErrors
|
|
11
|
-
* import { Hash } from 'ox'
|
|
12
|
-
* import { Engine } from 'ox/node'
|
|
12
|
+
* import { Engine, Hash } from 'ox/node'
|
|
13
13
|
*
|
|
14
|
-
* await Engine.
|
|
14
|
+
* await Engine.install()
|
|
15
15
|
*
|
|
16
16
|
* Hash.sha256('0xdeadbeef')
|
|
17
17
|
* ```
|
|
@@ -20,15 +20,32 @@
|
|
|
20
20
|
*/
|
|
21
21
|
export * as Engine from './Engine.js';
|
|
22
22
|
/**
|
|
23
|
-
*
|
|
23
|
+
* Ox's Ed25519 API and its supported Node.js engine primitives.
|
|
24
24
|
*
|
|
25
25
|
* @example
|
|
26
26
|
* ```ts twoslash
|
|
27
27
|
* // @noErrors
|
|
28
|
-
* import { Engine
|
|
29
|
-
* import
|
|
28
|
+
* import { Engine } from 'ox'
|
|
29
|
+
* import { Ed25519 } from 'ox/node'
|
|
30
30
|
*
|
|
31
|
-
* Engine.
|
|
31
|
+
* await Engine.install({ Ed25519: Ed25519.engine() })
|
|
32
|
+
*
|
|
33
|
+
* Ed25519.getPublicKey({ privateKey: '0x...' })
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @category Crypto
|
|
37
|
+
*/
|
|
38
|
+
export * as Ed25519 from './Ed25519.js';
|
|
39
|
+
/**
|
|
40
|
+
* Ox's hash API and its supported Node.js engine primitives.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```ts twoslash
|
|
44
|
+
* // @noErrors
|
|
45
|
+
* import { Engine } from 'ox'
|
|
46
|
+
* import { Hash } from 'ox/node'
|
|
47
|
+
*
|
|
48
|
+
* await Engine.install({ Hash: Hash.engine() })
|
|
32
49
|
*
|
|
33
50
|
* Hash.sha256('0xdeadbeef')
|
|
34
51
|
* ```
|
|
@@ -36,4 +53,74 @@ export * as Engine from './Engine.js';
|
|
|
36
53
|
* @category Crypto
|
|
37
54
|
*/
|
|
38
55
|
export * as Hash from './Hash.js';
|
|
56
|
+
/**
|
|
57
|
+
* Ox's keystore API and its supported Node.js engine primitives.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```ts twoslash
|
|
61
|
+
* // @noErrors
|
|
62
|
+
* import { Engine } from 'ox'
|
|
63
|
+
* import { Keystore } from 'ox/node'
|
|
64
|
+
*
|
|
65
|
+
* await Engine.install({ Keystore: Keystore.engine() })
|
|
66
|
+
*
|
|
67
|
+
* Keystore.pbkdf2({ password: 'testpassword' })
|
|
68
|
+
* ```
|
|
69
|
+
*
|
|
70
|
+
* @category Crypto
|
|
71
|
+
*/
|
|
72
|
+
export * as Keystore from './Keystore.js';
|
|
73
|
+
/**
|
|
74
|
+
* Ox's mnemonic API and its Node.js BIP-39 seed engine primitive.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```ts twoslash
|
|
78
|
+
* // @noErrors
|
|
79
|
+
* import { Engine } from 'ox'
|
|
80
|
+
* import { Mnemonic } from 'ox/node'
|
|
81
|
+
*
|
|
82
|
+
* await Engine.install({ Mnemonic: Mnemonic.engine() })
|
|
83
|
+
*
|
|
84
|
+
* Mnemonic.toSeed(
|
|
85
|
+
* 'test test test test test test test test test test test junk'
|
|
86
|
+
* )
|
|
87
|
+
* ```
|
|
88
|
+
*
|
|
89
|
+
* @category Crypto
|
|
90
|
+
*/
|
|
91
|
+
export * as Mnemonic from './Mnemonic.js';
|
|
92
|
+
/**
|
|
93
|
+
* Ox's P256 API and its Node.js public-key derivation engine primitive.
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```ts twoslash
|
|
97
|
+
* // @noErrors
|
|
98
|
+
* import { Engine } from 'ox'
|
|
99
|
+
* import { P256 } from 'ox/node'
|
|
100
|
+
*
|
|
101
|
+
* await Engine.install({ P256: P256.engine() })
|
|
102
|
+
*
|
|
103
|
+
* P256.getPublicKey({ privateKey: '0x...' })
|
|
104
|
+
* ```
|
|
105
|
+
*
|
|
106
|
+
* @category Crypto
|
|
107
|
+
*/
|
|
108
|
+
export * as P256 from './P256.js';
|
|
109
|
+
/**
|
|
110
|
+
* Ox's X25519 API and its supported Node.js engine primitives.
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```ts twoslash
|
|
114
|
+
* // @noErrors
|
|
115
|
+
* import { Engine } from 'ox'
|
|
116
|
+
* import { X25519 } from 'ox/node'
|
|
117
|
+
*
|
|
118
|
+
* await Engine.install({ X25519: X25519.engine() })
|
|
119
|
+
*
|
|
120
|
+
* X25519.getPublicKey({ privateKey: '0x...' })
|
|
121
|
+
* ```
|
|
122
|
+
*
|
|
123
|
+
* @category Crypto
|
|
124
|
+
*/
|
|
125
|
+
export * as X25519 from './X25519.js';
|
|
39
126
|
//# sourceMappingURL=index.js.map
|
package/dist/node/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAE/B;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAErC;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAE/B;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAErC;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AAEvC;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AAEjC;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AAEzC;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AAEzC;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AAEjC;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Paths.d.ts","sourceRoot":"","sources":["../../src/trusted-setups/Paths.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,OAAO,QAAkB,CAAA"}
|
|
1
|
+
{"version":3,"file":"Paths.d.ts","sourceRoot":"","sources":["../../src/trusted-setups/Paths.ts"],"names":[],"mappings":"AAEA,8DAA8D;AAC9D,eAAO,MAAM,OAAO,QAAkB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Paths.js","sourceRoot":"","sources":["../../src/trusted-setups/Paths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAE1C,MAAM,CAAC,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,CAAA"}
|
|
1
|
+
{"version":3,"file":"Paths.js","sourceRoot":"","sources":["../../src/trusted-setups/Paths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAE1C,8DAA8D;AAC9D,MAAM,CAAC,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,CAAA"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type * as Bytes from '../core/Bytes.js';
|
|
2
|
+
/**
|
|
3
|
+
* Trusted setup points for EIP-4844 and EIP-7594 KZG operations.
|
|
4
|
+
*/
|
|
5
|
+
export type TrustedSetup = {
|
|
6
|
+
/** G1 points in Lagrange form. */
|
|
7
|
+
readonly g1_lagrange: Bytes.Bytes;
|
|
8
|
+
/** G1 points in monomial form. */
|
|
9
|
+
readonly g1_monomial: Bytes.Bytes;
|
|
10
|
+
/** G2 points in monomial form. */
|
|
11
|
+
readonly g2_monomial: Bytes.Bytes;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Ethereum mainnet trusted setup for EIP-4844 and EIP-7594.
|
|
15
|
+
*
|
|
16
|
+
* The setup stores packed points and is safe to reuse across `Kzg.create`
|
|
17
|
+
* calls. `Kzg.create` copies every field before asynchronous initialization.
|
|
18
|
+
*
|
|
19
|
+
* Treat the exported byte arrays as read-only.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts twoslash
|
|
23
|
+
* // @noErrors
|
|
24
|
+
* import { Setups } from 'ox/trusted-setups'
|
|
25
|
+
* import { Kzg } from 'ox/wasm'
|
|
26
|
+
*
|
|
27
|
+
* const kzg = await Kzg.create({
|
|
28
|
+
* trustedSetup: Setups.mainnet
|
|
29
|
+
* })
|
|
30
|
+
*
|
|
31
|
+
* kzg.dispose()
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare const mainnet: TrustedSetup;
|
|
35
|
+
//# sourceMappingURL=Setups.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Setups.d.ts","sourceRoot":"","sources":["../../src/trusted-setups/Setups.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,KAAK,MAAM,kBAAkB,CAAA;AAO9C;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,kCAAkC;IAClC,QAAQ,CAAC,WAAW,EAAE,KAAK,CAAC,KAAK,CAAA;IACjC,kCAAkC;IAClC,QAAQ,CAAC,WAAW,EAAE,KAAK,CAAC,KAAK,CAAA;IACjC,kCAAkC;IAClC,QAAQ,CAAC,WAAW,EAAE,KAAK,CAAC,KAAK,CAAA;CAClC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,OAAO,EAAE,YAIpB,CAAA"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as Base64 from '../core/Base64.js';
|
|
2
|
+
import { g1Lagrange, g1Monomial, g2Monomial, } from './internal/setups/mainnet.js';
|
|
3
|
+
/**
|
|
4
|
+
* Ethereum mainnet trusted setup for EIP-4844 and EIP-7594.
|
|
5
|
+
*
|
|
6
|
+
* The setup stores packed points and is safe to reuse across `Kzg.create`
|
|
7
|
+
* calls. `Kzg.create` copies every field before asynchronous initialization.
|
|
8
|
+
*
|
|
9
|
+
* Treat the exported byte arrays as read-only.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts twoslash
|
|
13
|
+
* // @noErrors
|
|
14
|
+
* import { Setups } from 'ox/trusted-setups'
|
|
15
|
+
* import { Kzg } from 'ox/wasm'
|
|
16
|
+
*
|
|
17
|
+
* const kzg = await Kzg.create({
|
|
18
|
+
* trustedSetup: Setups.mainnet
|
|
19
|
+
* })
|
|
20
|
+
*
|
|
21
|
+
* kzg.dispose()
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export const mainnet = /* @__PURE__ */ Object.freeze({
|
|
25
|
+
g1_lagrange: /* @__PURE__ */ Base64.toBytes(g1Lagrange),
|
|
26
|
+
g1_monomial: /* @__PURE__ */ Base64.toBytes(g1Monomial),
|
|
27
|
+
g2_monomial: /* @__PURE__ */ Base64.toBytes(g2Monomial),
|
|
28
|
+
});
|
|
29
|
+
//# sourceMappingURL=Setups.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Setups.js","sourceRoot":"","sources":["../../src/trusted-setups/Setups.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAA;AAE3C,OAAO,EACL,UAAU,EACV,UAAU,EACV,UAAU,GACX,MAAM,8BAA8B,CAAA;AAcrC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,MAAM,OAAO,GAAiB,eAAe,CAAC,MAAM,CAAC,MAAM,CAAC;IACjE,WAAW,EAAE,eAAe,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC;IACvD,WAAW,EAAE,eAAe,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC;IACvD,WAAW,EAAE,eAAe,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC;CACxD,CAAC,CAAA"}
|
|
@@ -1,2 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File-system paths for trusted setup files bundled with Ox.
|
|
3
|
+
*/
|
|
1
4
|
export * as Paths from './Paths.js';
|
|
5
|
+
/**
|
|
6
|
+
* Trusted setup data bundled with Ox.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts twoslash
|
|
10
|
+
* // @noErrors
|
|
11
|
+
* import { Setups } from 'ox/trusted-setups'
|
|
12
|
+
* import { Kzg } from 'ox/wasm'
|
|
13
|
+
*
|
|
14
|
+
* const kzg = await Kzg.create({
|
|
15
|
+
* trustedSetup: Setups.mainnet
|
|
16
|
+
* })
|
|
17
|
+
*
|
|
18
|
+
* kzg.dispose()
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export * as Setups from './Setups.js';
|
|
2
22
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/trusted-setups/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/trusted-setups/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AAEnC;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA"}
|
|
@@ -1,2 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File-system paths for trusted setup files bundled with Ox.
|
|
3
|
+
*/
|
|
1
4
|
export * as Paths from './Paths.js';
|
|
5
|
+
/**
|
|
6
|
+
* Trusted setup data bundled with Ox.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts twoslash
|
|
10
|
+
* // @noErrors
|
|
11
|
+
* import { Setups } from 'ox/trusted-setups'
|
|
12
|
+
* import { Kzg } from 'ox/wasm'
|
|
13
|
+
*
|
|
14
|
+
* const kzg = await Kzg.create({
|
|
15
|
+
* trustedSetup: Setups.mainnet
|
|
16
|
+
* })
|
|
17
|
+
*
|
|
18
|
+
* kzg.dispose()
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export * as Setups from './Setups.js';
|
|
2
22
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/trusted-setups/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/trusted-setups/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AAEnC;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../../src/trusted-setups/internal/paths.ts"],"names":[],"mappings":"AAGA,gBAAgB;AAChB,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../../src/trusted-setups/internal/paths.ts"],"names":[],"mappings":"AAGA,gBAAgB;AAChB,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,UAYhC"}
|
|
@@ -8,6 +8,6 @@ export function path(name) {
|
|
|
8
8
|
// @ts-ignore
|
|
9
9
|
import.meta.url);
|
|
10
10
|
const __dirname = dirname(__filename);
|
|
11
|
-
return resolve(__dirname,
|
|
11
|
+
return resolve(__dirname, `../../../src/trusted-setups/internal/setups/${name}.json`);
|
|
12
12
|
}
|
|
13
13
|
//# sourceMappingURL=paths.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../../../src/trusted-setups/internal/paths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAExC,gBAAgB;AAChB,MAAM,UAAU,IAAI,CAAC,IAAY;IAC/B,MAAM,UAAU,GAAG,aAAa;IAC9B,2IAA2I;IAC3I,6CAA6C;IAC7C,aAAa;IACb,MAAM,CAAC,IAAI,CAAC,GAAG,CAChB,CAAA;IACD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;IACrC,OAAO,OAAO,
|
|
1
|
+
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../../../src/trusted-setups/internal/paths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAExC,gBAAgB;AAChB,MAAM,UAAU,IAAI,CAAC,IAAY;IAC/B,MAAM,UAAU,GAAG,aAAa;IAC9B,2IAA2I;IAC3I,6CAA6C;IAC7C,aAAa;IACb,MAAM,CAAC,IAAI,CAAC,GAAG,CAChB,CAAA;IACD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;IACrC,OAAO,OAAO,CACZ,SAAS,EACT,+CAA+C,IAAI,OAAO,CAC3D,CAAA;AACH,CAAC"}
|