see3-js
see3-js is a JavaScript library for implementing See3-compliant JavaScript applications. It supports the generation and verification of attestation proofs, as well as basic editing capabilities.
It is built on noir.js, WebWorkers, and WebAssembly.
DANGER
see3-js is still in development. It is not ready for production use, features known bugs, and is not yet fully documented. Workarounds are used heavily for the sake of the demo. The codebase is being rewritten and refactored.
Demo Application
There is a demo application which leverages see3-js on GitHub. The build instructions are given in the repository's README.md
.
Zod Schemas in utils/schemas.ts
This file defines various Zod schemas for validating the structure of data objects used throughout the application. These schemas ensure that data conforms to expected formats before processing or storage.
Types and Schemas
Each schema has a corresponding TypeScript type. The schemas are defined in utils/schemas.ts
and the types are defined in utils/types.ts
.
Types are named identically to the schemas, except without the trailing Schema
.
These are used throughout.
StringNumberSchema
- Validates strings that contain only numeric characters.
- Regex:
/^[0-9]+$/
HexStringSchema
- Validates strings representing hexadecimal values.
- Regex:
/^([0-9a-f][0-9a-f])+$/
HexNumberSchema
- Validates strings representing hexadecimal numbers prefixed with
0x
. - Regex:
/^0x([0-9a-f][0-9a-f])+$/
- Validates strings representing hexadecimal numbers prefixed with
Base64Schema
- Validates Base64 encoded strings.
- Regex:
/^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/
UUIDSchema
- Validates strings formatted as UUIDs.
- Regex:
/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/
ECPointSchema
- Validates objects representing elliptic curve points with
x
andy
coordinates as hexadecimal numbers.
- Validates objects representing elliptic curve points with
SignatureSchema
- Validates signature objects containing:
signature-R
: An elliptic curve point.signature-s
: A hexadecimal number.
- Validates signature objects containing:
CaptureDeviceDataSchema
- Validates data related to a capture device, including:
camera-private-key
: A hexadecimal number.ta-public-key
: An elliptic curve point.ta-signature
: A signature.
- Validates data related to a capture device, including:
CropDataSchema
- Validates data for an image crop operation, including:
position
: Coordinatesx
andy
as numeric strings.previous-size
andnew-size
: Dimensionswidth
andheight
as numeric strings.
- Validates data for an image crop operation, including:
ManifestNameSchema
- Alias for
UUIDSchema
, used for validating manifest names.
- Alias for
ResizeDataSchema
- Validates data for an image resize operation, specifically the
factor
as a hexadecimal number.
- Validates data for an image resize operation, specifically the
EditSchema
- A union schema that validates either a crop or resize operation.
ManifestPointerSchema
- Validates manifest pointers, including:
hash
: A hexadecimal string.contained-in
: An optional UUID.
- Validates manifest pointers, including:
ManifestPointerStrictSchema
- Similar to
ManifestPointerSchema
but withcontained-in
as a required UUID.
- Similar to
AttestationProverInputMapSchema
- Validates complex structures used in cryptographic attestations.
See3AttestationDataSchema
- Validates data for a See3 attestation, including zero-knowledge proof components and public keys.
See3AttestationSchema
- Validates a complete See3 attestation object.
See3EqProofDataSchema
- Validates data for an equality proof, including the cryptographic proof and edit history.
See3EqProofSchema
- Validates a complete See3 equality proof object.
These schemas are crucial for maintaining data integrity and ensuring that all data interactions within the application are predictable and secure.