functionalscript 0.23.0 → 0.25.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/fs/asserts/proof.f.d.ts +8 -0
- package/fs/asserts/proof.f.js +51 -0
- package/fs/bnf/data/proof.f.js +7 -17
- package/fs/bnf/module.f.d.ts +10 -0
- package/fs/bnf/module.f.js +10 -0
- package/fs/bnf/testlib.f.js +4 -9
- package/fs/cas/module.f.d.ts +2 -2
- package/fs/cas/module.f.js +2 -2
- package/fs/cas/proof.f.js +3 -3
- package/fs/ci/common/module.f.d.ts +2 -0
- package/fs/ci/common/module.f.js +4 -1
- package/fs/ci/config/module.f.d.ts +2 -2
- package/fs/ci/config/module.f.js +2 -2
- package/fs/ci/module.f.d.ts +3 -4
- package/fs/ci/module.f.js +10 -8
- package/fs/ci/node/module.f.js +4 -2
- package/fs/ci/proof.f.js +9 -6
- package/fs/crypto/sha2/module.f.js +32 -36
- package/fs/crypto/vdf/module.f.d.ts +21 -0
- package/fs/crypto/vdf/module.f.js +57 -0
- package/fs/crypto/vdf/proof.f.d.ts +32 -0
- package/fs/crypto/vdf/proof.f.js +135 -0
- package/fs/dev/module.f.d.ts +2 -9
- package/fs/dev/module.f.js +10 -9
- package/fs/dev/proof.f.d.ts +0 -1
- package/fs/dev/proof.f.js +0 -21
- package/fs/dev/version/module.f.d.ts +2 -2
- package/fs/dev/version/module.f.js +2 -2
- package/fs/dev/version/proof.f.js +2 -2
- package/fs/djs/module.f.d.ts +2 -2
- package/fs/djs/module.f.js +2 -2
- package/fs/djs/parser/module.f.d.ts +0 -2
- package/fs/djs/proof.f.js +1 -1
- package/fs/djs/transpiler/module.f.d.ts +2 -2
- package/fs/djs/transpiler/module.f.js +2 -2
- package/fs/djs/transpiler/proof.f.js +1 -1
- package/fs/{types/effects → effects}/module.f.d.ts +1 -1
- package/fs/{types/effects → effects}/module.f.js +1 -1
- package/fs/{io → effects/node}/module.d.ts +5 -12
- package/fs/{types/effects → effects}/node/module.f.d.ts +3 -3
- package/fs/{types/effects → effects}/node/module.f.js +1 -1
- package/fs/{io → effects/node}/module.js +96 -12
- package/fs/{types/effects → effects}/node/proof.f.js +1 -1
- package/fs/{types/effects → effects}/node/virtual/module.f.d.ts +1 -1
- package/fs/{types/effects → effects}/node/virtual/module.f.js +5 -5
- package/fs/emergent_testing/all.test.d.ts +1 -1
- package/fs/emergent_testing/all.test.js +3 -2
- package/fs/emergent_testing/module.f.d.ts +2 -2
- package/fs/emergent_testing/module.f.js +2 -2
- package/fs/emergent_testing/proof.f.js +4 -4
- package/fs/emergent_testing/scenarios/all.d.ts +1 -1
- package/fs/emergent_testing/scenarios/all.js +1 -1
- package/fs/fjs/module.f.d.ts +1 -1
- package/fs/fjs/module.f.js +1 -1
- package/fs/fjs/module.js +2 -2
- package/fs/json/module.f.d.ts +25 -9
- package/fs/json/module.f.js +25 -3
- package/fs/json/rpc/module.f.d.ts +109 -0
- package/fs/json/rpc/module.f.js +84 -0
- package/fs/json/rpc/proof.f.d.ts +35 -0
- package/fs/json/rpc/proof.f.js +68 -0
- package/fs/json/schema/module.f.d.ts +76 -0
- package/fs/json/schema/module.f.js +112 -0
- package/fs/json/schema/proof.f.d.ts +33 -0
- package/fs/json/schema/proof.f.js +71 -0
- package/fs/mcp/module.f.d.ts +88 -0
- package/fs/mcp/module.f.js +69 -0
- package/fs/sul/level/literal/proof.f.d.ts +1 -0
- package/fs/sul/level/literal/proof.f.js +6 -0
- package/fs/text/sgr/module.f.d.ts +2 -17
- package/fs/text/sgr/module.f.js +4 -19
- package/fs/types/array/module.f.d.ts +7 -0
- package/fs/types/array/module.f.js +7 -0
- package/fs/types/prime_field/module.f.d.ts +8 -0
- package/fs/types/prime_field/module.f.js +37 -5
- package/fs/types/prime_field/proof.f.d.ts +3 -0
- package/fs/types/prime_field/proof.f.js +27 -2
- package/fs/types/rtti/parse/module.f.d.ts +28 -0
- package/fs/types/rtti/parse/module.f.js +35 -5
- package/fs/types/rtti/ts/module.f.d.ts +46 -3
- package/fs/types/rtti/validate/module.f.js +5 -0
- package/fs/website/module.f.d.ts +2 -2
- package/fs/website/module.f.js +2 -2
- package/package.json +3 -3
- package/fs/emergent_testing/module.d.ts +0 -1
- package/fs/emergent_testing/module.js +0 -4
- package/fs/io/module.f.d.ts +0 -134
- package/fs/io/module.f.js +0 -113
- /package/fs/{types/effects → effects}/mock/module.f.d.ts +0 -0
- /package/fs/{types/effects → effects}/mock/module.f.js +0 -0
- /package/fs/{types/effects → effects}/module.d.ts +0 -0
- /package/fs/{types/effects → effects}/module.js +0 -0
- /package/fs/{types/effects → effects}/node/proof.f.d.ts +0 -0
- /package/fs/{types/effects → effects}/proof.f.d.ts +0 -0
- /package/fs/{types/effects → effects}/proof.f.js +0 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { assert, assertEq, todo } from "./module.f.js";
|
|
2
|
+
const throws = (f, expected) => {
|
|
3
|
+
let caught = false;
|
|
4
|
+
try {
|
|
5
|
+
f();
|
|
6
|
+
}
|
|
7
|
+
catch (e) {
|
|
8
|
+
caught = true;
|
|
9
|
+
if (e !== expected) {
|
|
10
|
+
throw ['unexpected throw value', e];
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
if (!caught) {
|
|
14
|
+
throw 'expected function to throw but it did not';
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
export const proof = {
|
|
18
|
+
assertPassesOnTrue: () => {
|
|
19
|
+
assert(true);
|
|
20
|
+
assert(true, 'with message');
|
|
21
|
+
},
|
|
22
|
+
assertThrowsDefaultMsg: () => {
|
|
23
|
+
throws(() => assert(false), 'assertion failed');
|
|
24
|
+
},
|
|
25
|
+
assertThrowsCustomMsg: () => {
|
|
26
|
+
throws(() => assert(false, 'oops'), 'oops');
|
|
27
|
+
},
|
|
28
|
+
assertEqPassesOnEqual: () => {
|
|
29
|
+
assertEq(1, 1);
|
|
30
|
+
assertEq('x', 'x');
|
|
31
|
+
},
|
|
32
|
+
assertEqThrowsOnUnequal: () => {
|
|
33
|
+
let caught = false;
|
|
34
|
+
try {
|
|
35
|
+
assertEq(1, 2);
|
|
36
|
+
}
|
|
37
|
+
catch (e) {
|
|
38
|
+
caught = true;
|
|
39
|
+
const arr = e;
|
|
40
|
+
if (arr[0] !== 1 || arr[1] !== 2) {
|
|
41
|
+
throw ['wrong throw value', e];
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (!caught) {
|
|
45
|
+
throw 'expected assertEq to throw';
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
todoThrows: () => {
|
|
49
|
+
throws(() => todo(), 'not implemented');
|
|
50
|
+
},
|
|
51
|
+
};
|
package/fs/bnf/data/proof.f.js
CHANGED
|
@@ -3,7 +3,7 @@ import { stringToCodePointList } from "../../text/utf16/module.f.js";
|
|
|
3
3
|
import { identity } from "../../types/function/module.f.js";
|
|
4
4
|
import { map, toArray } from "../../types/list/module.f.js";
|
|
5
5
|
import { sort } from "../../types/object/module.f.js";
|
|
6
|
-
import {
|
|
6
|
+
import { commaJoin0Plus, oneEncode, option, range, rangeDecode, repeat0Plus, set } from "../module.f.js";
|
|
7
7
|
import { classic, deterministic } from "../testlib.f.js";
|
|
8
8
|
import { dispatchMap, parser, parserRuleSet, toData, createEmptyTagMap, descentParser } from "./module.f.js";
|
|
9
9
|
const mapCodePoint = (cp) => [cp, undefined];
|
|
@@ -437,15 +437,10 @@ export const proof = {
|
|
|
437
437
|
},
|
|
438
438
|
() => {
|
|
439
439
|
const ws = repeat0Plus(set(' \n\r\t'));
|
|
440
|
-
const
|
|
441
|
-
open,
|
|
442
|
-
ws,
|
|
443
|
-
join0Plus([a, ws], [',', ws]),
|
|
444
|
-
close,
|
|
445
|
-
];
|
|
440
|
+
const cj = commaJoin0Plus(ws);
|
|
446
441
|
const value = () => ({
|
|
447
|
-
object:
|
|
448
|
-
array:
|
|
442
|
+
object: cj('{}', 'a'),
|
|
443
|
+
array: cj('[]', 'a')
|
|
449
444
|
});
|
|
450
445
|
value.name; //bun will fail if no usage of name found
|
|
451
446
|
const m = parser(value);
|
|
@@ -642,15 +637,10 @@ export const proof = {
|
|
|
642
637
|
},
|
|
643
638
|
() => {
|
|
644
639
|
const ws = repeat0Plus(set(' \n\r\t'));
|
|
645
|
-
const
|
|
646
|
-
open,
|
|
647
|
-
ws,
|
|
648
|
-
join0Plus([a, ws], [',', ws]),
|
|
649
|
-
close,
|
|
650
|
-
];
|
|
640
|
+
const cj = commaJoin0Plus(ws);
|
|
651
641
|
const value = () => ({
|
|
652
|
-
object:
|
|
653
|
-
array:
|
|
642
|
+
object: cj('{}', 'a'),
|
|
643
|
+
array: cj('[]', 'a')
|
|
654
644
|
});
|
|
655
645
|
value.name; //bun will fail if no usage of name found
|
|
656
646
|
const m = descentParser(value);
|
package/fs/bnf/module.f.d.ts
CHANGED
|
@@ -131,6 +131,16 @@ export type Join0Plus<T, S> = Option<readonly [T, Repeat0Plus<readonly [S, T]>]>
|
|
|
131
131
|
* Repeats `some` zero or more times separated by `separator`.
|
|
132
132
|
*/
|
|
133
133
|
export declare const join0Plus: <T extends Rule, S extends Rule>(some: T, separator: S) => Rule;
|
|
134
|
+
/**
|
|
135
|
+
* A delimited, comma-separated list with whitespace between tokens:
|
|
136
|
+
* `open ws (item ws (',' ws item ws)*)? close`.
|
|
137
|
+
*
|
|
138
|
+
* `ws` is the per-grammar whitespace rule and is curried so callers can
|
|
139
|
+
* partially apply it once (`const cj = commaJoin0Plus(ws)`) before reusing
|
|
140
|
+
* the same combinator at multiple bracket pairs. The two-character string
|
|
141
|
+
* supplies the bracket pair via destructuring (e.g. `'[]'`, `'{}'`).
|
|
142
|
+
*/
|
|
143
|
+
export declare const commaJoin0Plus: (ws: Rule) => ([open, close]: string, item: Rule) => Sequence;
|
|
134
144
|
export type Repeat<T> = readonly T[];
|
|
135
145
|
/**
|
|
136
146
|
* Repeats a rule a fixed number of times.
|
package/fs/bnf/module.f.js
CHANGED
|
@@ -151,6 +151,16 @@ export const join1Plus = (some, separator) => [some, repeat0Plus([separator, som
|
|
|
151
151
|
* Repeats `some` zero or more times separated by `separator`.
|
|
152
152
|
*/
|
|
153
153
|
export const join0Plus = (some, separator) => option(join1Plus(some, separator));
|
|
154
|
+
/**
|
|
155
|
+
* A delimited, comma-separated list with whitespace between tokens:
|
|
156
|
+
* `open ws (item ws (',' ws item ws)*)? close`.
|
|
157
|
+
*
|
|
158
|
+
* `ws` is the per-grammar whitespace rule and is curried so callers can
|
|
159
|
+
* partially apply it once (`const cj = commaJoin0Plus(ws)`) before reusing
|
|
160
|
+
* the same combinator at multiple bracket pairs. The two-character string
|
|
161
|
+
* supplies the bracket pair via destructuring (e.g. `'[]'`, `'{}'`).
|
|
162
|
+
*/
|
|
163
|
+
export const commaJoin0Plus = (ws) => ([open, close], item) => [open, ws, join0Plus([item, ws], [',', ws]), close];
|
|
154
164
|
/**
|
|
155
165
|
* Repeats a rule a fixed number of times.
|
|
156
166
|
*/
|
package/fs/bnf/testlib.f.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { commaJoin0Plus, max, none, option, range, remove, repeat, repeat0Plus, set } from "./module.f.js";
|
|
2
2
|
export const classic = () => {
|
|
3
3
|
// https://www.json.org/json-en.html
|
|
4
4
|
const json = () => [element];
|
|
@@ -123,15 +123,10 @@ export const deterministic = () => {
|
|
|
123
123
|
option([set('Ee'), option(set('+-')), digits])
|
|
124
124
|
];
|
|
125
125
|
const ws = repeat0Plus(set(' \n\r\t'));
|
|
126
|
-
const
|
|
127
|
-
open,
|
|
128
|
-
ws,
|
|
129
|
-
join0Plus([a, ws], [',', ws]),
|
|
130
|
-
close,
|
|
131
|
-
];
|
|
126
|
+
const cj = commaJoin0Plus(ws);
|
|
132
127
|
const value = () => ({
|
|
133
|
-
array:
|
|
134
|
-
object:
|
|
128
|
+
array: cj('[]', value),
|
|
129
|
+
object: cj('{}', [string, ws, ':', ws, value]),
|
|
135
130
|
string,
|
|
136
131
|
number,
|
|
137
132
|
true: 'true',
|
package/fs/cas/module.f.d.ts
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { type Sha2 } from '../crypto/sha2/module.f.ts';
|
|
7
7
|
import type { Vec } from '../types/bit_vec/module.f.ts';
|
|
8
|
-
import { type Effect, type Operation } from '../
|
|
9
|
-
import { type Fs, type NodeOp } from '../
|
|
8
|
+
import { type Effect, type Operation } from '../effects/module.f.ts';
|
|
9
|
+
import { type Fs, type NodeOp } from '../effects/node/module.f.ts';
|
|
10
10
|
export type KvStore<O extends Operation> = {
|
|
11
11
|
/** Reads a value by key; returns `undefined` when the key does not exist. */
|
|
12
12
|
readonly read: (key: Vec) => Effect<O, Vec | undefined>;
|
package/fs/cas/module.f.js
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
import { computeSync, sha256 } from "../crypto/sha2/module.f.js";
|
|
7
7
|
import { parse } from "../path/module.f.js";
|
|
8
8
|
import { cBase32ToVec, vecToCBase32 } from "../cbase32/module.f.js";
|
|
9
|
-
import { begin, forEachStep, pure } from "../
|
|
10
|
-
import { errorExit, log, mkdir, readdir, readFile, writeFile } from "../
|
|
9
|
+
import { begin, forEachStep, pure } from "../effects/module.f.js";
|
|
10
|
+
import { errorExit, log, mkdir, readdir, readFile, writeFile } from "../effects/node/module.f.js";
|
|
11
11
|
import { toOption } from "../types/nullable/module.f.js";
|
|
12
12
|
import { unwrap } from "../types/result/module.f.js";
|
|
13
13
|
const o = { withFileTypes: true };
|
package/fs/cas/proof.f.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { cas, main } from "./module.f.js";
|
|
2
2
|
import { sha256 } from "../crypto/sha2/module.f.js";
|
|
3
3
|
import { empty, length, vec8 } from "../types/bit_vec/module.f.js";
|
|
4
|
-
import { pure } from "../
|
|
5
|
-
import { run } from "../
|
|
6
|
-
import { emptyState, virtual } from "../
|
|
4
|
+
import { pure } from "../effects/module.f.js";
|
|
5
|
+
import { run } from "../effects/mock/module.f.js";
|
|
6
|
+
import { emptyState, virtual } from "../effects/node/virtual/module.f.js";
|
|
7
7
|
export const proof = {
|
|
8
8
|
mainAdd: () => {
|
|
9
9
|
const content = vec8(0x2an);
|
|
@@ -37,6 +37,7 @@ export declare const gitHubActionSchema: {
|
|
|
37
37
|
readonly name: import("../../types/rtti/module.f.ts").String;
|
|
38
38
|
readonly on: {
|
|
39
39
|
readonly pull_request: import("../../types/rtti/module.f.ts").Or<readonly [{}, undefined]>;
|
|
40
|
+
readonly merge_group: import("../../types/rtti/module.f.ts").Or<readonly [{}, undefined]>;
|
|
40
41
|
};
|
|
41
42
|
readonly jobs: import("../../types/rtti/module.f.ts").Type1<"record", {
|
|
42
43
|
readonly 'runs-on': import("../../types/rtti/module.f.ts").String;
|
|
@@ -55,6 +56,7 @@ export declare const parseGitHubAction: import("../../types/rtti/parse/module.f.
|
|
|
55
56
|
readonly name: import("../../types/rtti/module.f.ts").String;
|
|
56
57
|
readonly on: {
|
|
57
58
|
readonly pull_request: import("../../types/rtti/module.f.ts").Or<readonly [{}, undefined]>;
|
|
59
|
+
readonly merge_group: import("../../types/rtti/module.f.ts").Or<readonly [{}, undefined]>;
|
|
58
60
|
};
|
|
59
61
|
readonly jobs: import("../../types/rtti/module.f.ts").Type1<"record", {
|
|
60
62
|
readonly 'runs-on': import("../../types/rtti/module.f.ts").String;
|
package/fs/ci/common/module.f.js
CHANGED
|
@@ -23,7 +23,10 @@ export const jobSchema = {
|
|
|
23
23
|
export const jobsSchema = record(jobSchema);
|
|
24
24
|
export const gitHubActionSchema = {
|
|
25
25
|
name: string,
|
|
26
|
-
on: {
|
|
26
|
+
on: {
|
|
27
|
+
pull_request: option({}),
|
|
28
|
+
merge_group: option({})
|
|
29
|
+
},
|
|
27
30
|
jobs: jobsSchema
|
|
28
31
|
};
|
|
29
32
|
export const parseGitHubAction = rttiParse(gitHubActionSchema);
|
|
@@ -28,7 +28,7 @@ export declare const node: {
|
|
|
28
28
|
};
|
|
29
29
|
export declare const wasmtime = "45.0.0";
|
|
30
30
|
export declare const wasmer = "7.1.0";
|
|
31
|
-
export declare const tsgo = "7.0.0-dev.
|
|
31
|
+
export declare const tsgo = "7.0.0-dev.20260605.1";
|
|
32
32
|
export declare const actions: {
|
|
33
33
|
readonly 'actions/checkout': "v6";
|
|
34
34
|
readonly 'actions/setup-node': "v6";
|
|
@@ -37,5 +37,5 @@ export declare const actions: {
|
|
|
37
37
|
readonly 'oven-sh/setup-bun': "v2";
|
|
38
38
|
readonly 'bytecodealliance/actions/wasmtime/setup': "v1";
|
|
39
39
|
readonly 'wasmerio/setup-wasmer': "v3.1";
|
|
40
|
-
readonly 'dtolnay/rust-toolchain': "1.
|
|
40
|
+
readonly 'dtolnay/rust-toolchain': "1.96.0";
|
|
41
41
|
};
|
package/fs/ci/config/module.f.js
CHANGED
|
@@ -36,7 +36,7 @@ export const wasmtime = '45.0.0';
|
|
|
36
36
|
// https://github.com/wasmerio/wasmer/releases
|
|
37
37
|
export const wasmer = '7.1.0';
|
|
38
38
|
// https://www.npmjs.com/package/@typescript/native-preview?activeTab=versions
|
|
39
|
-
export const tsgo = '7.0.0-dev.
|
|
39
|
+
export const tsgo = '7.0.0-dev.20260605.1';
|
|
40
40
|
// GitHub Action versions used by CI step builders. The key is the action
|
|
41
41
|
// `owner/name`; call sites compose the full ref as
|
|
42
42
|
// `` `${name}@${actions[name]}` ``.
|
|
@@ -57,5 +57,5 @@ export const actions = {
|
|
|
57
57
|
// https://github.com/wasmerio/setup-wasmer
|
|
58
58
|
'wasmerio/setup-wasmer': 'v3.1',
|
|
59
59
|
// https://rust-lang.org/ - value is Rust version, not action version
|
|
60
|
-
'dtolnay/rust-toolchain': '1.
|
|
60
|
+
'dtolnay/rust-toolchain': '1.96.0',
|
|
61
61
|
};
|
package/fs/ci/module.f.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { type Effect } from '../
|
|
2
|
-
import { type NodeOp } from '../
|
|
1
|
+
import { type Effect } from '../effects/module.f.ts';
|
|
2
|
+
import { type NodeOp } from '../effects/node/module.f.ts';
|
|
3
3
|
import { type MetaStep, type Os } from './common/module.f.ts';
|
|
4
4
|
export type Setup = {
|
|
5
|
-
readonly rust: boolean;
|
|
6
5
|
readonly nodeExtra: (os: Os) => readonly MetaStep[];
|
|
7
6
|
readonly denoExtra: readonly MetaStep[];
|
|
8
7
|
readonly bunExtra: readonly MetaStep[];
|
|
9
8
|
};
|
|
10
|
-
export declare const ci: ({
|
|
9
|
+
export declare const ci: ({ nodeExtra, denoExtra, bunExtra }: Setup) => Effect<NodeOp, number>;
|
|
11
10
|
declare const _default: () => Effect<NodeOp, number>;
|
|
12
11
|
export default _default;
|
package/fs/ci/module.f.js
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
6
|
import { utf8 } from "../text/module.f.js";
|
|
7
|
-
import {
|
|
8
|
-
import { writeFile } from "../
|
|
7
|
+
import { pure } from "../effects/module.f.js";
|
|
8
|
+
import { access, writeFile } from "../effects/node/module.f.js";
|
|
9
9
|
import { images } from "./config/module.f.js";
|
|
10
10
|
import { architecture, findTgz, os, test, toSteps } from "./common/module.f.js";
|
|
11
11
|
import { rustSteps } from "./rust/module.f.js";
|
|
@@ -24,7 +24,8 @@ const job = (rust, nodeExtra, denoExtra, bunExtra) => (o) => (a) => {
|
|
|
24
24
|
];
|
|
25
25
|
return [id, { 'runs-on': image, steps: toSteps(result) }];
|
|
26
26
|
};
|
|
27
|
-
export const ci = ({
|
|
27
|
+
export const ci = ({ nodeExtra, denoExtra, bunExtra }) => access('Cargo.toml').step(result => {
|
|
28
|
+
const rust = result[0] === 'ok';
|
|
28
29
|
const jobs = {
|
|
29
30
|
...Object.fromEntries(os.flatMap(o => architecture.map(job(rust, nodeExtra(o), denoExtra, bunExtra)(o)))),
|
|
30
31
|
...nodeVersions,
|
|
@@ -32,15 +33,16 @@ export const ci = ({ rust, nodeExtra, denoExtra, bunExtra }) => {
|
|
|
32
33
|
};
|
|
33
34
|
const gha = {
|
|
34
35
|
name: 'CI',
|
|
35
|
-
on: {
|
|
36
|
+
on: {
|
|
37
|
+
pull_request: {},
|
|
38
|
+
merge_group: {},
|
|
39
|
+
},
|
|
36
40
|
jobs,
|
|
37
41
|
};
|
|
38
|
-
return
|
|
39
|
-
.step(() => writeFile('.github/workflows/ci.yml', utf8(JSON.stringify(gha, null, ' '))))
|
|
42
|
+
return writeFile('.github/workflows/ci.yml', utf8(JSON.stringify(gha, null, ' ')))
|
|
40
43
|
.step(() => pure(0));
|
|
41
|
-
};
|
|
44
|
+
});
|
|
42
45
|
const defaultEffect = ci({
|
|
43
|
-
rust: true,
|
|
44
46
|
nodeExtra: o => [
|
|
45
47
|
test({ run: 'npm pack' }),
|
|
46
48
|
test({ run: `npm install -g ${findTgz(o)}` }),
|
package/fs/ci/node/module.f.js
CHANGED
|
@@ -17,8 +17,10 @@ export const basicNode = (version) => (extra) => clean([
|
|
|
17
17
|
...extra,
|
|
18
18
|
]);
|
|
19
19
|
const basicTests = [
|
|
20
|
-
test({ run: '
|
|
21
|
-
test({ run: 'npm
|
|
20
|
+
test({ run: 'npx tsc' }),
|
|
21
|
+
test({ run: 'npm test' }),
|
|
22
|
+
test({ run: 'node --test' }),
|
|
23
|
+
test({ run: 'npm run cov' }),
|
|
22
24
|
];
|
|
23
25
|
export const nodeTests = (version) => (extra) => basicNode(version)([
|
|
24
26
|
...basicTests,
|
package/fs/ci/proof.f.js
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
import { ci } from "./module.f.js";
|
|
2
2
|
import { utf8ToString } from "../text/module.f.js";
|
|
3
|
-
import { isVec } from "../types/bit_vec/module.f.js";
|
|
3
|
+
import { empty as emptyVec, isVec } from "../types/bit_vec/module.f.js";
|
|
4
4
|
import { test, parseGitHubAction } from "./common/module.f.js";
|
|
5
5
|
import { assert } from "../asserts/module.f.js";
|
|
6
|
-
import { emptyState, virtual } from "../
|
|
6
|
+
import { emptyState, virtual } from "../effects/node/virtual/module.f.js";
|
|
7
7
|
import { parse as jsonParse } from "../json/module.f.js";
|
|
8
8
|
import { unwrap } from "../types/result/module.f.js";
|
|
9
9
|
const hasRun = (cmd) => (gha) => Object.values(gha.jobs).some(job => job.steps.some(step => step.run?.includes(cmd)));
|
|
10
10
|
const hasRunInJob = (jobId, cmd) => (gha) => gha.jobs[jobId]?.steps.some(step => step.run?.includes(cmd)) ?? false;
|
|
11
|
-
const
|
|
11
|
+
const makeState = (rust) => ({
|
|
12
12
|
...emptyState,
|
|
13
|
-
root: {
|
|
14
|
-
}
|
|
13
|
+
root: {
|
|
14
|
+
'.github': { workflows: {} },
|
|
15
|
+
...(rust ? { 'Cargo.toml': emptyVec } : {}),
|
|
16
|
+
},
|
|
17
|
+
});
|
|
15
18
|
const run = (rust, nodeExtra = () => []) => {
|
|
16
|
-
const [state, result] = virtual(
|
|
19
|
+
const [state, result] = virtual(makeState(rust))(ci({ nodeExtra, denoExtra: [], bunExtra: [] }));
|
|
17
20
|
assert(result === 0, result);
|
|
18
21
|
const dotGithub = state.root['.github'];
|
|
19
22
|
assert(typeof dotGithub === 'object', dotGithub);
|
|
@@ -9,47 +9,43 @@ const base = ({ logBitLen, k, bs0, bs1, ss0, ss1 }) => {
|
|
|
9
9
|
const r = bitLength - d;
|
|
10
10
|
return (n) => n >> d | n << r;
|
|
11
11
|
};
|
|
12
|
-
const
|
|
12
|
+
const sigma = third => (a, b, c) => {
|
|
13
13
|
const ra = rotr(a);
|
|
14
14
|
const rb = rotr(b);
|
|
15
|
-
const rc =
|
|
16
|
-
return
|
|
15
|
+
const rc = third(c);
|
|
16
|
+
return x => ra(x) ^ rb(x) ^ rc(x);
|
|
17
17
|
};
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
25
|
-
const smallSigma0 = smallSigma(ss0);
|
|
26
|
-
const smallSigma1 = smallSigma(ss1);
|
|
18
|
+
const bigSigma = sigma(rotr);
|
|
19
|
+
const smallSigma = sigma(c => x => x >> c);
|
|
20
|
+
const bigSigma0 = bigSigma(...bs0);
|
|
21
|
+
const bigSigma1 = bigSigma(...bs1);
|
|
22
|
+
const smallSigma0 = smallSigma(...ss0);
|
|
23
|
+
const smallSigma1 = smallSigma(...ss1);
|
|
27
24
|
const ch = (x, y, z) => x & y ^ ~x & z;
|
|
28
25
|
const maj = (x, y, z) => x & y ^ x & z ^ y & z;
|
|
29
26
|
const m = mask(bitLength);
|
|
30
|
-
const wi = (
|
|
31
|
-
const nextW = (
|
|
32
|
-
w0 = wi(
|
|
33
|
-
w1 = wi(
|
|
34
|
-
w2 = wi(
|
|
35
|
-
w3 = wi(
|
|
36
|
-
w4 = wi(
|
|
37
|
-
w5 = wi(
|
|
38
|
-
w6 = wi(
|
|
39
|
-
w7 = wi(
|
|
40
|
-
w8 = wi(
|
|
41
|
-
w9 = wi(
|
|
42
|
-
wA = wi(
|
|
43
|
-
wB = wi(
|
|
44
|
-
wC = wi(
|
|
45
|
-
wD = wi(
|
|
46
|
-
wE = wi(
|
|
47
|
-
wF = wi(
|
|
27
|
+
const wi = (a0, a1, a2, a3) => (smallSigma1(a0) + a1 + smallSigma0(a2) + a3) & m;
|
|
28
|
+
const nextW = (w0, w1, w2, w3, w4, w5, w6, w7, w8, w9, wA, wB, wC, wD, wE, wF) => {
|
|
29
|
+
w0 = wi(wE, w9, w1, w0);
|
|
30
|
+
w1 = wi(wF, wA, w2, w1);
|
|
31
|
+
w2 = wi(w0, wB, w3, w2);
|
|
32
|
+
w3 = wi(w1, wC, w4, w3);
|
|
33
|
+
w4 = wi(w2, wD, w5, w4);
|
|
34
|
+
w5 = wi(w3, wE, w6, w5);
|
|
35
|
+
w6 = wi(w4, wF, w7, w6);
|
|
36
|
+
w7 = wi(w5, w0, w8, w7);
|
|
37
|
+
w8 = wi(w6, w1, w9, w8);
|
|
38
|
+
w9 = wi(w7, w2, wA, w9);
|
|
39
|
+
wA = wi(w8, w3, wB, wA);
|
|
40
|
+
wB = wi(w9, w4, wC, wB);
|
|
41
|
+
wC = wi(wA, w5, wD, wC);
|
|
42
|
+
wD = wi(wB, w6, wE, wD);
|
|
43
|
+
wE = wi(wC, w7, wF, wE);
|
|
44
|
+
wF = wi(wD, w8, w0, wF);
|
|
48
45
|
return [w0, w1, w2, w3, w4, w5, w6, w7, w8, w9, wA, wB, wC, wD, wE, wF];
|
|
49
46
|
};
|
|
50
47
|
const kLength = k.length;
|
|
51
|
-
const compressV16 = (
|
|
52
|
-
let w = data;
|
|
48
|
+
const compressV16 = (a0, b0, c0, d0, e0, f0, g0, h0) => w => {
|
|
53
49
|
let a = a0;
|
|
54
50
|
let b = b0;
|
|
55
51
|
let c = c0;
|
|
@@ -77,7 +73,7 @@ const base = ({ logBitLen, k, bs0, bs1, ss0, ss1 }) => {
|
|
|
77
73
|
if (i === kLength) {
|
|
78
74
|
break;
|
|
79
75
|
}
|
|
80
|
-
w = nextW(w);
|
|
76
|
+
w = nextW(...w);
|
|
81
77
|
}
|
|
82
78
|
return [
|
|
83
79
|
(a0 + a) & m,
|
|
@@ -90,10 +86,10 @@ const base = ({ logBitLen, k, bs0, bs1, ss0, ss1 }) => {
|
|
|
90
86
|
(h0 + h) & m,
|
|
91
87
|
];
|
|
92
88
|
};
|
|
93
|
-
const at =
|
|
94
|
-
const compress =
|
|
89
|
+
const at = u => i => (u >> (i << logBitLen)) & m;
|
|
90
|
+
const compress = i => u => {
|
|
95
91
|
const a = at(u);
|
|
96
|
-
return compressV16(i)([
|
|
92
|
+
return compressV16(...i)([
|
|
97
93
|
a(15n),
|
|
98
94
|
a(14n),
|
|
99
95
|
a(13n),
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Nullable } from '../../types/nullable/module.f.ts';
|
|
2
|
+
/** Sloth VDF modulus (3072-bit safe prime, same as reference implementations). */
|
|
3
|
+
export declare const p = 170082004324204494273811327264862981553264701145937538369570764779791492622392118654022654452947093285873855529044371650895045691292912712699015605832276411308653107069798639938826015099738961427172366594187783204437869906954750443653318078358839409699824714551430573905637228307966826784684174483831608534979n;
|
|
4
|
+
/**
|
|
5
|
+
* Sloth VDF over prime `modulus` (`p ≡ 3 (mod 4)`).
|
|
6
|
+
*/
|
|
7
|
+
export type Sloth = {
|
|
8
|
+
readonly p: bigint;
|
|
9
|
+
readonly quadRes: (x: bigint) => boolean;
|
|
10
|
+
readonly modSqrt: (x: bigint) => bigint;
|
|
11
|
+
/** Sequential Sloth permutation; `null` when `steps < 0`. */
|
|
12
|
+
readonly eval: (steps: bigint) => (x: bigint) => Nullable<bigint>;
|
|
13
|
+
/** Fast verification of {@link Sloth.eval}; `false` when `steps < 0`. */
|
|
14
|
+
readonly verify: (steps: bigint) => (x: bigint) => (y: bigint) => boolean;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Builds Sloth VDF operations over `modulus`.
|
|
18
|
+
*/
|
|
19
|
+
export declare const sloth_vdf: (modulus: bigint) => Sloth;
|
|
20
|
+
/** Sloth VDF over {@link p}. */
|
|
21
|
+
export declare const sloth: Sloth;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sloth verifiable delay function over a fixed 3072-bit safe prime.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { sloth } from './module.f.ts'
|
|
10
|
+
*
|
|
11
|
+
* const steps = 4n
|
|
12
|
+
* const x = 42n
|
|
13
|
+
* const y = sloth.eval(steps)(x)
|
|
14
|
+
* if (y === null || !sloth.verify(steps)(x)(y)) { throw y }
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
import { modSqrt, prime_field } from "../../types/prime_field/module.f.js";
|
|
18
|
+
/** Sloth VDF modulus (3072-bit safe prime, same as reference implementations). */
|
|
19
|
+
export const p = 0xf2346eae06a233882814ff16f6a076d3b8f2161c5c92171c0b7b84eed4e9475bcce0c13bde34512afdf90f41ab9b86dcf834f85e04b27fadee712eed23a1d4e58cd1b09d9bfb10696d614f119179a40c49dc8762edc29e8115263913237e14718cbcd4dc6b35bace13f8cdb1b5156c50c47b4aaee0820c874e2864cb854367c3n;
|
|
20
|
+
const repeatSeq = (steps) => (f) => (value) => {
|
|
21
|
+
let v = value;
|
|
22
|
+
let i = 0n;
|
|
23
|
+
while (i < steps) {
|
|
24
|
+
v = f(v);
|
|
25
|
+
i = i + 1n;
|
|
26
|
+
}
|
|
27
|
+
return v;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Builds Sloth VDF operations over `modulus`.
|
|
31
|
+
*/
|
|
32
|
+
export const sloth_vdf = (modulus) => {
|
|
33
|
+
const field = prime_field(modulus);
|
|
34
|
+
const { neg, pow2, reduce, quadRes } = field;
|
|
35
|
+
const root = modSqrt(field);
|
|
36
|
+
const squareLoop = (steps) => (value) => repeatSeq(steps)(pow2)(reduce(value));
|
|
37
|
+
const modSqrtLoop = (steps) => (value) => repeatSeq(steps)(root)(reduce(value));
|
|
38
|
+
const evalSteps = (steps) => (x) => steps < 0n ? null : modSqrtLoop(steps)(x);
|
|
39
|
+
const verifySteps = (steps) => (x) => (y) => {
|
|
40
|
+
if (steps < 0n) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
const input = reduce(x);
|
|
44
|
+
const squared = squareLoop(steps)(y);
|
|
45
|
+
const value = quadRes(squared) ? squared : neg(squared);
|
|
46
|
+
return input === value || neg(input) === value;
|
|
47
|
+
};
|
|
48
|
+
return {
|
|
49
|
+
p: modulus,
|
|
50
|
+
quadRes,
|
|
51
|
+
modSqrt: root,
|
|
52
|
+
eval: evalSteps,
|
|
53
|
+
verify: verifySteps,
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
/** Sloth VDF over {@link p}. */
|
|
57
|
+
export const sloth = sloth_vdf(p);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export declare const proof: {
|
|
2
|
+
p: {
|
|
3
|
+
matchesField: () => void;
|
|
4
|
+
};
|
|
5
|
+
eval: {
|
|
6
|
+
steps100: () => void;
|
|
7
|
+
steps10: () => void;
|
|
8
|
+
steps6: () => void;
|
|
9
|
+
steps4: () => void;
|
|
10
|
+
zeroSteps: () => void;
|
|
11
|
+
negativeSteps: () => void;
|
|
12
|
+
};
|
|
13
|
+
verify: {
|
|
14
|
+
steps100: () => void;
|
|
15
|
+
steps10: () => void;
|
|
16
|
+
steps6: () => void;
|
|
17
|
+
steps4: () => void;
|
|
18
|
+
tampered: () => void;
|
|
19
|
+
wrongY: () => void;
|
|
20
|
+
zeroSteps: () => void;
|
|
21
|
+
negativeSteps: () => void;
|
|
22
|
+
invalidY: () => void;
|
|
23
|
+
};
|
|
24
|
+
modSqrt: {
|
|
25
|
+
roundTrip: () => void;
|
|
26
|
+
nonResidue: () => void;
|
|
27
|
+
};
|
|
28
|
+
quadRes: {
|
|
29
|
+
one: () => void;
|
|
30
|
+
nonResidue: () => void;
|
|
31
|
+
};
|
|
32
|
+
};
|