Skip to content

provable-things/proof-verification-tool

Repository files navigation

Proof Verification Tool

Node Version Join the chat at https://gitter.im/oraclize/ethereum-api Docs@Oraclize.it Contributions Welcome! HitCount

Version 0.2.4

The proof-verification-tool allows users to verify if an Oraclize proof is valid.

It can be used:

From the Command Line.

It can be embedded:

As a Module in a Node app (though not yet via npm);

In the Browser, in j2v8.

Functions Exposed

getProofType(proof: string): ProofType: accepts a hexadecimal string (the proof), and returns a proof type. For now, the proof types supported are:

  • proofType_TLSNotary

  • proofType_Android

  • proofType_Ledger

verifyProof(proof: Uint8Array, ?callback): Promise<ParsedProof>: accepts a byte array (the proof), an optional callback, and returns a promise containing the following object:

    {
      mainProof: {
        proofType: MainProof,
        isVerified: boolean,
        status: VerificationStatus
      },
      extensionProof: ?{
        proofType: ExtensionProof,
        isVerified: boolean,
        status: VerificationStatus
      },
      proofShield: ?{
        proofType: ShieldProof,
        isVerified: boolean,
        status: VerificationStatus },
      message: string | {type: 'hex', value: string},
      proofId: string,
    }

Please, note that the char ?, in the json snippet above, stands for optional.

✒️ Notes:

The proofType_Android has two versions. The user should provide the configuration parameters for v1 and v2 in the config file ./settings/settings.json. These parameters are provided by the Android device and along with the Google API key, are used to generate and validate the proof. The values provided in settings are just examples of how they are used.

All the newly generated proofType_Android proofs are v2.

💻 Use from the Command Line

Please, remember that the target is ECMA 2015, but if you want to use yarn you should have at least node 4.2.6.

For using the Oraclize Proof Verification Tool from the command line, execute the following steps:

1) Clone the repository:

❍ git clone https://github.com/oraclize/proof-verification-tool.git

2) Install the deps:

❍ cd proof-verification-tool && yarn install

3) Build the project:

❍ yarn build

🔎 Proof Verification

When you use the proof-verification-tool from the command line, you can check if the proof is valid or extract the message contained in the proof:

a) Check the proof validity:

❍ npm run verify <path/to/proof>

  • If the proof is valid, the tool prints out the ParsedProof, then exits cleanly showing a SUCCESS message;

  • If the proof is not valid, the tool shows a FAILURE message, then exits with a non-zero exit code.

b) Extract the message contained in the proof:

❍ node ./lib/cli <path/to/proof> -s <path/to/output>

  • If the proof is valid, the tool prints out the ParsedProof, then exits cleanly with an exit code 0;

  • If the proof is not valid, the tool exits with a non-zero exit code.

If the message contained in the proof is of the type string, it will be written to the given output-path as a UTF-8 string; if it is of type hex, the data wiil be written as binary.

 

Embed in a Node App

For using the Oraclize Proof Verification Tool from a Node app, execute the following steps:

1) Clone the repository:

❍ git clone https://github.com/oraclize/proof-verification-tool.git

2) Install the deps:

❍ cd proof-verification-tool && yarn install

3) Build the project:

❍ yarn build

4) Import the module in your app with:

❍ import { verifyProof, getProofType } from 'path to proof verification tool directory' + '/lib/index.js\'

The target is ECMA 2015, but if you want to use yarn you should have at least node 4.8.0.

 

Embed in a Java App

For using the Oraclize Proof Verification Tool from a Java app, execute the following steps:

1) Clone the repository:

❍ git clone https://github.com/oraclize/proof-verification-tool.git

2) Install the deps:

❍ cd proof-verification-tool && yarn install

3) Build the project:

❍ yarn build

4) Create the bundle:

❍ yarn browserify-node

The target is ECMA 2015, but if you want to use yarn you should have at least node 4.8.0.

 

Embed in a Browser App

Same as embed in a Node app

If you use browserify, when you build the bundle, execute:

❍ -r fs:browserify-fs

 

📷 Examples of Passing Proofs:

The passing Android V2 Proof! The passing TLSN Proof! The passing Ledger Proof!

 

Test Available Proofs:

To test all the successfully verified proofs in the folder src/proof execute:

❍ npm run test:proofs

To test all the failing proofs in the folder src/proof/failed execute:

❍ npm run test:proofs-failed

 

📢 Support

If you have any issues, head on over to our Gitter channel to get timely support!

Happy verification!