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
.
❍ 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.
❍ 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.
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
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.
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
.
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
.
Same as embed in a Node app
If you use browserify
, when you build the bundle, execute:
❍ -r fs:browserify-fs
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
❍ If you have any issues, head on over to our Gitter channel to get timely support!
Happy verification!