Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion .config/cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,19 @@
// language - current active spelling language
"language": "en",
// words - list of words to be always considered correct
"words": ["tarides", "nixbuild", "stefanzweifel", "ACMRT", "Oxlint", "rimraf", "jsoo", "Eeuo", "caml", "esbuild"],
"words": [
"ACMRT",
"Iseconds",
"nixbuild",
"Oxlint",
"stefanzweifel",
"tarides",
"rimraf",
"jsoo",
"Eeuo",
"caml",
"esbuild"
],
// flagWords - list of words to be always considered incorrect
// This is useful for offensive words and common spelling errors.
// For example "hte" should be "the"
Expand Down
3 changes: 2 additions & 1 deletion scripts/tests/check-cache-regressions.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#!/usr/bin/env bash
set -Eeuxo pipefail

Check warning on line 2 in scripts/tests/check-cache-regressions.sh

View workflow job for this annotation

GitHub Actions / Lint-Format-and-TypoCheck

Unknown word (Eeuxo)

source ./scripts/lib/ux.sh

# test cache regression packaging and unpackaging primitives here

Check warning on line 6 in scripts/tests/check-cache-regressions.sh

View workflow job for this annotation

GitHub Actions / Lint-Format-and-TypoCheck

Unknown word (unpackaging)
./run ./src/tests/cache/simple-regression.ts --bundle --mode dump --tarball ./tests/test-artifacts/cache/simple-regression.tar.gz

./run ./src/tests/cache/simple-regression.ts --bundle --mode check --tarball ./tests/test-artifacts/cache/simple-regression.tar.gz

# This pin is generated in ./dump-cache-regressions.sh
ARTIFACT_PIN=2025-10-02T13:36:52-04:00
ARTIFACT_PIN=2025-10-14T13:40:45-04:00

WORKDIR=tests/test-artifacts/cache/
mkdir -p $WORKDIR
Expand All @@ -22,5 +22,6 @@
# Regression checks
./run ./src/tests/cache/simple-regression.ts --bundle --mode check --tarball $WORKDIR/simple-regression.tar.gz
./run ./src/tests/cache/complex-regression.ts --bundle --mode check --tarball $WORKDIR/complex-regression.tar.gz
./run ./src/tests/cache/rsa-regression.ts --bundle --keep --mode check --tarball $WORKDIR/rsa-regression.tar.gz

echo "Artifacts checked successfully!"
1 change: 1 addition & 0 deletions scripts/tests/dump-cache-regressions.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
set -Eeuxo pipefail

Check warning on line 2 in scripts/tests/dump-cache-regressions.sh

View workflow job for this annotation

GitHub Actions / Lint-Format-and-TypoCheck

Unknown word (Eeuxo)

source ./scripts/lib/ux.sh

Expand All @@ -10,6 +10,7 @@

./run ./src/tests/cache/simple-regression.ts --bundle --mode dump --tarball $WORKDIR/simple-regression.tar.gz
./run ./src/tests/cache/complex-regression.ts --bundle --keep --mode dump --tarball $WORKDIR/complex-regression.tar.gz
./run ./src/tests/cache/rsa-regression.ts --bundle --keep --mode dump --tarball $WORKDIR/rsa-regression.tar.gz

gcloud storage cp --recursive $WORKDIR gs://o1js-ci/tests/cache/fixtures/

Expand Down
16 changes: 16 additions & 0 deletions src/examples/crypto/rsa/program.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { ZkProgram } from 'o1js';
import { Bigint2048, rsaVerify65537 } from './rsa.js';

export const rsaZkProgram = ZkProgram({
name: 'rsa-verify',

methods: {
verifyRsa65537: {
privateInputs: [Bigint2048, Bigint2048, Bigint2048],

async method(message: Bigint2048, signature: Bigint2048, modulus: Bigint2048) {
rsaVerify65537(message, signature, modulus);
},
},
},
});
18 changes: 2 additions & 16 deletions src/examples/crypto/rsa/run.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,8 @@
import { ZkProgram } from 'o1js';
import { Performance } from '../../../lib/testing/perf-regression.js';
import { Bigint2048, rsaVerify65537 } from './rsa.js';
import { rsaZkProgram } from './program.js';
import { Bigint2048 } from './rsa.js';
import { generateRsaParams, rsaSign, sha256Bigint } from './utils.js';

let rsaZkProgram = ZkProgram({
name: 'rsa-verify',

methods: {
verifyRsa65537: {
privateInputs: [Bigint2048, Bigint2048, Bigint2048],

async method(message: Bigint2048, signature: Bigint2048, modulus: Bigint2048) {
rsaVerify65537(message, signature, modulus);
},
},
},
});

let cs = await rsaZkProgram.analyzeMethods();

console.log(cs.verifyRsa65537.summary());
Expand Down
46 changes: 23 additions & 23 deletions src/tests/cache/complex-regression.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import minimist from "minimist";
import assert from "node:assert";
import { Field, Provable, Struct, UInt64, Unconstrained, ZkProgram } from "o1js";
import { CacheHarness } from "./harness.js";
import minimist from 'minimist';
import assert from 'node:assert';
import { Field, Provable, Struct, UInt64, Unconstrained, ZkProgram } from 'o1js';
import { CacheHarness } from './harness.js';

