Skip to content

Instantly share code, notes, and snippets.

@joschisan
joschisan / proofs.rs
Last active February 29, 2024 19:43
Sigma Protocol Proofs
use bitcoin_hashes::{sha256, Hash, HashEngine};
use bls12_381::{G1Affine, G1Projective, Scalar};
use core::array;
use ff::Field;
use group::Curve;
use rand::{thread_rng, SeedableRng};
use rand_chacha::ChaChaRng;
use std::io::Write;
fn prove<const N: usize, const M: usize, const S: usize>(

Current Transaction Submission State Machine

The reason for this migration is to make the TransactionError available in the Rejected state. While we are at it we remove the operation state wrapper as operation ids will in the future be tracked outside of the state machines and this is the only place where its used anyways. Furthermore, we make the transaction available in all states in case we need it in the future and remove the deprectaed NonRetryableError state.

OperationState<TxSubmissionStates> {
    operation_id: OperationId,
    state: TxSubmissionStates,
}

SendStates

graph LR

Funding -- funding transaction is rejected --> Failure
Funding -- funding transaction is accepted --> Funded
Funded -- payment attempt expires --> Refunding
Funded -- gateway cancels payment attempt --> Refunding
Funded -- payment is confirmed --&gt; Success