Skip to content

initializeDevice Function

Initializes a device by generating a key pair and preparing a certificate request. This function generates a new private key for the device and uses it to compute the device's public key. The client software must securely store the returned private key. A certificate request is also prepared, which the client can send to a trusted authority to receive their device certificate. The resulting data, including the private key, should be securely stored by the client in a CaptureDeviceData type.

Parameters

  • ta_public_key: ECPoint - The public key of the trusted authority, used in the certificate request.
  • request_body: object - Additional data to be included in the certificate request, e.g., a hardware-based device inte### generateImageCropProof Function

Generates a cryptographic proof for an image crop operation and returns the cropped image file along with the proof. This function handles the entire process from converting the image file to bytes, generating cryptographic hashes, setting up cryptographic circuits, and generating zero-knowledge proofs.

Parameters

  • imageFile: File - The original image file.
  • cropInput: CropInput - The input parameters for the crop operation.
  • fromManifest: ManifestName - The manifest name from which the image originates.

Returns

  • Promise<Result<{eqProof: See3EqProof, croppedImage: File}, Error>>: A promise that resolves to a result object containing the proof and cropped image file or an error.

Process

  1. Convert Image to Bytes: Converts the original image file to RGB bytes.
  2. Generate Prover Inputs: Asynchronously gathers necessary data for proof generation:
    • Crop circuit configuration.
    • Image data converted to field elements.
    • Hash of the original image.
    • Cropped image and its hash.
  3. Error Handling: If there is an error in generating prover inputs, it returns an error.
  4. Setup Cryptographic Environment: Initializes necessary cryptographic modules and configurations.
  5. Generate Cryptographic Proof: Using Noir and Barretenberg backend, generates a zero-knowledge proof for the crop operation.
  6. Construct Equality Proof (eqProof): Packages the cryptographic proof with additional metadata about the edit operation.
  7. Return Results: Returns the equality proof and the file of the cropped image.

Example Usage

grity proof.

Returns

  • An object containing:
    • privateKey: The generated private key for the device.
    • certificateRequest: An object containing:
      • ta-public-key: The public key of the trusted authority.
      • camera-public-key: An object with properties x and y representing the device's public key coordinates.
      • request_body: The additional data provided in the certificate request.

Example Usage

typescript
const taPublicKey = { x: "0x....", y: "0x...." };
const requestBody = { deviceIntegrity: "valid" };
const deviceData = initializeDevice(taPublicKey, requestBody);
console.log(deviceData);