const { mode, tarball } = minimist(process.argv.slice(2))
const { mode, tarball } = minimist(process.argv.slice(2));

const harness = await CacheHarness({ mode, tarball })
const harness = await CacheHarness({ mode, tarball });

const RealProgram = ZkProgram({
name: 'real',
Expand All @@ -22,8 +22,8 @@ const RealProgram = ZkProgram({
},
});

class RealProof extends RealProgram.Proof { }
class Nested extends Struct({ inner: RealProof }) { }
class RealProof extends RealProgram.Proof {}
class Nested extends Struct({ inner: RealProof }) {}

const RecursiveProgram = ZkProgram({
name: 'recursive',
Expand Down Expand Up @@ -59,32 +59,32 @@ const RecursiveProgram = ZkProgram({
},
});

const { verificationKey: realVk } = await RealProgram.compile({ cache: harness.cache })
harness.check(realVk, "realVk");
const { verificationKey: vk } = await RecursiveProgram.compile({ cache: harness.cache })
harness.check(vk, "vk");
const { verificationKey: realVk } = await RealProgram.compile({ cache: harness.cache });
harness.check(realVk, 'realVk');
const { verificationKey: vk } = await RecursiveProgram.compile({ cache: harness.cache });
harness.check(vk, 'vk');
const { proof: realProof } = await RealProgram.make(35);
{
const ok = await harness.verify(realProof, "realVk");
assert.equal(ok, true, "expected real proof to verify with realVk")
const ok = await harness.verify(realProof, 'realVk');
assert.equal(ok, true, 'expected real proof to verify with realVk');
}
const { proof: recursiveProof } = await RecursiveProgram.verifyReal(realProof);

{
const ok = await harness.verify(recursiveProof, "vk");
assert.equal(ok, true, "expected recursive proof to verify with vk");
const ok = await harness.verify(recursiveProof, 'vk');
assert.equal(ok, true, 'expected recursive proof to verify with vk');
}

const { proof: nestedProof } = await RecursiveProgram.verifyNested(0, { inner: realProof })
const { proof: nestedProof } = await RecursiveProgram.verifyNested(0, { inner: realProof });
{
const ok = await harness.verify(nestedProof, "vk");
assert.equal(ok, true, "expected nested proof to verify with vk")
const ok = await harness.verify(nestedProof, 'vk');
assert.equal(ok, true, 'expected nested proof to verify with vk');
}
const { proof: internalProof } = await RecursiveProgram.verifyInternal(undefined)
const { proof: internalProof } = await RecursiveProgram.verifyInternal(undefined);

{
const ok = await harness.verify(internalProof, "vk");
assert.equal(ok, true, "expected internal proof to verify with vk");
const ok = await harness.verify(internalProof, 'vk');
assert.equal(ok, true, 'expected internal proof to verify with vk');
}

await harness.finish()
await harness.finish();
24 changes: 24 additions & 0 deletions src/tests/cache/rsa-regression.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import minimist from 'minimist';
import assert from 'node:assert';
import { rsaZkProgram } from '../../examples/crypto/rsa/program.js';
import { Bigint2048 } from '../../examples/crypto/rsa/rsa.js';
import { generateRsaParams, rsaSign, sha256Bigint } from '../../examples/crypto/rsa/utils.js';
import { CacheHarness } from './harness.js';

const { mode, tarball } = minimist(process.argv.slice(2));

const harness = await CacheHarness({ mode, tarball });

const { verificationKey: vk } = await rsaZkProgram.compile({ cache: harness.cache });
harness.check(vk, 'vk');

const input = await sha256Bigint('How are you!');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i am good x)

const params = generateRsaParams(2048);
const message = Bigint2048.from(input);
const signature = Bigint2048.from(rsaSign(input, params.d, params.n));
const modulus = Bigint2048.from(params.n);

const { proof } = await rsaZkProgram.verifyRsa65537(message, signature, modulus);
const ok = await harness.verify(proof, 'vk');
assert.equal(ok, true, 'expected proof to verify');
await harness.finish();
35 changes: 16 additions & 19 deletions src/tests/cache/simple-regression.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,30 @@
import minimist from "minimist";
import assert from "node:assert";
import { Field, ZkProgram } from "o1js";
import { CacheHarness } from "./harness.js";
import minimist from 'minimist';
import assert from 'node:assert';
import { Field, ZkProgram } from 'o1js';
import { CacheHarness } from './harness.js';

const {
mode,
tarball,
} = minimist(process.argv.slice(2))
const { mode, tarball } = minimist(process.argv.slice(2));

const harness = await CacheHarness({ mode, tarball })
const harness = await CacheHarness({ mode, tarball });

const SimpleProgram = ZkProgram({
name: "simple-program",
name: 'simple-program',
publicOutput: Field,
methods: {
baseCase: {
privateInputs: [],
async method() {
return {
publicOutput: Field(1),
}
}
}
}
})
};
},
},
},
});

const { verificationKey: vk } = await SimpleProgram.compile({ cache: harness.cache });
const { proof } = await SimpleProgram.baseCase();
harness.check(vk, "vk");
const ok = await harness.verify(proof, "vk");
assert.equal(ok, true, "expected proof to verify");
await harness.finish()
harness.check(vk, 'vk');
const ok = await harness.verify(proof, 'vk');
assert.equal(ok, true, 'expected proof to verify');
await harness.finish();
Loading