Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature request] exposing/(de)serializing proof and verification key #54

Closed
Trivo25 opened this issue Dec 23, 2021 · 3 comments
Closed

Comments

@Trivo25
Copy link
Member

Trivo25 commented Dec 23, 2021

Thins idea was also mentioned in Discord.

Idea: Potentially allowing to "export" and "import" proofs and their coressponding verification key to allow verification and proofing of code outside of the Mina blockchain, inside of web2.0.

Reason: It would open up SnarkyJS to more developers, allowing many web 2.0 devs and other developers to utilize the power of zero knowledge proofs to some extend in normal web applications.

Possible usage: What it could look like

// example from ex00_preimage.ts

class Main extends Circuit {
  @circuitMain
  static main(preimage: Field, @public_ hash: Field) {
    Poseidon.hash([preimage]).assertEquals(hash);
  }
}

// ... 

let proof = Main.prove(/* .. */); // returns the proof
let encodedProof = proof.toBase58()) // potentially encoded in base58 for easy use eg 'RJcTKtswS9xgY4FDfxCq4ZaLRfQwGME8GYPFGpxieWZXJMGUuqN1zdKYEM6dLZER'  

let verificationKey = Main.getVerificationKey(); // returns the verification key; potentially also encoded for easy use

// usage in a different application

class MyVerifier extends Verifier {
  constructor(key: VerificationKey) {
     // ...
  }
}

let verificationKey = 'someVerificationKeyEncoded';
let myVerifier = new Verifier(VerificationKey.fromString(verificationKey))

let proof = 'someProofEncoded';
let isValid = myVerifier.verify(Proof.fromString(proof)); // returns true if proof matches verification key

Is something like that feasible and makes sense?
Or is something like that potentially even planned already?

Thanks!

@Trivo25 Trivo25 closed this as completed Sep 22, 2022
@Scratch-net
Copy link

@Trivo25 is it implemented? It would be nice to have both compiled circuits and keys to be exportable for off-chain applications

@Trivo25
Copy link
Member Author

Trivo25 commented Feb 28, 2023

@Trivo25 is it implemented? It would be nice to have both compiled circuits and keys to be exportable for off-chain applications

Yes, proofs can be serialized as well as verification keys (of smart contract as well as the ZkProgram API). The prover key can't be currently serialized but there's a separate issue for that #87

@Scratch-net
Copy link

Ok, I was just playing with a plain circuit and could not find it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants