Skip to content
This repository was archived by the owner on Apr 21, 2026. It is now read-only.
Open
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: 7 additions & 7 deletions src/node/zkPoK.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
MAX_UINT32,
MAX_UINT64,
MAX_UINT128,
MAX_UINT256,
} from "../core/utils/consts";
import {
toBigIntOrThrow,
Expand Down Expand Up @@ -72,12 +71,13 @@ export const zkPack = (
builder.push_u128(bint);
break;
}
case FheTypes.Uint256: {
const bint = toBigIntOrThrow(item.data);
validateBigIntInRange(bint, MAX_UINT256);
builder.push_u256(bint);
break;
}
// [U256-DISABLED]
// case FheTypes.Uint256: {
// const bint = toBigIntOrThrow(item.data);
// validateBigIntInRange(bint, MAX_UINT256);
// builder.push_u256(bint);
// break;
// }
case FheTypes.Uint160: {
const bint =
typeof item.data === "string"
Expand Down
54 changes: 30 additions & 24 deletions src/types/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,32 @@ export enum FheTypes {
Uint64 = 5,
Uint128 = 6,
Uint160 = 7,
Uint256 = 8,
Uint512 = 9,
Uint1024 = 10,
Uint2048 = 11,
Uint2 = 12,
Uint6 = 13,
Uint10 = 14,
Uint12 = 15,
Uint14 = 16,
Int2 = 17,
Int4 = 18,
Int6 = 19,
Int8 = 20,
Int10 = 21,
Int12 = 22,
Int14 = 23,
Int16 = 24,
Int32 = 25,
Int64 = 26,
Int128 = 27,
Int160 = 28,
Int256 = 29,

// [U256-DISABLED]
// Uint256 = 8,

// Remaining FHE types are too high precision and not supported.
// Uint512 = 9,
// Uint1024 = 10,
// Uint2048 = 11,
// Uint2 = 12,
// Uint6 = 13,
// Uint10 = 14,
// Uint12 = 15,
// Uint14 = 16,
// Int2 = 17,
// Int4 = 18,
// Int6 = 19,
// Int8 = 20,
// Int10 = 21,
// Int12 = 22,
// Int14 = 23,
// Int16 = 24,
// Int32 = 25,
// Int64 = 26,
// Int128 = 27,
// Int160 = 28,
// Int256 = 29,
}

/**
Expand All @@ -40,7 +44,8 @@ export const FheUintUTypes = [
FheTypes.Uint32,
FheTypes.Uint64,
FheTypes.Uint128,
FheTypes.Uint256,
// [U256-DISABLED]
// FheTypes.Uint256,
] as const;

/**
Expand All @@ -53,6 +58,7 @@ export const FheAllUTypes = [
FheTypes.Uint32,
FheTypes.Uint64,
FheTypes.Uint128,
FheTypes.Uint256,
// [U256-DISABLED]
// FheTypes.Uint256,
FheTypes.Uint160,
] as const;
29 changes: 16 additions & 13 deletions src/types/encryptable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
CoFheInUint32,
CoFheInUint64,
CoFheInUint128,
CoFheInUint256,
CoFheInAddress,
} from "./encrypted";

Expand Down Expand Up @@ -35,10 +34,11 @@ export type EncryptableUint128 = {
data: string | bigint;
utype: FheTypes.Uint128;
};
export type EncryptableUint256 = {
data: string | bigint;
utype: FheTypes.Uint256;
};
// [U256-DISABLED]
// export type EncryptableUint256 = {
// data: string | bigint;
// utype: FheTypes.Uint256;
// };
export type EncryptableAddress = {
data: string | bigint;
utype: FheTypes.Uint160;
Expand All @@ -59,8 +59,9 @@ export const Encryptable = {
({ data, securityZone, utype: FheTypes.Uint64 }) as EncryptableUint64,
uint128: (data: EncryptableUint128["data"], securityZone = 0) =>
({ data, securityZone, utype: FheTypes.Uint128 }) as EncryptableUint128,
uint256: (data: EncryptableUint256["data"], securityZone = 0) =>
({ data, securityZone, utype: FheTypes.Uint256 }) as EncryptableUint256,
// [U256-DISABLED]
// uint256: (data: EncryptableUint256["data"], securityZone = 0) =>
// ({ data, securityZone, utype: FheTypes.Uint256 }) as EncryptableUint256,
} as const;

export type EncryptableItem =
Expand All @@ -70,7 +71,8 @@ export type EncryptableItem =
| EncryptableUint32
| EncryptableUint64
| EncryptableUint128
| EncryptableUint256
// [U256-DISABLED]
// | EncryptableUint256
| EncryptableAddress;

// COFHE Encrypt
Expand All @@ -87,11 +89,12 @@ export type Encryptable_CoFheInItem_Map<E extends EncryptableItem> =
? CoFheInUint64
: E extends EncryptableUint128
? CoFheInUint128
: E extends EncryptableUint256
? CoFheInUint256
: E extends EncryptableAddress
? CoFheInAddress
: never;
: // [U256-DISABLED]
// : E extends EncryptableUint256
// ? CoFheInUint256
E extends EncryptableAddress
? CoFheInAddress
: never;

export type Encrypted_Inputs<T> = T extends Primitive
? LiteralToPrimitive<T>
Expand Down
7 changes: 4 additions & 3 deletions src/types/encrypted.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ export type CoFheInUint64 = CoFheInItem & {
export type CoFheInUint128 = CoFheInItem & {
utype: FheTypes.Uint128;
};
export type CoFheInUint256 = CoFheInItem & {
utype: FheTypes.Uint256;
};
// [U256-DISABLED]
// export type CoFheInUint256 = CoFheInItem & {
// utype: FheTypes.Uint256;
// };
export type CoFheInAddress = CoFheInItem & {
utype: FheTypes.Uint160;
};
32 changes: 17 additions & 15 deletions src/web/zkPoK.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
MAX_UINT32,
MAX_UINT64,
MAX_UINT128,
MAX_UINT256,
} from "../core/utils/consts";
import {
toBigIntOrThrow,
Expand Down Expand Up @@ -72,12 +71,13 @@ export const zkPack = (
builder.push_u128(bint);
break;
}
case FheTypes.Uint256: {
const bint = toBigIntOrThrow(item.data);
validateBigIntInRange(bint, MAX_UINT256);
builder.push_u256(bint);
break;
}
// [U256-DISABLED]
// case FheTypes.Uint256: {
// const bint = toBigIntOrThrow(item.data);
// validateBigIntInRange(bint, MAX_UINT256);
// builder.push_u256(bint);
// break;
// }
case FheTypes.Uint160: {
const bint =
typeof item.data === "string"
Expand All @@ -95,8 +95,8 @@ export const zkPack = (
// Force multiple event loop cycles to ensure UI updates
const forceUIUpdate = async (cycles: number = 3): Promise<void> => {
for (let i = 0; i < cycles; i++) {
await new Promise(resolve => {
if (typeof requestAnimationFrame !== 'undefined') {
await new Promise((resolve) => {
if (typeof requestAnimationFrame !== "undefined") {
requestAnimationFrame(() => setTimeout(resolve, 0));
} else {
setTimeout(resolve, 16); // ~60fps
Expand All @@ -119,23 +119,25 @@ export const zkProve = async (
);

console.log("Starting zkProve - forcing UI updates...");

// Force multiple UI update cycles before the blocking operation
await forceUIUpdate(5);
console.log("About to start heavy WASM computation (this will block)...");

// Give one final chance for UI to update
return new Promise<ProvenCompactCiphertextList>(resolve => {
return new Promise<ProvenCompactCiphertextList>((resolve) => {
requestAnimationFrame(() => {
setTimeout(() => {
console.log("🔥 Executing build_with_proof_packed (blocking operation)...");

console.log(
"🔥 Executing build_with_proof_packed (blocking operation)...",
);

const compactList = builder.build_with_proof_packed(
crs,
metadata,
ZkComputeLoad.Verify,
);

console.log("✅ build_with_proof_packed completed");
resolve(compactList);
}, 50); // Give 50ms for final UI updates
Expand Down
Loading