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
Functions
from_noun(arg1)
Callback implementation for Noun.Nounable.Kind.from_noun/1
.
generate_compliance_proof(witness)
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.
get_cairo_program_hash(proof_record)
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.
padding_resource_logic_proving_key()
prove(proving_key, witness, instance \\ <<>>)
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 aProofRecord
struct with the generated proof and instance.{:error, any()}
: A tuple containing:error
and the reason for the failure.
verify(proof)
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.