Skip to content

Instantly share code, notes, and snippets.

@rkdud007
Last active March 7, 2024 02:26
understanding what happening with Cairo Program when going through SHARP prover

SHARP status Flow ( what is happening here )

tldr : You write ANY Cairo program -> can send this program to STARK prover-> (if you used prover as SHARP) multiple Cairo programs sent in batch -> validate statement expressed in the all batched Cairo code -> if pass, we could consider all Cairo program in batch is valid ( proven )

Definition

  • train: batch of jobs, this is unit of SHARP. ( 1 train == N jobs )
  • 1 job handles 1 fact meaning 1 cairo program
  • job key: unique identifier assigned to your job by SHARP
  • fact hash: keccak(program_hash, program_output_hash),
  • program hash : Pedersen hash of the compiled program
  • program output : uint256[]. output of field elements from the cairo program run on CairoVM. Also call as trace of the program. This sent to a STARK prover in order to prove the validity of the statement expressed in the Cairo code.
  • program output hash : keccak(program_output), when program output is uint256[]

Note: to use cairo commands below, need to install cairo : https://www.cairo-lang.org/getting-started/

How to get program hash?

cairo-hash-program source-code

# first compile the cairo program
cairo-compile {cairo_program_path} --output {output_file_path}

# with this compiled program, compute program hash
cairo-hash-program --program {output_file_path}

how to submit program to sharp ( start proving process )? :

cairo-sharp submit --source sharp_test.cairo \
    --program_input input.json
  • This returns result like this
sharpSubmitResult {
  jobId: 'd576e107-3c6d-41dc-b829-bf75c22d21f7',
  factHash: '0x7a6b5d15800708e2c1fe2002c9be2410bc8d1f1923406a14cd9bbe03c8dae122'
}

When SHARP Flow end

Proving Detail

I'm also learning how does STARK works, atm not at level can write much about proving detail. Highly recommend this one : SHARP mechanism in more detail-ethresearch, If anyone know relevant reading, please lmk

SHARP fact compute logic implementation

Reference

@0xAsten
Copy link

0xAsten commented Feb 23, 2024

Great work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment