Circuit used for verifying payments using the Openbanking standard
- Verifies PS256 signature over the payment payload
- Extracts, creditor sort code, payment id, currency code, and currency amount
signature_limbs- signature over Openbanking payment in limb formatmodulus_limbs- modulus of pubkey used to verify signature over payment in limb formatredc_limbs- reduction parameters of pubkey used to verify signature over payment in limb formatpartial_hash_start- partial hash of the JWT header used to reduce constraintsheader_delimiter_index- index of delimiter "." between JWT header and payment JSON payload inpayloadparameterpayload- payment payload of the form <jwt_header>.<json_payload>
amount- payment currency amountcurrency_code- three letter code of the currency type (ex: GBP)payment_id- unqiue ID of payment, useful when preventing double spendssort_code- sort code of creditor account
fn main(params: OpenbankingVerifierParams) -> pub OpenbankingVerifierReturn {
verify_openbanking_payment(params)
}To import into you project you can provider the following line to your Nargo.toml
openbanking_verifier = { git = "https://github.com/Mach-34/openbanking-circuit/tree/feat/add-comments", directory = "./lib" }
- Simply run
nargo testin the root directory
- Compile circuit
cd ./scripts && ./compile.sh
- Navigate to JS directory
cd ../js/src
- Run JS code and view logged witness
node index.js
Functions as a non-custodial onramp powered through payments using the Openbanking standard
-
Liquidity provider makes a deposit to the escrow contract by calling
init_escrow_balance. They enter their bank account sort code, the currency they wish to accept, and the total amount of USDC tokens they wish to escrow. The bank account sort code and currency code will be hashed together to create a unique commitment that maps to a public balance. This commitment is then stored in the contract's private state for later retrieval by the provider. Additionally the provider's tokens will be transfered from their private balance to the public balance of the escrow -
When a user wishes to convert their fiat into crypto they would initiate a payment to an escrow provider's bank account (current only uses Revolut). Upon confirmation of a successful payment the server / typescript library to format the inputs to a contract friendly format. When the inputs are ready the user would then call
prover_payment_and_claim. This would then use the verify_payment circuit from Openbanking verifier library and extract the sort_code, currency_code, payment_id, and amount. The payment_id is used to prevent double spends in the contract, the sort_code and currency_code are hashed together to compute the commitment the liquidity provider has mapped to their balance. The amount extracted from the payment verifier circuit with be decremented from the public escrow balance, and the tokens will be transferred from the escrow contracts's public balance to the payee's private token balance -
While maintaining an escrow position, the provider may choose to add to their balance at any time by calling
increment_escrow_balance. A provider may also withdraw from their balance by callingwithdraw_escrow_balance. There are block restricted withdrawal windows stored with the escrow balance tied to when a provider has last deposited. This prevents foulplay on the part of the provider. An example would be if they attempted to withdraw their funds after a user had sent money to their bank account but had not yet proven the payment on Aztec and claimed their tokens
Typescript library used for generating circuit inputs and exporting utility functions relevant to circuit / contract
npm i @openbanking-nr/js-inputs
=================================
yarn add @openbanking-nr/js-inputs
- Frontend implementation: https://github.com/Mach-34/aztec-openbanking-ui
- Server: https://github.com/openbanking-nr/openbanking.nr-server/tree/main/src