Anoma.CairoResource.ProofRecord (Anoma v0.32.0)

I am a proof record for a shielded resource.

Summary

Functions

Callback implementation for Noun.Nounable.Kind.from_noun/1.

Generates a compliance proof using the provided witness and the fixed compliance proving key.

Calculates the Cairo program hash for the given ProofRecord.

Generates a cairo proof using the provided proving key and witness.

Verifies the given ProofRecord.

Types

@type t() :: %Anoma.CairoResource.ProofRecord{
  instance: binary(),
  proof: binary(),
  verifying_key: binary()
}

Functions

Link to this function

from_noun(arg1)

@spec from_noun(Noun.t()) :: {:ok, t()} | :error

Callback implementation for Noun.Nounable.Kind.from_noun/1.

Link to this function

generate_compliance_proof(witness)

@spec generate_compliance_proof(binary()) :: {:ok, t()} | {:error, term()}

Generates a compliance proof using the provided witness and the fixed compliance proving key.

This function reads the compliance proving key from a JSON file. It then uses this proving key to generate a proof based on the given witness.

Parameters

  • witness (binary()): The witness data used to generate the compliance proof.

Returns

  • {:ok, t()}: If the compliance proof is successfully generated.
  • {:error, term()}: If there is an error, such as the compliance proving key file not being found.
Link to this function

get_cairo_program_hash(proof_record)

@spec get_cairo_program_hash(t()) :: binary()

Calculates the Cairo program hash for the given ProofRecord.

Parameters

  • proof_record: A ProofRecord struct containing the instance.

Returns

  • A binary representing the Cairo program hash.
Link to this function

padding_resource_logic_proving_key()

@spec padding_resource_logic_proving_key() :: {:error, atom()} | {:ok, binary()}
Link to this function

prove(proving_key, witness, instance \\ <<>>)

@spec prove(binary(), binary(), any()) :: {:error, any()} | {:ok, t()}

Generates a cairo proof using the provided proving key and witness.

Parameters

  • proving_key (binary): The proving key used for generating the proof.
  • witness (binary): The witness data used for generating the proof.
  • _instance (any, not used): An instance parameter, defaults to an empty binary. In zkvms, the instance is an output rather than an input.

Returns

  • {:ok, %ProofRecord{}}: A tuple containing :ok and a ProofRecord struct with the generated proof and instance.
  • {:error, any()}: A tuple containing :error and the reason for the failure.
@spec verify(t()) :: boolean() | {:error, term()}

Verifies the given ProofRecord.

This function takes a ProofRecord and verifies its proof against its public inputs. It converts the binary data of both the instance and the proof to lists before passing them to the Cairo.verify/2 function. There is no verifying key in the Cairo system; instead, a program segment in the instance serves this purpose. For efficiency, we provide a method to retrieve the verifying key from instance without explicitly using the verifying key field.

Parameters

  • proof: A ProofRecord containing the verifying key, proof and public inputs to be verified.

Returns

  • true if the proof is valid.
  • false if the proof is invalid.
  • {:error, term()} if the verification encounters errors.