TrustWire Documentation
User Journey
- User registers or logs in to the TrustWire platform
- User connects their Web3 wallet
- User creates a new Training Set
- User uploads documents to the Training Set
- User generates Zero-Knowledge Proofs for the documents
- User mints the Training Set to the blockchain
- User mints individual documents to the blockchain
- User can view and share public links to Training Sets and Documents
Functions
Training Sets
- Create a new Training Set
- View all Training Sets
- View details of a specific Training Set
- Mint a Training Set to the blockchain
- Share public links to Training Sets
Documents
- Upload documents to a Training Set
- View document details
- Generate Zero-Knowledge Proof for a document
- Validate a document's Zero-Knowledge Proof
- Mint a document to the blockchain
- Share public links to documents
Blockchain Interactions
- Connect Web3 wallet
- Mint Training Sets and Documents as NFTs
- View minted assets on the blockchain explorer
- Verify proofs using the on-chain verifier contract
Account Management
- View account information
- Change password
- View owned Training Sets and document counts
API Endpoints
Authentication
POST /api/auth/register POST /api/auth/login GET /api/auth/profile POST /api/auth/change-password
Training Sets
GET /api/training-sets POST /api/training-sets GET /api/training-sets/:uuid GET /api/training-sets/public/:uuid POST /api/training-sets/:uuid/deploy
Documents
POST /api/training-sets/:uuid/add-file GET /api/documents/:uuid GET /api/documents/public/:uuid POST /api/documents/:trainingSetUUID/documents/:documentUUID/mint
Proofs
GET /api/proofs/generate/:fileUUID GET /api/proofs/verify/:fileUUID GET /api/proofs/:proofId GET /api/proofs/by-file/:fileId GET /api/proofs/by-zkhash/:zkHash
On-Chain Verifier Contract
The TrustWire verifier contract is deployed on Arbitrum at the following address:
0x539a2cd5fbf43ae693eC33d7eC85F4712Acf18Da
Retrieving Full Proof from On-Chain Token
To retrieve the full proof for a document that has been minted as an on-chain token:
- Use the Document View API endpoint:
GET /api/documents/:uuid
- From the response, note the
blockchain_token_id
andtraining_set_address
. - Call the
getProof
function on the TrustWire Training Set contract attraining_set_address
, passing theblockchain_token_id
as an argument. - The returned data will contain the full proof information.
Formatting Transaction for On-Chain Prover
To verify a proof using the on-chain verifier contract:
- Retrieve the full proof data as described above.
- Format the proof data into the required structure for the
verifyProof
function:function verifyProof( uint[2] calldata _pA, uint[2][2] calldata _pB, uint[2] calldata _pC, uint[5] calldata _pubSignals ) public view returns (bool)
- Prepare the transaction data:
- To:
0x539a2cd5fbf43ae693eC33d7eC85F4712Acf18Da
(Verifier contract address) - Data: Encoded function call to
verifyProof
with the formatted proof data
- To:
- Send the transaction to the Arbitrum network.
- The function will return
true
if the proof is valid, andfalse
otherwise.
Example of formatting the proof data in JavaScript:
const proofData = {
pA: [proof.pi_a[0], proof.pi_a[1]],
pB: [[proof.pi_b[0][1], proof.pi_b[0][0]], [proof.pi_b[1][1], proof.pi_b[1][0]]],
pC: [proof.pi_c[0], proof.pi_c[1]],
pubSignals: proof.public_signals
};
const verifierContract = new ethers.Contract(verifierAddress, verifierABI, signer);
const isValid = await verifierContract.verifyProof(
proofData.pA,
proofData.pB,
proofData.pC,
proofData.pubSignals
);
Security Considerations
- All API endpoints are protected with JWT authentication
- Zero-Knowledge Proofs ensure document privacy while allowing verification
- Blockchain interactions require user's Web3 wallet signature
- Passwords are securely hashed before storage
- Public and private views are strictly separated to ensure data privacy
Best Practices
- Regularly update your password to maintain account security
- Always verify the blockchain address before minting Training Sets or Documents
- Use descriptive names and symbols for your Training Sets to easily identify them
- Generate Zero-Knowledge Proofs for all documents to ensure verifiability
- Carefully review all information before minting to the blockchain, as this action is irreversible
- When verifying proofs on-chain, ensure you're interacting with the correct verifier contract address
For more detailed information, please refer to the API documentation or contact support.