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
9 changes: 7 additions & 2 deletions DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,15 @@ session.verify().ezkl().execute({...})

### UltraHonk

Supports versions: `V0_84`, `V3_0`
Supports versions: `V0_84`, `V3_0`, `Legacy`
Supports variants: `Plain`, `ZK`

**Note for zkverifyjs v2.4.0+ and runtime v1.6.0+**: The `version` and `variant` options are required. If `version` is omitted, zkverifyjs defaults to `V0_84` for backwards compatibility and logs a warning.
**Note for zkverifyjs v2.4.0+ and runtime v1.6.0+**: The `version` and `variant` options are required. If `version` is omitted, zkverifyjs defaults to:

* `V0_84` on runtime v1.6.0
* `Legacy` on runtime v1.6.1+

The `Legacy` default preserves pre-versioning Ultrahonk statement hash compatibility.

```typescript
session.verify().ultrahonk({
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,14 @@ session.verify().ezkl().execute({...})
```

### UltraHonk
Supports versions: `V0_84`, `V3_0`
Supports versions: `V0_84`, `V3_0`, `Legacy`
Supports variants: `Plain`, `ZK`

**Note for zkverifyjs v2.4.0+ and runtime v1.6.0+**: The `version` and `variant` options are required. If `version` is omitted, zkverifyjs defaults to `V0_84` for backwards compatibility and logs a warning.
**Note for zkverifyjs v2.4.0+ and runtime v1.6.0+**: The `version` and `variant` options are required. If `version` is omitted, zkverifyjs defaults to:
- `V0_84` on runtime v1.6.0
- `Legacy` on runtime v1.6.1+

The `Legacy` default preserves pre-versioning Ultrahonk statement hash compatibility.

```typescript
session.verify().ultrahonk({
Expand Down
3,424 changes: 2,230 additions & 1,194 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zkverifyjs",
"version": "3.0.0",
"version": "3.1.0",
"description": "Submit proofs to zkVerify and query proof state with ease using our npm package.",
"author": "zkVerify <web3-platform@zkverify.io>",
"license": "GPL-3.0",
Expand Down
16 changes: 15 additions & 1 deletion src/config/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { RuntimeVersion } from '../enums.js';
import { getZkvTypes, legacyZkvTypes, v1_6ZkvTypes } from './index.js';
import {
getZkvTypes,
legacyZkvTypes,
v1_6_1ZkvTypes,
v1_6ZkvTypes,
} from './index.js';

describe('getZkvTypes', () => {
it('uses legacy type definitions before runtime version 1.6.0', () => {
Expand All @@ -19,4 +24,13 @@ describe('getZkvTypes', () => {
}),
).toBe(v1_6ZkvTypes);
});

it('uses v1.6.1 type definitions from runtime version 1.6.1', () => {
expect(
getZkvTypes({
specName: 'zkverify',
specVersion: RuntimeVersion.V1_6_1,
}),
).toBe(v1_6_1ZkvTypes);
});
});
27 changes: 27 additions & 0 deletions src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,36 @@ export const v1_6ZkvTypes: ZkvTypes = {
},
};

export const v1_6_1ZkvTypes: ZkvTypes = {
...commonZkvTypes,
UltraHonkVk: {
_enum: {
V0_84: 'Bytes',
V3_0: 'Bytes',
Legacy: 'Bytes',
},
},
TeeIntelVk: {
tcb_response: 'Bytes',
certificates: 'Bytes',
},
TeeVk: {
_enum: {
Intel: 'TeeIntelVk',
},
},
};

export const zkvTypes = legacyZkvTypes;

export function getZkvTypes(runtimeSpec?: RuntimeSpec): ZkvTypes {
if (
runtimeSpec !== undefined &&
runtimeSpec.specVersion >= RuntimeVersion.V1_6_1
) {
return v1_6_1ZkvTypes;
}

if (
runtimeSpec !== undefined &&
runtimeSpec.specVersion >= RuntimeVersion.V1_6_0
Expand Down
2 changes: 2 additions & 0 deletions src/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export enum Risc0Version {
export enum UltrahonkVersion {
V0_84 = 'V0_84',
V3_0 = 'V3_0',
Legacy = 'Legacy',
}

export enum UltrahonkVariant {
Expand Down Expand Up @@ -96,6 +97,7 @@ export enum RuntimeVersion {
V1_3_0 = 1003000,
V1_5_0 = 1005000,
V1_6_0 = 1006000,
V1_6_1 = 1006001,
}

export const PUBLIC_ZK_VERIFY_EVENTS: ZkVerifyEvents[] = [
Expand Down
25 changes: 23 additions & 2 deletions src/session/validator/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe('validateProofTypeOptions', () => {
).toThrow("does not support a 'version' option");
});

it('defaults missing version from runtime version 1.6.0', () => {
it('defaults missing version to V0_84 on runtime version 1.6.0', () => {
const options = {
proofType: ProofType.ultrahonk,
config: { variant: UltrahonkVariant.Plain },
Expand All @@ -78,7 +78,28 @@ describe('validateProofTypeOptions', () => {
});
expect(options.config).toEqual({ variant: UltrahonkVariant.Plain });
expect(warnSpy).toHaveBeenCalledWith(
expect.stringContaining("Defaulting missing 'version'"),
expect.stringContaining(`'${UltrahonkVersion.V0_84}'`),
);
});

it('defaults missing version to Legacy on runtime version 1.6.1', () => {
const options = {
proofType: ProofType.ultrahonk,
config: { variant: UltrahonkVariant.Plain },
};

const result = validateProofTypeOptions(
options,
runtimeSpec(RuntimeVersion.V1_6_1),
);

expect(result.config).toEqual({
version: UltrahonkVersion.Legacy,
variant: UltrahonkVariant.Plain,
});
expect(options.config).toEqual({ variant: UltrahonkVariant.Plain });
expect(warnSpy).toHaveBeenCalledWith(
expect.stringContaining(`'${UltrahonkVersion.Legacy}'`),
);
});

Expand Down
15 changes: 11 additions & 4 deletions src/session/validator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export function validateProofTypeOptions(

case ProofType.ultrahonk: {
if (isVersionAtLeast(runtimeSpec, RuntimeVersion.V1_6_0)) {
const defaulted = withDefaultedUltrahonkVersion(options);
const defaulted = withDefaultedUltrahonkVersion(options, runtimeSpec);

if (!isVersionedUltrahonkConfig(defaulted)) {
throw new Error(
Expand Down Expand Up @@ -141,22 +141,29 @@ export function validateProofTypeOptions(
}
}

function withDefaultedUltrahonkVersion(options: ProofOptions): ProofOptions {
function withDefaultedUltrahonkVersion(
options: ProofOptions,
runtimeSpec: RuntimeSpec,
): ProofOptions {
const config = options.config as UltrahonkConfig | undefined;

if (config?.variant === undefined || config.version !== undefined) {
return options;
}

const defaultVersion = isVersionAtLeast(runtimeSpec, RuntimeVersion.V1_6_1)
? UltrahonkVersion.Legacy
: UltrahonkVersion.V0_84;

console.warn(
`zkverifyjs: Proof type '${ProofType.ultrahonk}' now supports versioned proofs on runtime version 1.6.0 or later. Defaulting missing 'version' to '${UltrahonkVersion.V0_84}' for backwards compatibility. Pass 'version' explicitly to silence this warning.`,
`zkverifyjs: Proof type '${ProofType.ultrahonk}' now supports versioned proofs on runtime version 1.6.0 or later. Defaulting missing 'version' to '${defaultVersion}' for backwards compatibility. Pass 'version' explicitly to silence this warning.`,
);

return {
...options,
config: {
...config,
version: UltrahonkVersion.V0_84,
version: defaultVersion,
},
};
}
Expand Down
2 changes: 1 addition & 1 deletion tests/common/data/tee_intel.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions tests/common/runners.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('generateTestPromises', () => {
);
});

it('excludes v1.6-only explicit configs before runtime version 1.6.0', async () => {
it('excludes legacy-only explicit ultrahonk configs before runtime version 1.6.1', async () => {
const proofOptions: ProofOptions[] = [];

generateTestPromises(
Expand Down Expand Up @@ -66,7 +66,7 @@ describe('generateTestPromises', () => {
{
proofType: ProofType.ultrahonk,
config: {
version: UltrahonkVersion.V0_84,
version: UltrahonkVersion.Legacy,
variant: UltrahonkVariant.Plain,
},
},
Expand Down
11 changes: 9 additions & 2 deletions tests/common/runners.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ProofOptions, ProofType, RuntimeVersion } from "../../src";
import { ProofOptions, ProofType, RuntimeVersion, UltrahonkVersion } from "../../src";
import { RuntimeSpec } from "../../src/types";
import {
loadProofAndVK,
Expand Down Expand Up @@ -142,7 +142,8 @@ export const generateTestPromises = (
break;

case ProofType.ultrahonk:
// Legacy fallback coverage: SDK defaults missing version to V0_84 on runtime v1.6.0+.
// Legacy fallback coverage: SDK defaults missing version to V0_84 on runtime v1.6.0
// and to Legacy on runtime v1.6.1+.
// Remove these generated cases when support for pre-versioned Ultrahonk calls is dropped.
testOptions.ultrahonkVariants.forEach((variant) => {
promises.push(runTest({
Expand All @@ -155,6 +156,9 @@ export const generateTestPromises = (
}
testOptions.ultrahonkVersions
.filter((v) => !excludedVersions.includes(v))
.filter((v) =>
supportsV1_6_1(runtimeSpec) ? true : v !== UltrahonkVersion.Legacy
)
.forEach((version) => {
testOptions.ultrahonkVariants.forEach((variant) => {
promises.push(runTest({
Expand Down Expand Up @@ -202,6 +206,9 @@ export const generateTestPromises = (
const supportsV1_6_0 = (runtimeSpec?: RuntimeSpec): boolean =>
runtimeSpec === undefined || runtimeSpec.specVersion >= RuntimeVersion.V1_6_0;

const supportsV1_6_1 = (runtimeSpec?: RuntimeSpec): boolean =>
runtimeSpec === undefined || runtimeSpec.specVersion >= RuntimeVersion.V1_6_1;

export const runAllProofTests = async (
withAggregation: boolean
) => {
Expand Down
5 changes: 3 additions & 2 deletions tests/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,9 @@ export function getProofFilenameComponents(
if (!variant) {
throw new Error('Ultrahonk fixture lookup requires a variant.');
}
// Legacy fallback test path: SDK defaults missing Ultrahonk version to V0_84 on runtime v1.6.0+.
// Remove this default when support for pre-versioned Ultrahonk calls is dropped.
// Legacy fallback test path: SDK defaults missing Ultrahonk version to V0_84 on runtime v1.6.0
// and to Legacy on runtime v1.6.1+.
// Fixtures still reuse V0_84 bytes because Legacy wraps the same proof/VK format.
components.push(
(version ?? UltrahonkVersion.V0_84).toLowerCase(),
variant.toLowerCase(),
Expand Down